当前位置: 首页>>代码示例>>Python>>正文


Python Read.name方法代码示例

本文整理汇总了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
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:93,代码来源:InteractionDetector.py


注:本文中的MolKit.Read.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。