Exemplo n.º 1
0
def plot(plotname=None,nox=False,workspace=None,specfile=None,plotlog=False,**kwargs):

	"""
	Run a plotting routine.
	"""

	from copy import deepcopy
	if plotname == None:
		from base.workspace import Workspace
		if workspace == None: workspace = unpacker(conf_paths)['workspace_spot']
		work = Workspace(workspace,previous=False)
		specs = work.load_specs()
		plotnames = specs['plots'].keys()
	else: plotnames = [plotname]
	#---for each desired plot type
	for pname in plotnames:
		fns = []
		for (dirpath, dirnames, filenames) in os.walk('./'): 
			fns.extend([dirpath+'/'+fn for fn in filenames])
		search = filter(lambda x:re.match('^\.\/[^omni].+\/plot-%s\.py$'%pname,x),fns)
		if len(search)!=1: status('unclear search for %s: %s'%(pname,str(search)))
		else: 
			if plotname==None: 
				cmd = 'python '+search[0]+' nox quit=True '+' "%s"'%str(kwargs)+\
					(' &> %s'%plotlog if plotlog else '')
			else: 
				status('rerun the plot with:\n\nexecfile(\''+search[0]+'\')\n',tag='note')
				cmd = "python -i "+search[0]+(' nox' if nox else '')+' "%s"'%str(kwargs)
				#---! add log here? is the user or factory ever going to use this?
			status('calling: "%s"'%cmd,tag='status')
			os.system(cmd)
Exemplo n.º 2
0
def export_to_factory(project_name,project_location,workspace=None):

	"""
	Export the simulation data from the toc to the factory database.
	Users should not run this.
	"""

	sys.path.insert(0,project_location)
	os.environ.setdefault("DJANGO_SETTINGS_MODULE",project_name+".settings")
	import django
	#---! a fairly extreme hack. this function needs a lot of work. the paths are almost certainly fubar
	sys.path.insert(0,os.path.join(os.path.abspath(os.path.join(project_location,'../../')),'dev'))
	django.setup()
	from simulator import models
	from base.workspace import Workspace
	workspace = unpacker(conf_paths)['workspace_spot']
	work = Workspace(workspace)
	sns={}
	for key in work.toc.keys():
		for sn in work.toc[key]:
			sns[sn]=key[0]
	for sn in sns.keys():
		if any([sn in work.toc[i] for i in work.toc.keys() if i[1]=='edr']) and (
			any([sn in work.toc[i] for i in work.toc.keys() if i[1]=='trr']) or
			any([sn in work.toc[i] for i in work.toc.keys() if i[1]=='xtc'])):
			spot=(sns[sn],'edr')
			name=work.prefixer(sn)
			try: models.Simulation(name=name,program="protein",code=sn).save()
			except: print '[NOTE] simulation "%s" already exists in the database'%name
	if not sns: print "[STATUS] nothing to export"
Exemplo n.º 3
0
def refresh(autoreload=True):

	"""
	If you have new data or more data (i.e. more XTC files or longer trajectories) you must
	run refresh in order to add those files to the tables of contents.
	"""

	from base.workspace import Workspace
	workspace = unpacker(conf_paths)['workspace_spot']
	work = Workspace(workspace,autoreload=autoreload)
	work.bootstrap()
	work.save()
Exemplo n.º 4
0
def compute(calculation_name=None,autoreload=True):

	"""
	Open the workspace, parse a YAML script with instructions, save, and exit.
	Note that we may specify a particular calculation if there are many pending calculations.
	"""

	from base.workspace import Workspace
	workspace = unpacker(conf_paths)['workspace_spot']
	work = Workspace(workspace,autoreload=autoreload)
	work.action(calculation_name=calculation_name)
	work.save()