當前位置: 首頁>>代碼示例>>Python>>正文


Python Utility.isDefinedPosition方法代碼示例

本文整理匯總了Python中MMTK.Utility.isDefinedPosition方法的典型用法代碼示例。如果您正苦於以下問題:Python Utility.isDefinedPosition方法的具體用法?Python Utility.isDefinedPosition怎麽用?Python Utility.isDefinedPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MMTK.Utility的用法示例。


在下文中一共展示了Utility.isDefinedPosition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: write

# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import isDefinedPosition [as 別名]
    def write(self, object, configuration = None, tag = None):
        """
        Write  an object to the file

        :param object: the object to be written
        :type object: :class:`~MMTK.Collections.GroupOfAtoms`
        :param configuration: the configuration from which the coordinates 
                              are taken (default: current configuration)
        :type configuration: :class:`~MMTK.ParticleProperties.Configuration`
        """
        if not ChemicalObjects.isChemicalObject(object):
            for o in object:
                self.write(o, configuration)
        else:
            toplevel = tag is None
            if toplevel:
                tag = Utility.uniqueAttribute()
            if hasattr(object, 'pdbmap'):
                for residue in object.pdbmap:
                    self.file.nextResidue(residue[0], )
                    sorted_atoms = residue[1].items()
                    sorted_atoms.sort(lambda x, y:
                                      cmp(x[1].number, y[1].number))
                    for atom_name, atom in sorted_atoms:
                        atom = object.getAtom(atom)
                        p = atom.position(configuration)
                        if Utility.isDefinedPosition(p):
                            try: occ = atom.occupancy
                            except AttributeError: occ = 0.
                            try: temp = atom.temperature_factor
                            except AttributeError: temp = 0.
                            self.file.writeAtom(atom_name, p/Units.Ang,
                                                occ, temp, atom.type.symbol)
                            self.atom_sequence.append(atom)
                        else:
                            self.warning = True
                        setattr(atom, tag, None)
            else:
                if hasattr(object, 'is_protein'):
                    for chain in object:                    
                        self.write(chain, configuration, tag)
                elif hasattr(object, 'is_chain'):
                        self.file.nextChain(None, object.name)
                        for residue in object:
                            self.write(residue, configuration, tag)
                        self.file.terminateChain()
                elif hasattr(object, 'molecules'):
                    for m in object.molecules:
                        self.write(m, configuration, tag)
                elif hasattr(object, 'groups'):
                    for g in object.groups:
                        self.write(g, configuration, tag)
            if toplevel:
                for a in object.atomList():
                    if not hasattr(a, tag):
                        self.write(a, configuration, tag)
                    delattr(a, tag)
開發者ID:acousticpants,項目名稱:mmtk,代碼行數:59,代碼來源:PDB.py

示例2: atomsWithDefinedPositions

# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import isDefinedPosition [as 別名]
 def atomsWithDefinedPositions(self, conf = None):
     """
     :param conf: a configuration object, or None for the
                  current configuration
     :type conf: :class:`~MMTK.ParticleProperties.Configuration` or NoneType
     :returns: a collection of all atoms that have a position in the
               given configuration
     """
     return Collection([a for a in self.atomIterator()
                        if Utility.isDefinedPosition(a.position(conf))])
開發者ID:acousticpants,項目名稱:mmtk,代碼行數:12,代碼來源:Collections.py


注:本文中的MMTK.Utility.isDefinedPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。