Ejemplo n.º 1
0
def autodetect_start_structure():
    """
	Autodetect a lone PDB file in the inputs folder if the user has not changed the default "start_structure"
	setting. This function is useful for starting batches of protein simulations or homology modeling in 
	e.g. the factory codes.
	"""

    if wordspace.requires == 'homology':
        wordspace.start_structure = wordspace.template
    if not 'start_structure' in wordspace:
        raise Exception(
            '\n[ERROR] this autodect function requires the start_structure setting\n'
            +
            '[ERROR] (set start_structure to inputs/STRUCTURE.pdb to autodetect a lone pdb in inputs.'
        )
    if wordspace.start_structure == 'inputs/STRUCTURE.pdb':
        pdbs = glob.glob('inputs/*.pdb')
        if len(pdbs) == 1:
            wordspace.start_structure = pdbs[0]
            wordspace.system_name = re.findall('^inputs/([\w\.-]+)\.pdb$',
                                               pdbs[0])[0]
        else:
            if 'watch_file' not in wordspace:
                wordspace.watch_file = 'ERROR.log'
            report(
                'multiple PDBs in inputs/ and start_structure is still default',
                tag='warning')
    else:
        print "OOPS"
        import pdb
        pdb.set_trace()
Ejemplo n.º 2
0
def equilibrate_check(name):
    """
	Check if the gro file for this step has been written.
	"""

    found = False
    fn = wordspace['step'] + 'md-%s.gro' % name
    if os.path.isfile(fn):
        report('found %s' % fn, tag='RETURN')
        found = True
    return found
Ejemplo n.º 3
0
def equilibrate_check(name):

	"""
	Check if the gro file for this step has been written.
	"""

	found = False
	fn = wordspace['step']+'md-%s.gro'%name
	if os.path.isfile(fn): 
		report('found %s'%fn,tag='RETURN')
		found = True
	return found
Ejemplo n.º 4
0
def autodetect_start_structure():

	"""
	Autodetect a lone PDB file in the inputs folder if the user has not changed the default "start_structure"
	setting. This function is useful for starting batches of protein simulations or homology modeling in 
	e.g. the factory codes.
	"""
        
        if wordspace.requires=='homology':
                wordspace.start_structure=wordspace.template
	if not 'start_structure' in wordspace: 
		raise Exception('\n[ERROR] this autodect function requires the start_structure setting\n'+
			'[ERROR] (set start_structure to inputs/STRUCTURE.pdb to autodetect a lone pdb in inputs.')
	if wordspace.start_structure == 'inputs/STRUCTURE.pdb':
		pdbs = glob.glob('inputs/*.pdb')
		if len(pdbs)==1: 
			wordspace.start_structure = pdbs[0]
                        wordspace.system_name = re.findall('^inputs/([\w\.-]+)\.pdb$',pdbs[0])[0]
		else: 
			if 'watch_file' not in wordspace: wordspace.watch_file = 'ERROR.log'
			report('multiple PDBs in inputs/ and start_structure is still default',tag='warning')
	else:
		print "OOPS"
		import pdb;pdb.set_trace()
Ejemplo n.º 5
0
def exception_handler(e,wordspace,all=False,outfile=None):

	"""
	Report an error concisely to the terminal to avoid overwhelming the user.
	"""

	exc_type, exc_obj, exc_tb = sys.exc_info()
	fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
	from amx.base.journal import report
	report('%s in %s at line %d'%(str(exc_type),fname,exc_tb.tb_lineno),tag='error')
	report('%s'%e,tag='error')
	if all:
		import traceback
		report(re.sub('\n','\n[TRACEBACK] ',traceback.format_exc()),tag='traceback')
	write_wordspace(wordspace,outfile=outfile)
	sys.exit(1)
Ejemplo n.º 6
0
def exception_handler(e, wordspace, all=False, outfile=None):
    """
	Report an error concisely to the terminal to avoid overwhelming the user.
	"""

    exc_type, exc_obj, exc_tb = sys.exc_info()
    fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
    from amx.base.journal import report
    report('%s in %s at line %d' % (str(exc_type), fname, exc_tb.tb_lineno),
           tag='error')
    report('%s' % e, tag='error')
    if all:
        import traceback
        report(re.sub('\n', '\n[TRACEBACK] ', traceback.format_exc()),
               tag='traceback')
    write_wordspace(wordspace, outfile=outfile)
    sys.exit(1)