本文整理汇总了Python中forcebalance.molecule.Molecule.require方法的典型用法代码示例。如果您正苦于以下问题:Python Molecule.require方法的具体用法?Python Molecule.require怎么用?Python Molecule.require使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forcebalance.molecule.Molecule
的用法示例。
在下文中一共展示了Molecule.require方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TINKER
# 需要导入模块: from forcebalance.molecule import Molecule [as 别名]
# 或者: from forcebalance.molecule.Molecule import require [as 别名]
class TINKER(Engine):
""" Engine for carrying out general purpose TINKER calculations. """
def __init__(self, name="tinker", **kwargs):
## Keyword args that aren't in this list are filtered out.
self.valkwd = ['tinker_key', 'tinkerpath', 'tinker_prm']
self.warn_vn = False
super(TINKER,self).__init__(name=name, **kwargs)
def setopts(self, **kwargs):
""" Called by __init__ ; Set TINKER-specific options. """
## The directory containing TINKER executables (e.g. dynamic)
if 'tinkerpath' in kwargs:
self.tinkerpath = kwargs['tinkerpath']
if not os.path.exists(os.path.join(self.tinkerpath,"dynamic")):
warn_press_key("The 'dynamic' executable indicated by %s doesn't exist! (Check tinkerpath)" \
% os.path.join(self.tinkerpath,"dynamic"))
else:
warn_once("The 'tinkerpath' option was not specified; using default.")
if which('mdrun') == '':
warn_press_key("Please add TINKER executables to the PATH or specify tinkerpath.")
self.tinkerpath = which('dynamic')
def readsrc(self, **kwargs):
""" Called by __init__ ; read files from the source directory. """
self.key = onefile(kwargs.get('tinker_key'), 'key')
self.prm = onefile(kwargs.get('tinker_prm'), 'prm')
if 'mol' in kwargs:
self.mol = kwargs['mol']
else:
crdfile = onefile(kwargs.get('coords'), 'arc', err=True)
self.mol = Molecule(crdfile)
def calltinker(self, command, stdin=None, print_to_screen=False, print_command=False, **kwargs):
""" Call TINKER; prepend the tinkerpath to calling the TINKER program. """
csplit = command.split()
# Sometimes the engine changes dirs and the key goes missing, so we link it.
if "%s.key" % self.name in csplit and not os.path.exists("%s.key" % self.name):
LinkFile(self.abskey, "%s.key" % self.name)
prog = os.path.join(self.tinkerpath, csplit[0])
csplit[0] = prog
o = _exec(' '.join(csplit), stdin=stdin, print_to_screen=print_to_screen, print_command=print_command, rbytes=1024, **kwargs)
# Determine the TINKER version number.
for line in o[:10]:
if "Version" in line:
vw = line.split()[2]
if len(vw.split('.')) <= 2:
vn = float(vw)
else:
vn = float(vw.split('.')[:2])
vn_need = 6.3
try:
if vn < vn_need:
if self.warn_vn:
warn_press_key("ForceBalance requires TINKER %.1f - unexpected behavior with older versions!" % vn_need)
self.warn_vn = True
except:
logger.error("Unable to determine TINKER version number!\n")
raise RuntimeError
for line in o[-10:]:
# Catch exceptions since TINKER does not have exit status.
if "TINKER is Unable to Continue" in line:
for l in o:
logger.error("%s\n" % l)
time.sleep(1)
logger.error("TINKER may have crashed! (See above output)\nThe command was: %s\nThe directory was: %s\n" % (' '.join(csplit), os.getcwd()))
raise RuntimeError
break
for line in o:
if 'D+' in line:
logger.info(line+'\n')
warn_press_key("TINKER returned a very large floating point number! (See above line; will give error on parse)")
return o
def prepare(self, pbc=False, **kwargs):
""" Called by __init__ ; prepare the temp directory and figure out the topology. """
# Call TINKER but do nothing to figure out the version number.
o = self.calltinker("dynamic", persist=1, print_error=False)
self.rigid = False
## Attempt to set some TINKER options.
tk_chk = []
tk_opts = OrderedDict([("digits", "10"), ("archive", "")])
tk_defs = OrderedDict()
prmtmp = False
if hasattr(self,'FF'):
if not os.path.exists(self.FF.tinkerprm):
# If the parameter files don't already exist, create them for the purpose of
#.........这里部分代码省略.........