本文整理汇总了Python中MolKit.Read.name方法的典型用法代码示例。如果您正苦于以下问题:Python Read.name方法的具体用法?Python Read.name怎么用?Python Read.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MolKit.Read
的用法示例。
在下文中一共展示了Read.name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: processLigand
# 需要导入模块: from MolKit import Read [as 别名]
# 或者: from MolKit.Read import name [as 别名]
def processLigand(self, ligand_file, percentCutoff=None, output=1, outputfilename=None, comment="USER AD> ", buildHB=1, remove_modelStr=False):
#if outputfilename is not None, have to (1) update all the strings or (2) rename ligand
self.results = d = {}
ligand = Read(ligand_file)
assert isinstance(ligand, MoleculeSet)
assert(len(ligand)==1)
ligand = ligand[0]
first = ligand.name.find('_model')
last = ligand.name.rfind('_model')
if first!=last:
ligand.name = ligand.name[:last]
if remove_modelStr:
curName = ligand.name
modelIndex=curName.find("_model")
if modelIndex>-1:
curName = curName[:modelIndex]
#setup outputfilestem
ligand.name = curName
ligand.buildBondsByDistance()
if not percentCutoff:
percentCutoff = self.percentCutoff
# first detect sets of atoms forming hydrogen bonds
# hbondStr,hblist and has_hbonds added to process vina results which do not include valid hydrogen bonds
hbondStr = ""
hblist = [""]
has_hbonds = False
if buildHB:
has_hbonds = True
hbondStr = self.buildHydrogenBonds(ligand, comment=comment) #
if self.verbose: print "hbondStr=", hbondStr
hblist = hbondStr.split('\n') # hbond info
if hblist[0]=='lig_hb_atoms : 0':
has_hbonds = False
# next detect sets of atoms in close contact not forming hydrogen bonds
macrocloseContactStr, ligcloseContactStr = self.buildCloseContactAtoms(percentCutoff, ligand, comment=comment) #
self.piResults = ""
if self.detect_pi:
self.detectPiInteractions()
if self.results['pi_cation']:
self.piResults = self.get_pi_cation_result(print_ctr=1, comment=comment)
if self.verbose:
print "found pi_cation in ", ligand_file
print "set self.piResults to ", self.piResults
if self.results['pi_pi']:
self.piResults += self.get_pi_pi(print_ctr=1, comment=comment)
if self.verbose:
print "set self.piResults to ", self.piResults
macro_cclist = macrocloseContactStr.split(';')
lig_cclist = ligcloseContactStr.split(';')
if has_hbonds or len(macro_cclist):
fptr = open(ligand_file)
lines = fptr.readlines()
fptr.close()
if outputfilename is not None:
optr = open(outputfilename, 'w')
else:
optr = open(ligand_file, 'w')
for new_l in hblist:
if not(len(new_l)): #don't output empty lines
continue
if new_l.find(comment)!=0:
new_l = comment + new_l
if new_l != hblist[-1]:
optr.write(new_l+"\n")
else:
optr.write(new_l) # no newline after the last one
for new_l in macro_cclist:
if not(len(new_l)): #don't output empty lines
continue
if new_l.find(comment)!=0:
new_l = comment + new_l
if new_l != macro_cclist[-1]:
optr.write(new_l + "\n")
else:
optr.write(new_l)
for new_l in lig_cclist:
if not(len(new_l)): #don't output empty lines
continue
if new_l.find(comment)!=0:
new_l = comment + new_l
if new_l != lig_cclist[-1]:
optr.write(new_l + "\n")
else:
optr.write(new_l)
if len(self.piResults): ##???
for s in self.piResults.split("\n"):
optr.write(s+"\n")
for l in lines:
optr.write(l)
optr.close()
return hbondStr + macrocloseContactStr + ligcloseContactStr