本文整理匯總了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)
示例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))])