本文整理汇总了Python中MMTK.Utility.warning方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.warning方法的具体用法?Python Utility.warning怎么用?Python Utility.warning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MMTK.Utility
的用法示例。
在下文中一共展示了Utility.warning方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: databasePath
# 需要导入模块: from MMTK import Utility [as 别名]
# 或者: from MMTK.Utility import warning [as 别名]
def databasePath(filename, directory, try_direct = False):
if Utility.isURL(filename):
return filename
filename = os.path.expanduser(filename)
if try_direct and os.path.exists(filename):
return os.path.normcase(filename)
entries = []
if os.path.split(filename)[0] == '':
for p in path:
if Utility.isURL(p):
url = Utility.joinURL(p, directory+'/'+filename)
if Utility.checkURL(url):
entries.append(url)
else:
full_name = os.path.join(os.path.join(p, directory), filename)
if os.path.exists(full_name):
entries.append(os.path.normcase(full_name))
if len(entries) == 0:
raise IOError("Database entry %s/%s not found" % (directory, filename))
else:
if len(entries) > 1:
Utility.warning("multiple database entries for %s/%s, using first one"
% (directory, filename))
for e in entries:
sys.stderr.write(e+'\n')
return entries[0]
示例2: __init__
# 需要导入模块: from MMTK import Utility [as 别名]
# 或者: from MMTK.Utility import warning [as 别名]
def __init__(self, atoms, constraints):
self.atoms = atoms
natoms = len(self.atoms)
nconst = sum([len(c) for c in constraints])
b = N.zeros((nconst, natoms), N.Float)
c = N.zeros((nconst,), N.Float)
i = 0
for cons in constraints:
cons.setCoefficients(self.atoms, b, c, i)
i = i + len(cons)
u, s, vt = LA.singular_value_decomposition(b)
self.rank = 0
for i in range(min(natoms, nconst)):
if s[i] > 0.:
self.rank = self.rank + 1
self.b = b
self.bi = LA.generalized_inverse(b)
self.p = N.identity(natoms)-N.dot(self.bi, self.b)
self.c = c
self.bi_c = N.dot(self.bi, c)
c_test = N.dot(self.b, self.bi_c)
if N.add.reduce((c_test-c)**2)/nconst > 1.e-12:
Utility.warning("The charge constraints are inconsistent."
" They will be applied as a least-squares"
" condition.")
示例3: close
# 需要导入模块: from MMTK import Utility [as 别名]
# 或者: from MMTK.Utility import warning [as 别名]
def close(self):
"""
Closes the file. Must be called in order to prevent data loss.
"""
if self.model_number is not None:
self.file.writeLine('ENDMDL', '')
self.file.close()
if self.warning:
Utility.warning('Some atoms are missing in the output file ' + \
'because their positions are undefined.')
self.warning = False
示例4: setConfiguration
# 需要导入模块: from MMTK import Utility [as 别名]
# 或者: from MMTK.Utility import warning [as 别名]
def setConfiguration(object, pdb_residues,
map = 'pdbmap', alt = 'pdb_alternative',
atom_map = None, toplevel = True):
defined = 0
if hasattr(object, 'is_protein'):
i = 0
for chain in object:
l = len(chain)
defined += setConfiguration(chain, pdb_residues[i:i+l],
map, alt, atom_map, False)
i = i + l
elif hasattr(object, 'is_chain'):
for i in range(len(object)):
defined += setConfiguration(object[i], pdb_residues[i:i+1],
map, alt, atom_map, False)
elif hasattr(object, map):
pdbmap = getattr(object, map)
try: altmap = getattr(object, alt)
except AttributeError: altmap = {}
nres = len(pdb_residues)
if len(pdbmap) != nres:
raise IOError('PDB configuration does not match object ' +
object.fullName())
for i in range(nres):
defined += setResidueConfiguration(object, pdb_residues[i],
pdbmap[i], altmap, atom_map)
elif Collections.isCollection(object):
nres = len(pdb_residues)
if len(object) != nres:
raise IOError('PDB configuration does not match object ' +
object.fullName())
for i in range(nres):
defined += setConfiguration(object[i], [pdb_residues[i]],
map, alt, atom_map, False)
else:
try:
name = object.fullName()
except AttributeError:
try:
name = object.name
except AttributeError:
name = '???'
raise IOError('PDB configuration does not match object ' + name)
if toplevel and defined < object.numberOfAtoms():
name = '[unnamed object]'
try:
name = object.fullName()
except: pass
if name: name = ' in ' + name
Utility.warning(`object.numberOfAtoms()-defined` + ' atom(s)' + name +
' were not assigned (new) positions.')
return defined
示例5: viewSequence
# 需要导入模块: from MMTK import Utility [as 别名]
# 或者: from MMTK.Utility import warning [as 别名]
def viewSequence(object, conf_list, periodic = False, label = None):
"""
Launches an animation using an external viewer.
:param object: the object for which the animation is displayed.
:type object: :class:`~MMTK.Collections.GroupOfAtoms`
:param conf_list: a sequence of configurations that define the animation
:type conf_list: sequence
:param periodic: if True, turn animation into a loop
:param label: an optional text string that some interfaces
use to pass a description of the object to the
visualization system.
:type label: str
"""
pdbviewer, exec_path = viewer.get('pdb', (None, None))
function = {'vmd': viewSequenceVMD,
'xmol': viewSequenceXMol,
'imol': viewSequenceIMol,
None: None}[pdbviewer]
if function is None:
Utility.warning('No viewer with animation feature defined.')
else:
function(object, conf_list, periodic, label)
示例6: close
# 需要导入模块: from MMTK import Utility [as 别名]
# 或者: from MMTK.Utility import warning [as 别名]
def close(self):
VRML.VRMLFile.close(self)
if self.warning:
Utility.warning('Some atoms are missing in the output file ' + \
'because their positions are undefined.')
self.warning = 0
示例7: viewConfiguration
# 需要导入模块: from MMTK import Utility [as 别名]
# 或者: from MMTK.Utility import warning [as 别名]
# On Unix-like systems, give priority to a user-specified viewer.
object.writeToFile(filename, configuration, format)
if os.fork() == 0:
pipe = os.popen(viewer[format][1] + ' ' + filename + \
' 1> /dev/null 2>&1', 'w')
pipe.close()
os.unlink(filename)
os._exit(0)
elif running_on_macosx:
object.writeToFile(filename, configuration, format)
subprocess.call(["/usr/bin/open", filename])
elif running_on_linux:
object.writeToFile(filename, configuration, format)
subprocess.call(["xdg-open", filename])
else:
Utility.warning('No viewer for %s defined.' % viewer_format)
return
def viewConfiguration(*args, **kwargs):
pdbviewer, exec_path = viewer.get('pdb', (None, None))
function = {'vmd': viewConfigurationVMD,
'xmol': viewConfigurationXMol,
'imol': viewConfigurationIMol} \
.get(pdbviewer,genericViewConfiguration)
function(*args, **kwargs)
#
# Normal mode and trajectory animation
#
def viewSequence(object, conf_list, periodic = False, label = None):
"""
示例8: __init__
# 需要导入模块: from MMTK import Utility [as 别名]
# 或者: from MMTK.Utility import warning [as 别名]
#.........这里部分代码省略.........
:keyword name: a name for the protein
:type name: str
"""
if items == (None,):
return
self.name = ''
if len(items) == 1 and type(items[0]) == type(''):
try:
filename = Database.databasePath(items[0], 'Proteins')
found = 1
except IOError:
found = 0
if found:
blueprint = Database.BlueprintProtein(items[0])
items = blueprint.chains
for attr, value in vars(blueprint).items():
if attr not in ['type', 'chains']:
setattr(self, attr, value)
else:
import PDB
conf = PDB.PDBConfiguration(items[0])
model = properties.get('model', 'all')
items = conf.createPeptideChains(model)
molecules = []
for i in items:
if ChemicalObjects.isChemicalObject(i):
molecules.append(i)
else:
molecules = molecules + list(i)
for m, i in zip(molecules, range(len(molecules))):
m._numbers = [i]
if not m.name:
m.name = 'chain'+`i`
ss = self._findSSBridges(molecules)
new_mol = {}
for m in molecules:
new_mol[m] = ([m],[])
for bond in ss:
m1 = new_mol[bond[0].topLevelChemicalObject()]
m2 = new_mol[bond[1].topLevelChemicalObject()]
if m1 == m2:
m1[1].append(bond)
else:
combined = (m1[0] + m2[0], m1[1] + m2[1] + [bond])
for m in combined[0]:
new_mol[m] = combined
self.molecules = []
while new_mol:
m = new_mol.values()[0]
for i in m[0]:
del new_mol[i]
bonds = m[1]
if len(m[0]) == 1:
m = m[0][0]
m._addSSBridges(bonds)
else:
numbers = sum((i._numbers for i in m[0]), [])
m = ConnectedChains(m[0])
m._numbers = numbers
m._addSSBridges(bonds)
m._finalize()
for c in m:
c.parent = self
m.parent = self
self.molecules.append(m)
self.atoms = []
self.chains = []
for m in self.molecules:
self.atoms.extend(m.atoms)
if hasattr(m, 'is_connected_chains'):
for c, name, i in zip(range(len(m)),
m.chain_names, m._numbers):
self.chains.append((m, c, name, i))
else:
try: name = m.name
except AttributeError: name = ''
self.chains.append((m, None, name, m._numbers[0]))
self.chains.sort(lambda c1, c2: cmp(c1[3], c2[3]))
self.chains = map(lambda c: c[:3], self.chains)
self.parent = None
self.type = None
self.configurations = {}
try:
self.name = properties['name']
del properties['name']
except KeyError: pass
if properties.has_key('position'):
self.translateTo(properties['position'])
del properties['position']
self.addProperties(properties)
undefined = 0
for a in self.atoms:
if a.position() is None:
undefined += 1
if undefined > 0 and undefined != len(self.atoms):
Utility.warning('Some atoms in a protein ' +
'have undefined positions.')
示例9: __init__
# 需要导入模块: from MMTK import Utility [as 别名]
# 或者: from MMTK.Utility import warning [as 别名]
def __init__(self, object, points, constraints = None):
self.atoms = object.atomList()
if type(points) != type({}):
points = {None: points}
if constraints is not None:
constraints = ChargeConstraintSet(self.atoms, constraints)
npoints = reduce(operator.add, map(len, points.values()))
natoms = len(self.atoms)
if npoints < natoms:
raise ValueError("Not enough data points for fit")
m = Numeric.zeros((npoints, natoms), Numeric.Float)
phi = Numeric.zeros((npoints,), Numeric.Float)
i = 0
for conf, pointlist in points.items():
for r, p in pointlist:
for j in range(natoms):
m[i, j] = 1./(r-self.atoms[j].position(conf)).length()
phi[i] = p
i = i + 1
m = m*Units.electrostatic_energy
m_test = m
phi_test = phi
if constraints is not None:
phi = phi-Numeric.dot(m, constraints.bi_c)
m = Numeric.dot(m, constraints.p)
c_rank = constraints.rank
else:
c_rank = 0
u, s, vt = LinearAlgebra.singular_value_decomposition(m)
s_test = s[:len(s)-c_rank]
cutoff = 1.e-10*Numeric.maximum.reduce(s_test)
nonzero = Numeric.repeat(s_test, Numeric.not_equal(s_test, 0.))
self.rank = len(nonzero)
self.condition = Numeric.maximum.reduce(nonzero) / \
Numeric.minimum.reduce(nonzero)
self.effective_rank = Numeric.add.reduce(Numeric.greater(s, cutoff))
if self.effective_rank < self.rank:
self.effective_condition = Numeric.maximum.reduce(nonzero) / cutoff
else:
self.effective_condition = self.condition
if self.effective_rank < natoms-c_rank:
Utility.warning('Not all charges are uniquely determined' +
' by the available data')
for i in range(natoms):
if s[i] > cutoff:
s[i] = 1./s[i]
else:
s[i] = 0.
q = Numeric.dot(Numeric.transpose(vt),
s*Numeric.dot(Numeric.transpose(u)[:natoms, :], phi))
if constraints is not None:
q = constraints.bi_c + Numeric.dot(constraints.p, q)
deviation = Numeric.dot(m_test, q)-phi_test
self.rms_error = Numeric.sqrt(Numeric.dot(deviation, deviation))
deviation = Numeric.fabs(deviation/phi_test)
self.relative_rms_error = Numeric.sqrt(Numeric.dot(deviation,
deviation))
self.charges = {}
for i in range(natoms):
self.charges[self.atoms[i]] = q[i]