def getPairsFromAlignment(self): """ This is where we want to figure out the selection """ refCount=0 mobCount=0 refResidues = self.vf.expandNodes(self.refMolName)[0].children.children mobResidues = self.vf.expandNodes(self.mobMolName)[0].children.children refNodes = ResidueSet() mobNodes = ResidueSet() #get the item no's for each sequence refItems = self.vf.alnEditor.canvas.find_withtag(self.refMolName) mobItems = self.vf.alnEditor.canvas.find_withtag(self.mobMolName) for x in range(len(refItems)): ref = self.vf.alnEditor.canvas.itemcget(refItems[x],'text') mob = self.vf.alnEditor.canvas.itemcget(mobItems[x],'text') if ref.isalpha(): refRes = refResidues[refCount] refCount=refCount+1 if mob.isalpha(): mobRes = mobResidues[mobCount] mobCount=mobCount+1 refTags = self.vf.alnEditor.canvas.gettags(refItems[x]) mobTags = self.vf.alnEditor.canvas.gettags(mobItems[x]) if 'selected' in mobTags and 'selected' in refTags: if ref.isalpha() and mob.isalpha(): refNodes.append(refRes) mobNodes.append(mobRes) print len(refNodes),len(mobNodes),refNodes[0],mobNodes[0] #return refNodes,mobNodes apply(self.vf.superimposeAtomsGC.doitWrapper, (refNodes,), {'log':0}) apply(self.vf.superimposeAtomsGC.doitWrapper, (mobNodes,), {'log':0}) self.vf.superimposeAtomsGC.typeVar.set('By Picking')
def test_findType(): from MolKit import Read mol = Read("./Data/1crn.pdb")[0] from MolKit.protein import Residue, Chain, Protein, ResidueSet from MolKit.molecule import Atom, AtomSet # FindType below from top of the tree res = mol.findType(Residue) res.sort() molres = mol.chains.residues molres.sort() assert res == molres # FindType above from bottom of the tree atms = mol.allAtoms chains = atms.findType(Chain) # Automatically does a uniq when going above assert len(chains) == 327 # FindType above uniq from bottom of the tree chainsuniq = atms.findType(Chain, uniq=1) assert len(chainsuniq) == 1 # FindType above from middle of the tree prot = res.findType(Protein, uniq=1) assert len(prot) == 1 and prot == mol.setClass([mol]) # FindType below from middle of the tree atoms = chainsuniq.findType(Atom) assert len(atoms) == 327 # FindType on empty set emptyres = ResidueSet([]) atoms = emptyres.findType(Atom) assert len(atoms) == 0 and isinstance(atoms, AtomSet) # FindType on same type atoms = atms.findType(Atom) assert atoms == atms # Raise exception from MolKit.protein import Helix try: nodes = atms.findType(Helix) except RuntimeError: print "passed"
def createGeometries(self, obj): from DejaVu.Geom import Geom geomC = obj.geomContainer c = Geom('path', shape=(0, 0), protected=True) c.replace = 'force' geomC.addGeom(c, parent=geomC.masterGeom) for a in obj.allAtoms: a.colors['path'] = (1., 1., 1.) a.opacities['path'] = 1.0 for chain in obj.chains: if not hasattr(chain, 'sheet2D') or chain.sheet2D is None: continue # HACK TO DEBUG SECONDARYSTRUCTURE if not chain.sheet2D.has_key('ssSheet2D') or \ chain.sheet2D['ssSheet2D'] is None: continue # Create a geometry per sheet2D name = 'path' + chain.id g = Spheres(name, quality=10, radii=0.15, protected=True) g.replace = 'force' geomC.addGeom(g, parent=c) self.managedGeometries.append(g) # FIXME to update this geom we would have to implement # self.updateGeom specifically for this command geomC.atoms[name] = ResidueSet() g.chain = chain geomC.atomPropToVertices[name] = self.atomPropToVertices geomC.geomPickToAtoms[name] = self.pickedVerticesToAtoms geomC.geomPickToBonds[name] = None
def doit(self, Klass, KlassSet=None): if type(Klass) == types.StringType: if Klass in self.levelDict.keys(): Klass = self.levelDict[Klass] else: msg = Klass + "string does not map to a valid level" self.warningMsg(msg) return "ERROR" if Klass is Protein: Klass = Molecule if len(self.vf.selection): self.vf.selection = self.vf.selection.findType(Klass).uniq() else: if Klass == Molecule: self.vf.selection = MoleculeSet([]) elif Klass == Chain: self.vf.selection = ChainSet([]) elif Klass == Residue: self.vf.selection = ResidueSet([]) elif Klass == Atom: self.vf.selection = AtomSet([]) self.vf.selectionLevel = Klass self.vf.ICmdCaller.setLevel(Klass, KlassSet=None) if self.vf.hasGui: col = self.vf.ICmdCaller.levelColors[Klass.__name__] c = (col[0] / 1.5, col[1] / 1.5, col[2] / 1.5) self.vf.GUI.pickLabel.configure(background=TkColor(c)) msg = '%d %s(s)' % (len( self.vf.selection), self.vf.selectionLevel.__name__) self.vf.GUI.pickLabel.configure(text=msg) if hasattr(self.vf, 'select'): self.vf.select.updateSelectionIcons() self.levelVar.set(self.vf.selectionLevel.__name__)
def getObjects(self, column): # return a list of objects associated with this node and possibly # other seleted nodes. For selection we return a list for each type # ( i.e. Atom, Residue, etc..) # if the node is selected, collect object from all other selected nodes resultAtoms = AtomSet([]) resultResidues = ResidueSet([]) resultChains = ChainSet([]) resultMolecules = MoleculeSet([]) buttonValue = self.chkbtVar[column].get() if self.selected: for node in self.tree.list_selected: node.chkbtVar[column].set(buttonValue) result = node.getNodes(column) obj = result[0] if isinstance(obj, Atom): resultAtoms += result elif isinstance(obj, Residue): resultResidues += result elif isinstance(obj, Chain): resultChains += result elif isinstance(obj, Molecule) or isinstance(obj, Protein): resultMolecules += result result = [] if len(resultAtoms): result.append(resultAtoms) if len(resultResidues): result.append(resultResidues) if len(resultChains): result.append(resultChains) if len(resultMolecules): result.append(resultMolecules) return result else: return [self.getNodes(column)]
def test_findType(): from MolKit import Read mol = Read("./Data/1crn.pdb")[0] from MolKit.protein import Residue, Chain, Protein, ResidueSet from MolKit.molecule import Atom, AtomSet # FindType below from top of the tree res = mol.findType(Residue) res.sort() molres = mol.chains.residues molres.sort() assert res == molres # FindType above from bottom of the tree atms = mol.allAtoms chains = atms.findType(Chain) # Automatically does a uniq when going above assert len(chains) == 327 # FindType above uniq from bottom of the tree chainsuniq = atms.findType(Chain, uniq=1) assert len(chainsuniq) == 1 # FindType above from middle of the tree prot = res.findType(Protein, uniq=1) assert len(prot) == 1 and prot == mol.setClass([ mol, ]) # FindType below from middle of the tree atoms = chainsuniq.findType(Atom) assert len(atoms) == 327 # FindType on empty set emptyres = ResidueSet([]) atoms = emptyres.findType(Atom) assert len(atoms) == 0 and isinstance(atoms, AtomSet) # FindType on same type atoms = atms.findType(Atom) assert atoms == atms # Raise exception from MolKit.protein import Helix try: nodes = atms.findType(Helix) except RuntimeError: print "passed"
def getAsn(self, chain): asn = [] chain.residuesInSS = ResidueSet() from stride.stride import RESIDUE chain.residuesInSS.elementType = RESIDUE for j in range(chain.NRes): res = chain.getResidue(j) chain.residuesInSS.append(res) asn.append((res.ResType + res.PDB_ResNumb, res.Prop.Asn)) return asn
def test_select_intersect_residues_empty(self): """ test selecting with stringRepr of empty intersected residues """ stringSel = CompoundStringSelector() diff_residues = self.mols1.chains.residues & self.mols2.chains.residues selString = diff_residues.stringRepr selected, msg = stringSel.select(self.mols, selString, returnMsg=True) self.assertEquals(selected, diff_residues) self.assertEquals(selected, ResidueSet()) self.assertEquals(selString, "stringSel::/&/protease::")
def handleEditGeom(self, event): #print 'handle edit geoms', event.arg if event.arg == 'lines': nodes = event.objects[0] for mol in self.vf.Mols: #nodes.top.uniq(): #ats = mol.geomContainer.atoms['bonded'] self.setColPercent(event.setOn, event.setOff, '_showLinesStatus') elif event.arg == 'cpk': nodes = event.objects[0] for mol in self.vf.Mols: #nodes.top.uniq(): #ats = mol.geomContainer.atoms['cpk'] self.setColPercent(event.setOn, event.setOff, '_showCPKStatus') elif event.arg == 'bs': nodes = event.objects[0] for mol in self.vf.Mols: #nodes.top.uniq(): #ats = mol.geomContainer.atoms['sticks'] self.setColPercent(event.setOn, event.setOff, '_showS&BStatus') #ats = mol.geomContainer.atoms['balls'] self.setColPercent(event.setOn, event.setOff, '_showS&BStatus') elif event.arg == 'msms_ds': nodes = event.objects[0] surfName = event.objects[1][0][0] #if surfName=='MSMS-MOL': for mol in self.vf.Mols: #nodes.top.uniq(): if mol.geomContainer.atoms.has_key(surfName): #ats = mol.geomContainer.atoms[surfName] self.setColPercent(event.setOn, event.setOff, '_showMSMSStatus_%s' % surfName) elif event.arg == 'SSdisplay': nodes = event.objects[0] for mol in self.vf.Mols: #nodes.top.uniq(): geoms = mol.geomContainer.atoms res = ResidueSet([]) for k, v in geoms.items(): if k[:4] in ['Turn', 'Coil', 'Heli', 'Stra']: res += v self.setColPercent(event.setOn, event.setOff, '_showRibbonStatus') ## elif event.arg=='trace': ## nodes = event.objects[0] ## for mol in nodes.top.uniq(): ## ats = mol.geomContainer.atoms['CAsticks'] ## self.setColPercent(ats, '_showCAtraceStatus') ## ats = mol.geomContainer.atoms['CAballs'] ## self.setColPercent(ats, '_showCAtraceStatus') self.tree.redraw()
def getResidueRelIndex(self, item, nodes): try: number = int(item) except: msgStr = str(item) + " is invalid relative index" # self.vf.warningMsg(msgStr) return None # indices start w/ 1: parentNodes = nodes[0].parent.setClass(nodes.parent.uniq()) l = [] for par in parentNodes: if len(par.children) >= number: l.append(par.children[number - 1]) return ResidueSet(l)
def getAtomRelRange(self,item,nodes): levItList=string.split(item, '-') #now the hard part: need to call pLI w/ each set of parent nodes selNodes = None parentNodes = ResidueSet(nodes.parent.uniq()) for par in parentNodes: nds = AtomSet(filter(lambda x, par=par: x.parent==par, nodes)) firstNodes = self.processListItem(nds, levItList[0], self.atomFD) lastNodes = self.processListItem(nds, levItList[-1], self.atomFD) if firstNodes and lastNodes: newNodes= self.rangeMatch(nds,firstNodes[0],lastNodes[-1]) if newNodes: if selNodes: selNodes=selNodes + newNodes else: selNodes = newNodes return selNodes
def getResidueRange(self, item, nodes): #this needs to be done on a PER CHAIN basis: if len(nodes) <2: return None levItList=string.split(item, '-') selNodes = None parentNodes = nodes[0].parent.setClass(nodes.parent.uniq()) for par in parentNodes: nds = ResidueSet(filter(lambda x, par=par: x.parent==par, nodes)) if len(nds)<2: continue firstNodes = self.processListItem(nds, levItList[0], self.resFD) lastNodes = self.processListItem(nds, levItList[1], self.resFD) if firstNodes and lastNodes: newNodes = self.rangeMatch(nds,firstNodes[0],lastNodes[-1]) if newNodes: if selNodes: selNodes = selNodes + newNodes else: selNodes = newNodes else: continue return selNodes
def getSheet2DRes(self, chain, ctlAtmName, torsAtmName, buildIsHelix=False): isHelix = [] sheetCoords = [] from MolKit.protein import ResidueSet sheet2DRes = ResidueSet() residues = chain.residues sheet2DResappend = sheet2DRes.append isHelixappend = isHelix.append for res in residues: hasAtm, rCoords = res.getAtmsAndCoords([ctlAtmName, torsAtmName]) if hasAtm == 0: ## MS June 2012: the code below cause 2X2K.pdb and 2IVU.pdb ## to only show a short helical part. Instead of stopping ## we continue continue ## if len(sheet2DRes)== 0 or res.atoms[0].hetatm: ## # if the residue without CA and O is at the beginning ## # go on until you find the right residue ## # or res.atoms[0].hetatm added ti fix bug#779 ## continue ## else: ## # Stop the sheet2D right there ## return sheet2DRes, sheetCoords, isHelix ## end MS June 2012: else: sheet2DResappend(res) sheetCoords = sheetCoords + rCoords if buildIsHelix and hasattr(res, 'secondarystructure'): sr = res.secondarystructure.structureType isHelixappend(sr == 'Helix') else: isHelixappend(0) return sheet2DRes, sheetCoords, isHelix
def getNamedResSet(self, item, nodes): # here get all residues w/ name in residueList_[item] rlist = residueList_[item] ans = list( filter(lambda x, rlist=rlist, nodes=nodes: x.type in rlist, nodes)) return ResidueSet(ans)
print('prepare_flexreceptor4: residues to move must be specified!\n') usage() sys.exit() extension = os.path.splitext(receptor_filename)[1] if extension != ".pdbqt": print( 'prepare_flexreceptor4: receptor file must be in .pdbqt format\n') usage() sys.exit() rec = Read(receptor_filename)[0] bnds = rec.buildBondsByDistance() if verbose: print('read ', receptor_filename) all_res = ResidueSet() # hsg1:A:ARG8_ILE82;hsg1:B:THR4 # ARG8_ILE84 names_by_chain = residues_to_move.split(',') if verbose: print("Specified flexres selection strings are:") for strN in names_by_chain: print(" %s" % strN) #1. ['hsg1:A:ARG8_ILE82','hsg1:B:THR4'] # OR #2. ARG8_ILE84 for res_names_by_chain in names_by_chain: #check for ':' if verbose: print("selecting ", res_names_by_chain) if res_names_by_chain.find(':') == -1: # no ':' in selection string = simple case eg: ARG8_ILE84
def getResidueIndex(self, item, nodes): # residue indices are strings item = str(item) ans = list(filter(lambda x, item=item: x.number == item, nodes)) return ResidueSet(ans)
def getSSResidues(self, chain): res = [x for x in chain.children if hasattr(x, 'secondarystructure')] return ResidueSet(res)
def go(self): msgStr = None if self.moleculeSet: self.molSet = self.getMolecules(self.moleculeSet, self.selList[0]) else: self.molSet = None return [] # return [], msgStr # SPLIT here if mol.children==Atoms # possibly: self.Mols4levels=filter(lambda x: x.childrenSetClass == ChainSet, self.molSet) # then process the others separately....????????? # eg self.Mols2levels=filter(lambda x: x.childrenSetClass == AtomSet, self.molSet) # self.Mols2levels would get fed to self.getAtoms and two results ???merged??? if not self.molSet: self.chainSet = None msgStr = str(self.selList[0]) + " selected no molecules" return [] # return [], msgStr noChainMols = MoleculeSet( [x for x in self.molSet if Chain not in x.levels]) haveChainMols = MoleculeSet( [x for x in self.molSet if Chain in x.levels]) # build the residues belonging to molecules w/ no Chains (!WEIRD!) ncrs = ResidueSet() for item in noChainMols: if Residue in item.levels: itemRes = item.allAtoms.parent.uniq() ncrs = ncrs + itemRes if ncrs: noChainResSet = self.getResidues(ncrs, self.selList[2]) if not noChainResSet: noChainResSet = ResidueSet() else: noChainResSet = ResidueSet() if len(haveChainMols): self.chainSet = self.getChains(haveChainMols.findType(Chain), self.selList[1]) if self.chainSet: haveChainResSet = self.getResidues(self.chainSet.findType(Residue), self.selList[2]) # also test noChainMols for residues if haveChainResSet: self.resSet = haveChainResSet + noChainResSet else: self.resSet = noChainResSet else: self.resSet = noChainResSet ##don't return unless selList[2]!==[''] if self.selList[1] != ['']: msgStr = str(self.selList[1]) + " selected no chains" return [] # return [], msgStr # now: if self.selList for Chain and Residue level was empty, get the Atoms from noChains if self.selList[1] == [''] and self.selList[2] == ['']: tla = AtomSet() for item in noChainMols: if Residue not in item.levels: tla = tla + item.allAtoms twoLevelAtoms = tla else: twoLevelAtoms = AtomSet() if self.resSet: resAts = self.resSet.findType(Atom) if twoLevelAtoms: resAts = resAts + twoLevelAtoms self.atomSet = self.getAtoms(resAts, self.selList[3]) else: if self.selList[2] != ['']: msgStr = str(self.selList[2]) + " selected no residues" return [] # return [], msgStr else: self.atomSet = self.getAtoms(twoLevelAtoms, self.selList[3]) selNodes = self.atomSet # find correct levelType to return # need to split atomSet into two parts: if self.atomSet: haveChainAtoms = AtomSet( [x for x in self.atomSet if x.top != x.parent]) haveNoChainAtoms = self.atomSet - haveChainAtoms if self.selList[3] == ['']: # change atoms to residues if haveChainAtoms: selNodes = haveChainAtoms.parent.uniq() else: selNodes = ResidueSet() if self.selList[2] == ['']: # change residues to chains if len(selNodes): selNodes = selNodes.parent.uniq() if self.selList[1] == ['']: # change chains to molecules if haveNoChainAtoms: noChainTops = haveNoChainAtoms.top.uniq() else: noChainTops = ProteinSet() if selNodes: selTops = selNodes.top.uniq() else: selTops = ProteinSet() selNodes = selTops + noChainTops if self.selList[0] == ['']: # change molecules to molecules(?)in the case of no strs if selNodes.__class__ != MoleculeSet: selNodes = MoleculeSet(selNodes.top.uniq()) else: msgStr = str(self.selList[3]) + " selected no atoms" for item in ['moleculeSet', 'molSet', 'chainSet', 'resSet', 'atomSet']: if hasattr(self, item): delattr(self, item) # exec('del self.'+item) return selNodes
def select(self, nodes, selectionString, sets=None, caseSensitive=True, escapeCharacters=False): # print "in select with selectionString=", selectionString overallresults = None overallmsg = "" overall_class = None # eg: stringSel:A:PRO1:N;stringSel:B:PRO1:CA; if len(selectionString) and selectionString[-1] == ';': selectionString = selectionString[:-1] # eg: stringSel:A:PRO1:N;stringSel:B:PRO1:CA ## mol1;mol2;mol3::: allSelectionStrings = selectionString.split(';') # print "allSelectionStrings=", allSelectionStrings all_tops = nodes.top.uniq() final_str_repr = "" # keep track of string to assign at end for selString in allSelectionStrings: # print "processing selString=", selString lambda_index = selString.find('lambda ') if lambda_index == -1: setsStrings = selString.split(':') else: # split repair possible splits of lambda expressions # ":::lambda x:x.top.name=='ind'" # lambda_index = 3 setsStrings = selString[:lambda_index].split(':') # setsStrings = ['','','',''] # replace the last one with join of split on lambda ':' lambda_exp_list = selString[lambda_index:].split(':') lambda_exp = lambda_exp_list[0] + ':' + lambda_exp_list[1] setsStrings[-1] = lambda_exp if len(lambda_exp_list) > 2: # there may be trailing stuff setsStrings.extend(lambda_exp_list[2:]) # setsStrings = selString.split(':') # print "setsStrings=", setsStrings len_setsStrings = len(setsStrings) results = all_tops msg = '' for i in range(len_setsStrings): # print "setsStrings[",i,"]=", setsStrings[i] if i == 0 and len_setsStrings == 1 and setsStrings[i] == '': # special case of empty selection string final_str_repr = '' for m in all_tops: final_str_repr += m.name + ',' final_str_repr = final_str_repr[:-1] elif setsStrings[i] != '': # print "in elif loop" these_sets = None if sets is not None: these_sets = sets.get(stype=results.__class__) results, msgList = results.get( setsStrings[i], sets=these_sets, caseSensitive=caseSensitive, escapeCharacters=escapeCharacters, returnMsg=True) # print "results=", results, "msgList=", msgList for m in msgList: setsStrings[i].replace(m, '') msg = msg + str(m) if len(results) == 0: # print "no results with ", setsStrings[i] overallresults = None break # check whether the rest of the setsStrings are empty, if so final_str_repr += setsStrings[i] + ':' results.stringRepr = final_str_repr if i < len(setsStrings) - 1: results = results.children final_str_repr = final_str_repr[:-1] results.stringRepr = final_str_repr if len(results): if overallresults is None: overallresults = results overall_class = results.__class__ overallmsg = msg else: # levels are the same if overall_class == results.__class__: overallresults = overallresults + results # does this happen automatically? overallmsg = overallmsg + msg else: print("ERROR") print("overall_class->", overall_class) print("results.__class__->", results.__class__) print("results=", results) raise RuntimeError if selString != allSelectionStrings[-1]: final_str_repr += ';' final_str_repr.replace("/+/", ';') else: overallresults.stringRepr = final_str_repr if overallresults is None: overallmsg = selectionString if len(setsStrings) == 1: overallresults = ProteinSet() elif len(setsStrings) == 2: overallresults = ChainSet() elif len(setsStrings) == 3: overallresults = ResidueSet() else: overallresults = AtomSet() return overallresults, overallmsg
if not residues_to_move: print 'prepare_flexreceptor4: residues to move must be specified!\n' usage() sys.exit() extension = os.path.splitext(receptor_filename)[1] if extension!=".pdbqt": print 'prepare_flexreceptor4: receptor file must be in .pdbqt format\n' usage() sys.exit() r = Read(receptor_filename)[0] r.buildBondsByDistance() if verbose: print 'read ', receptor_filename all_res = ResidueSet() # hsg1:A:ARG8_ILE82;hsg1:B:THR4 # ARG8_ILE84 names_by_chain = residues_to_move.split(',') if verbose: print "Specified flexres selection strings are:" for strN in names_by_chain: print " %s" %strN #1. ['hsg1:A:ARG8_ILE82','hsg1:B:THR4'] # OR #2. ARG8_ILE84 for res_names_by_chain in names_by_chain: #check for ':' if verbose: print "selecting ", res_names_by_chain if res_names_by_chain.find(':')==-1: # no ':' in selection string = simple case eg: ARG8_ILE84
usage() sys.exit() if not residues_to_move: print 'prepare_flexdocking4: residues to move must be specified!\n' usage() sys.exit() l = Read(ligand_filename)[0] l.buildBondsByDistance() if verbose: print 'read ', ligand_filename r = Read(receptor_filename)[0] r.buildBondsByDistance() if verbose: print 'read ', receptor_filename all_res = ResidueSet() res_names = residues_to_move.split('_') for n in res_names: if n.find(':') == -1: res = r.chains.residues.get(lambda x: x.name == n) all_res += res if verbose: print "get: adding ", res.name, " to ", all_res else: res, msg = CompoundStringSelector().select(ProteinSet([r]), n) all_res += res if verbose: print "css: adding ", res.name, " to ", all_res if verbose: print "all_res=", all_res.full_name( ), 'all_res.__class__=', all_res.__class__ #?check for duplicates d = {}
def build3LevelsTree(self, atomlines): """ Function to build a 3 levels hierarchy Molecule-substructure-atoms.""" self.mol = Protein() self.mol.allAtoms = AtomSet() self.mol.atmNum = {} self.mol.parser = self if self.mol.name == 'NoName': self.mol.name = os.path.basename( os.path.splitext(self.filename)[0]) self.mol.children = ResidueSet([]) self.mol.childrenName = 'residues' self.mol.childrenSetClass = ResidueSet self.mol.elementType = Residue self.mol.curRes = Residue() self.mol.curRes.hasCA = 0 self.mol.curRes.hasO = 0 self.mol.levels = [Protein, Residue, Atom] for atmline in atomlines: if len(atmline) >= 10: status = string.split(atmline[9], '|') else: status = None resName = atmline[7][:3] resSeq = atmline[7][3:] if resSeq != self.mol.curRes.number or \ resName != self.mol.curRes.type: # check if this residue already exists na = string.strip(resName) + string.strip(resSeq) res = self.mol.get(na) if res: self.mol.curRes = res[0] else: self.mol.curRes = Residue(resName, resSeq, '', self.mol, top=self.mol) name = atmline[1] if name == 'CA': self.mol.curRes.hasCA = 1 if name == 'O': self.mol.curRes.hasO = 2 atom = Atom(name, self.mol.curRes, top=self.mol, chemicalElement=string.split(atmline[5], '.')[0]) #atom.element = atmline[5][0] atom.element = atom.chemElem atom.number = int(atmline[0]) self.mol.atmNum[atom.number] = atom atom._coords = [[ float(atmline[2]), float(atmline[3]), float(atmline[4]) ]] atom._charges['mol2'] = float(atmline[8]) atom.chargeSet = mol2 # atom.conformation = 0 atom.hetatm = 0 #Add a data member containing a list of string describing # the Sybyl status bis of the atoms. atom.status = status #add altname so buildBondsByDist doesn't croak atom.altname = None self.mol.allAtoms.append(atom) self.mol.residues = self.mol.children assert hasattr(self.mol, 'chains') delattr(self.mol, 'chains') delattr(self.mol, 'curRes')
if not receptor_filename: print 'prepare_flexreceptor4: receptor filename must be specified!\n' usage() sys.exit() if not residues_to_move: print 'prepare_flexreceptor4: residues to move must be specified!\n' usage() sys.exit() r = Read(receptor_filename)[0] r.buildBondsByDistance() if verbose: print 'read ', receptor_filename all_res = ResidueSet() res_names = residues_to_move.split('_') for n in res_names: res = r.chains.residues.get(lambda x: x.name==n) if verbose: print "adding ", res.name, " to ", all_res all_res += res if verbose: print "all_res=", all_res.full_name(), 'all_res.__class__=', all_res.__class__ #?check for duplicates d = {} for res in all_res: d[res] = 1 all_res = d.keys() all_res = ResidueSet(all_res) #inactivate specified bonds #disallowed_Pairs "CA_CB:CB_CG:C_CA"
if not residues_to_move: print 'prepare_flexreceptor4: residues to move must be specified!\n' usage() sys.exit() extension = os.path.splitext(receptor_filename)[1] if extension!=".pdbqt": print 'prepare_flexreceptor4: receptor file must be in .pdbqt format\n' usage() sys.exit() r = Read(receptor_filename)[0] r.buildBondsByDistance() if verbose: print 'read ', receptor_filename all_res = ResidueSet() # hsg1:A:ARG8_ILE82;hsg1:B:THR4 # ARG8_ILE84 names_by_chain = residues_to_move.split(',') if verbose: print "names_by_chain=", names_by_chain #1. ['hsg1:A:ARG8_ILE82','hsg1:B:THR4'] # OR #2. ARG8_ILE84 for res_names_by_chain in names_by_chain: #check for ':' if verbose: print "processing res_names_by_chain=", res_names_by_chain if res_names_by_chain.find(':')==-1: # no ':' so treat simple case # ARG8_ILE84 res_names.split('_') for n in res_names: