Returns the residue name of an Pybel or OpenBabel atom.
509626
def whichrestype(atom):
    """"""
    atom = atom if not isinstance(atom, Atom) else atom.OBAtom  # Convert to OpenBabel Atom
    return atom.GetResidue().GetName() if atom.GetResidue() is not None else None
361888
def _parse(self):
        
        
        atom_counter = 0
        
        structure_build = self.structure_builder
        
        residues = self._extract_residues()
        
        cur_model = None
        cur_chain = None
        structure_build.init_seg(' ') # There is never a SEGID present
        
        for r in residues:

            # New model?
            if cur_model != r['model']:
                cur_model = r['model']
                try:
                    structure_build.init_model(cur_model)
                except PDBConstructionException, message:
                    self._handle_builder_exception(message, r) 
            
            # New chain?
            if cur_chain != r['chain']:
                cur_chain = r['chain']
                try:
                    structure_build.init_chain(cur_chain)
                except PDBConstructionException, message:
                    self._handle_builder_exception(message, r)

            # Create residue
            if r['name'] in AA_LIST: # Get residue type crudely since there is no HETATM / ATOM
                hetero_flag = ' '
            elif r['name'] == 'WAT' or r['name'] == 'HOH':
                hetero_flag = 'W'
            else:
                hetero_flag = 'H'
            
            # Some terminal atoms are added at residue 0. This residue has a small number of atoms.
            # Protonated non-terminal glycine has 7 atoms. Any of these residues is smaller.
            # HETATMs have only a couple of atoms (3 for water for example) and they are ok.
            
            if (len(r['atoms']) >= 7) or (hetero_flag != " "):
                try:
                    structure_build.init_residue(r['name'], hetero_flag, r['number'], r['icode'])
                except PDBConstructionException, message:
                    self._handle_builder_exception(message, r)
            
                # Create Atoms
                for atom in r['atoms']:
                    a = self._parse_atom(atom)

                    if not sum(a['coord']): # e.g. HG of metal bound CYS coords are 0,0,0.
                        continue
                        
                    try:
                        atom_counter += 1
                        # fullname = name; altloc is empty;
                        structure_build.init_atom(a['name'], a['coord'], a['bfactor'], a['occupancy'], ' ',
                                                    a['name'], atom_counter, a['element'],  hetero_flag)
                    except PDBConstructionException, message:
                        self._handle_builder_exception(message, r)      
            
            elif len(r['atoms']) < 7: # Terminal Residues
                                
                for atom in r['atoms']:
                    
                    a = self._parse_atom(atom)
                    
                    if not sum(a['coord']): # e.g. HG of metal bound CYS coords are 0,0,0.
                        continue

                    atom_counter += 1                    
                    ter_atom = Atom(a['name'], a['coord'], a['bfactor'], a['occupancy'], ' ',
                                    a['name'], atom_counter, a['element'], hetero_flag)
                    
                    if a['name'] in N_TERMINAL_ATOMS:
                        
                        inc_struct = self.structure_builder.get_structure()
                        for model in inc_struct:
                            for chain in model:
                                if chain.id == r['chain']:
                                    for residue in chain: # Find First residue matching name
                                        if residue.resname == r['name']:
                                            residue.add(ter_atom)
                                            break
                    
                    elif a['name'] in C_TERMINAL_ATOMS:

                        inc_struct = self.structure_builder.get_structure()
                        c_ter = None
                        for model in inc_struct:
                            for chain in model:
                                if chain.id == r['chain']:
                                    for residue in chain: # Find Last residue matching name
                                        if residue.resname == r['name']:
                                            c_ter = residue
                                    if c_ter:
                                        c_ter.add(ter_atom)
83409
def product_name(self):
        
        buf = (ctypes.c_char * self.MAX_BUF_SIZE)()
        self._dll.JLINKARM_EMU_GetProductName(buf, self.MAX_BUF_SIZE)
        return ctypes.string_at(buf).decode()
765816
def getAtomLinesForResidueInRosettaStructure(self, resid):
        ''''''
        lines = [line for line in self.lines if line[0:4] == "ATOM" and resid == int(line[22:27])]
        if not lines:
            #print('Failed searching for residue %d.' % resid)
            #print("".join([line for line in self.lines if line[0:4] == "ATOM"]))
            raise Exception("Could not find the ATOM/HETATM line corresponding to residue '%(resid)s'." % vars())
        return lines
1127833
def register_name(self, register_index):
        
        result = self._dll.JLINKARM_GetRegisterName(register_index)
        return ctypes.cast(result, ctypes.c_char_p).value.decode()
944213
def GetRosettaResidueMap(self, ConvertMSEToAtom = False, RemoveIncompleteFinalResidues = False, RemoveIncompleteResidues = False):
        ''''''
        raise Exception('This code looks to be deprecated. Use construct_pdb_to_rosetta_residue_map instead.')
        chain = None
        sequences = {}
        residue_map = {}
        resid_set = set()
        resid_list = []

        DNA_residues = set([' DA', ' DC', ' DG', ' DT'])
        chains = []
        self.RAW_ATOM_SEQUENCE = []
        essential_atoms_1 = set(['CA', 'C', 'N'])#, 'O'])
        essential_atoms_2 = set(['CA', 'C', 'N'])#, 'OG'])
        current_atoms = set()
        atoms_read = {}
        oldchainID = None
        removed_residue = {}
        for line in self.lines:
            if line[0:4] == 'ATOM' or (ConvertMSEToAtom and (line[0:6] == 'HETATM') and (line[17:20] == 'MSE')):
                chainID = line[21]
                if missing_chain_ids.get(self.pdb_id):
                    chainID = missing_chain_ids[self.pdb_id]
                if chainID not in chains:
                    chains.append(chainID)
                residue_longname = line[17:20]
                if residue_longname in DNA_residues:
                    # Skip DNA
                    continue
                if residue_longname == 'UNK':
                    # Skip unknown residues
                    continue
                if residue_longname not in allowed_PDB_residues_types and not(ConvertMSEToAtom and residue_longname == 'MSE'):
                    if not self.strict:
                        # Skip unknown residues
                        continue
                    else:
                        raise NonCanonicalResidueException("Residue %s encountered: %s" % (line[17:20], line))
                else:
                    resid = line[21:27]
                    #print(chainID, residue_longname, resid)
                    #print(line)
                    #print(resid_list)
                    if resid not in resid_set:
                        removed_residue[chainID] = False
                        add_residue = True
                        if current_atoms:
                            if RemoveIncompleteResidues and essential_atoms_1.intersection(current_atoms) != essential_atoms_1 and essential_atoms_2.intersection(current_atoms) != essential_atoms_2:
                                oldChain = resid_list[-1][0]
                                oldResidueID = resid_list[-1][1:]
                                print("The last residue '%s', %s, in chain %s is missing these atoms: %s." % (resid_list[-1], residue_longname, oldChain, essential_atoms_1.difference(current_atoms) or essential_atoms_2.difference(current_atoms)))
                                resid_set.remove(resid_list[-1])
                                #print("".join(resid_list))
                                resid_list = resid_list[:-1]
                                if oldchainID:
                                    removed_residue[oldchainID] = True
                                #print("".join(resid_list))
                                #print(sequences[oldChain])
                                if sequences.get(oldChain):
                                    sequences[oldChain] = sequences[oldChain][:-1]

                                if residue_map.get(oldChain):
                                    residue_map[oldChain] = residue_map[oldChain][:-1]

                                #print(sequences[oldChain]
                        else:
                            assert(not(resid_set))
                        current_atoms = set()
                        atoms_read[chainID] = set()
                        atoms_read[chainID].add(line[12:15].strip())
                        resid_set.add(resid)
                        resid_list.append(resid)
                        chainID = line[21]

                        sequences[chainID] = sequences.get(chainID, [])
                        if residue_longname in non_canonical_amino_acids:
                            sequences[chainID].append(non_canonical_amino_acids[residue_longname])
                        else:
                            sequences[chainID].append(residue_type_3to1_map[residue_longname])

                        residue_map[chainID] = residue_map.get(chainID, [])
                        if residue_longname in non_canonical_amino_acids:
                            residue_map[chainID].append((resid, non_canonical_amino_acids[residue_longname]))
                        else:
                            residue_map[chainID].append((resid, residue_type_3to1_map[residue_longname]))

                        oldchainID = chainID
                    else:
                        #atoms_read[chainID] = atoms_read.get(chainID, set())
                        atoms_read[chainID].add(line[12:15].strip())
                    current_atoms.add(line[12:15].strip())
        if RemoveIncompleteFinalResidues:
            # These are (probably) necessary for Rosetta to keep the residue. Rosetta does throw away residues where only the N atom is present if that residue is at the end of a chain.
            for chainID, sequence_list in sequences.iteritems():
                if not(removed_residue[chainID]):
                    if essential_atoms_1.intersection(atoms_read[chainID]) != essential_atoms_1 and essential_atoms_2.intersection(atoms_read[chainID]) != essential_atoms_2:
                        print("The last residue %s of chain %s is missing these atoms: %s." % (sequence_list[-1], chainID, essential_atoms_1.difference(atoms_read[chainID]) or essential_atoms_2.difference(atoms_read[chainID])))
                        oldResidueID = sequence_list[-1][1:]
                        residue_map[chainID] = residue_map[chainID][0:-1]
                        sequences[chainID] = sequence_list[0:-1]


        for chainID, sequence_list in sequences.iteritems():
            sequences[chainID] = "".join(sequence_list)
            assert(sequences[chainID] == "".join([res_details[1] for res_details in residue_map[chainID]]))
        for chainID in chains:
            for a_acid in sequences.get(chainID, ""):
                self.RAW_ATOM_SEQUENCE.append((chainID, a_acid))

        residue_objects = {}
        for chainID in residue_map.keys():
            residue_objects[chainID] = []
        for chainID, residue_list in residue_map.iteritems():
            for res_pair in residue_list:
                resid = res_pair[0]
                resaa = res_pair[1]
                assert(resid[0] == chainID)
                residue_objects[chainID].append((resid[1:].strip(), resaa))

        return sequences, residue_objects
1021123
def name(self):
        """"""
        if self._name is None:
            return re.sub(r"(?<=\w)([A-Z])", r" \1", self.__class__.__name__)
        else:
            return self._name
1054783
def get_basic_name(linker, bb)
      prefix = bb.get_output_prefix(linker)
      name = bb.name
      dylib = bb.shared_suffix linker
      return "#{prefix}#{name}#{dylib}"
    end
193724
def get_mod_site_name(mod_condition):
    """"""
    if mod_condition.residue is None:
        mod_str = abbrevs[mod_condition.mod_type]
    else:
        mod_str = mod_condition.residue
    mod_pos = mod_condition.position if \
        mod_condition.position is not None else ''
    name = ('%s%s' % (mod_str, mod_pos))
    return name
1135318
def getopenfilename(parent=None, caption='', basedir='', filters='',
                    selectedfilter='', options=None):
    """"""
    return _qfiledialog_wrapper('getOpenFileName', parent=parent,
                                caption=caption, basedir=basedir,
                                filters=filters, selectedfilter=selectedfilter,
                                options=options)
872199
def get_atom_name(self, atom):
        """"""
        r = request.GetAtomName(display = self.display,
                                atom = atom)
        return r.name
580151
def getTablesByName(elem, name):
	
	name = StripTableName(name)
	return elem.getElements(lambda e: (e.tagName == ligolw.Table.tagName) and (e.Name == name))
396633
def namebase(self):
        
        base, ext = self.module.splitext(self.name)
        return base
129751
private String identifyAtomicSymbol(int atomicNumber) {
        String symbol;
        switch (atomicNumber) {
            case 1:
                symbol = "H";
                break;
            case 2:
                symbol = "He";
                break;
            case 3:
                symbol = "Li";
                break;
            case 4:
                symbol = "Be";
                break;
            case 5:
                symbol = "B";
                break;
            case 6:
                symbol = "C";
                break;
            case 7:
                symbol = "N";
                break;
            case 8:
                symbol = "O";
                break;
            case 9:
                symbol = "F";
                break;
            case 10:
                symbol = "Ne";
                break;
            case 11:
                symbol = "Na";
                break;
            case 12:
                symbol = "Mg";
                break;
            case 13:
                symbol = "Al";
                break;
            case 14:
                symbol = "Si";
                break;
            case 15:
                symbol = "P";
                break;
            case 16:
                symbol = "S";
                break;
            case 17:
                symbol = "Cl";
                break;
            case 18:
                symbol = "Ar";
                break;
            default:
                symbol = null;
                break;
        }
        return symbol;
    }
191445
def get_class_with_attr_name(pyname):
    
    lineno = get_lineno_for_node(pyname.assignments[0].ast_node)
    holding_scope = pyname.module.get_scope().get_inner_scope_for_line(lineno)
    pyobject = holding_scope.pyobject
    if isinstance(pyobject, PyClass):
        pyclass = pyobject
    elif (isinstance(pyobject, PyFunction) and
          isinstance(pyobject.parent, PyClass)):
        pyclass = pyobject.parent
    else:
        return
    for name, attr in pyclass.get_attributes().items():
        if attr is pyname:
            return (pyclass, name)
844513
def name(self):
        
        if hasattr(self._element, "name"):
            return self._element.name
        else:
            return str(self._element)
113104
def name(self):
        
        if self.m_name == -1 or (self.m_event != START_TAG and self.m_event != END_TAG):
            return ''

        return self.sb[self.m_name]