Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse(self, a_job, force_a_reparse=False):
"""Rather than running GAMESS, we just read
and parse the results already in the database."""
from markstools.io.gamess import ReadGamessInp
parser = None
print a_job.parsed
if not force_a_reparse:
parser = a_job.parser
if parser != self.__class__.__name__:
raise MyTypeError('Can not reparse, parsed results are from %s, expecting %s'%(parser, self.__class__.__name_))
a_result = a_job.parsed
if a_result:
if not isinstance(a_result, GamessResult):
raise MyTypeError('Unpickled parse results are of type %s, expecting %s'%(type(a_result)), GamessResult)
markstools.log.info('Using previously parsed results for Job %s'%(a_job.id))
if a_result is None:
markstools.log.info('Starting to parse Job %s results'%(a_job.id))
markstools.log.debug('Starting to parse Run %s results'%(a_job.run.id))
f_inp = a_job.get_attachment('inp')
if f_inp is None:
raise DocumentError('Run %s does not contain a .inp file'%(a_job.run.id))
reader = ReadGamessInp(f_inp)
f_inp.close()
f_dat = a_job.get_attachment('dat')
if f_dat is None:
raise DocumentError('Run %s does not contain a .dat file'%(a_job.run.id))
self.parsed_dat.parse_file(f_dat)
f_dat.close()
f_stdout = a_job.get_attachment('stdout')
def parse(self, a_job, force_a_reparse=False):
"""Rather than running GAMESS, we just read
and parse the results already in the database."""
from markstools.io.gamess import ReadGamessInp
parser = None
print a_job.parsed
if not force_a_reparse:
parser = a_job.parser
if parser != self.__class__.__name__:
raise MyTypeError('Can not reparse, parsed results are from %s, expecting %s'%(parser, self.__class__.__name_))
a_result = a_job.parsed
if a_result:
if not isinstance(a_result, GamessResult):
raise MyTypeError('Unpickled parse results are of type %s, expecting %s'%(type(a_result)), GamessResult)
markstools.log.info('Using previously parsed results for Job %s'%(a_job.id))
if a_result is None:
markstools.log.info('Starting to parse Job %s results'%(a_job.id))
markstools.log.debug('Starting to parse Run %s results'%(a_job.run.id))
f_inp = a_job.get_attachment('inp')
if f_inp is None:
raise DocumentError('Run %s does not contain a .inp file'%(a_job.run.id))
reader = ReadGamessInp(f_inp)
f_inp.close()
f_dat = a_job.get_attachment('dat')
if f_dat is None:
raise DocumentError('Run %s does not contain a .dat file'%(a_job.run.id))
self.parsed_dat.parse_file(f_dat)
f_dat.close()
f_stdout = a_job.get_attachment('stdout')
if f_stdout is None:
f_inp = a_job.get_attachment('inp')
if f_inp is None:
raise DocumentError('Run %s does not contain a .inp file'%(a_job.run.id))
reader = ReadGamessInp(f_inp)
f_inp.close()
f_dat = a_job.get_attachment('dat')
if f_dat is None:
raise DocumentError('Run %s does not contain a .dat file'%(a_job.run.id))
self.parsed_dat.parse_file(f_dat)
f_dat.close()
f_stdout = a_job.get_attachment('stdout')
if f_stdout is None:
raise DocumentError('Run %s does not contain a .stdout file'%(a_job.run.id))
self.parsed_out.parse_file(f_stdout)
f_stdout.close()
a_result = GamessResult(reader.atoms, reader.params, self.parsed_dat.group, self.parsed_out.group)
self._save_parsed_result(a_job, a_result)
return a_result
def preexisting_result(self, f_name):
"""Rather than running GAMESS, we just read
and parse the results already on the file system."""
from markstools.io.gamess import ReadGamessInp
f_dict = self.get_files(f_name)
new_reader = ReadGamessInp(f_dict['inp'])
result = GamessResult(new_reader.atoms, new_reader.params, self)
result.a_job = f_name
return result
def calculate(self, f_name):
import os
from markstools.io.gamess import WriteGamessInp
result = GamessResult(atoms, params, self)
cmd = 'cd %s; %s %s.%s 1> %s.%s 2> %s.%s'%(self.f_dir, self.CMD_GAMESS,
f_name, self.EXT_INPUT_FILE, f_name, self.EXT_STDOUT_FILE,
f_name, self.EXT_STDERR_FILE)
return_code = os.system(cmd)
assert return_code == 0, 'Error runing GAMESS. Check %s/%s.%s'%(self.f_dir, f_name, self.EXT_STDOUT_FILE)
result.a_job = f_name
return result