def init_project(p_name, sys_name=None, m_freq=None, p_freq=None, platform=None, dbhost=None, w_threads=None): #def init_project(p_name, **freq): from adaptivemd import Project #if p_name in Project.list(): # print(project.name, "Deleting existing version of this test project") # Project.delete(p_name) if dbhost is not None: Project.set_dbhost(dbhost) project = Project(p_name) if project.name in Project.list(): print( project.name, "Project {0} exists, reading it from database".format( project.name)) else: from adaptivemd import File, OpenMMEngine from adaptivemd.analysis.pyemma import PyEMMAAnalysis ##################################### # NEW initialize sequence configuration_file = 'configuration.cfg' project.initialize(configuration_file) # # OLD initialize sequence #from adaptivemd import LocalResource #resource = LocalResource('/lustre/atlas/scratch/jrossyra/bip149/admd/') #project.initialize(resource) ##################################### f_name = '{0}.pdb'.format(sys_name) # only works if filestructure is preserved as described in 'jro_ntl9.ipynb' # and something akin to job script in 'admd_workers.pbs' is used f_base = 'file:///$ADAPTIVEMD/examples/files/{0}/'.format(sys_name) f_structure = File(f_base + f_name).load() f_system_2 = File(f_base + 'system-2.xml').load() f_integrator_2 = File(f_base + 'integrator-2.xml').load() f_system_5 = File(f_base + 'system-5.xml').load() f_integrator_5 = File(f_base + 'integrator-5.xml').load() sim_args = '-r -p {0}'.format(platform) if platform == 'CPU': print( project.name, "Using CPU simulation platform with {0} threads per worker". format(w_threads)) sim_args += ' --cpu-cpu-threads {0}'.format(w_threads) engine_2 = OpenMMEngine(f_system_2, f_integrator_2, f_structure, sim_args).named('openmm-2') engine_5 = OpenMMEngine(f_system_5, f_integrator_5, f_structure, sim_args).named('openmm-5') m_freq_2 = m_freq p_freq_2 = p_freq m_freq_5 = m_freq * 2 / 5 p_freq_5 = p_freq * 2 / 5 engine_2.add_output_type('master', 'allatoms.dcd', stride=m_freq_2) engine_2.add_output_type('protein', 'protein.dcd', stride=p_freq_2, selection='protein') engine_5.add_output_type('master', 'allatoms.dcd', stride=m_freq_5) engine_5.add_output_type('protein', 'protein.dcd', stride=p_freq_5, selection='protein') ca_features = {'add_distances_ca': None} #features = {'add_inverse_distances': {'select_Backbone': None}} ca_modeller_2 = PyEMMAAnalysis(engine_2, 'protein', ca_features).named('pyemma-ca-2') ca_modeller_5 = PyEMMAAnalysis(engine_5, 'protein', ca_features).named('pyemma-ca-5') pos = [ '(rescode K and mass > 13) ' + 'or (rescode R and mass > 13) ' + 'or (rescode H and mass > 13)' ] neg = ['(rescode D and mass > 13) ' + 'or (rescode E and mass > 13)'] ionic_features = { 'add_distances': { 'select': pos }, 'kwargs': { 'indices2': { 'select': neg } } } all_features = [ca_features, ionic_features] #ok#ionic_modeller = {'add_distances': {'select': #ok# ['rescode K or rescode R or rescode H']}, #ok# 'kwargs': {'indices2': {'select': #ok# 'rescode D or rescode E']}}} #contact_features = [ {'add_inverse_distances': # {'select_Backbone': None}}, # {'add_residue_mindist': None, # 'kwargs': {'threshold': 0.6}} # ] all_modeller_2 = PyEMMAAnalysis(engine_2, 'protein', all_features).named('pyemma-ionic-2') all_modeller_5 = PyEMMAAnalysis(engine_5, 'protein', all_features).named('pyemma-ionic-5') project.generators.add(ca_modeller_2) project.generators.add(all_modeller_2) project.generators.add(ca_modeller_5) project.generators.add(all_modeller_5) project.generators.add(engine_2) project.generators.add(engine_5) [print(g) for g in project.generators] return project
def init_project(p_name, sys_name=None, m_freq=None, p_freq=None, platform=None, reinitialize=False): #, dblocation=None): #def init_project(p_name, **freq): from adaptivemd import Project #if p_name in Project.list(): # print("Deleting existing version of this test project") # Project.delete(p_name) dburl = os.environ.get("ADMD_DBURL", 0) if dburl: logger.info("Set ADMD_DBURL to: " + dburl) Project.set_dburl(dburl) # if dblocation is not None: # Project.set_dblocation(dblocation) if reinitialize: logger.info( "Project {0} exists, deleting it from database to reinialize". format(p_name)) Project.delete(p_name) if p_name in Project.list(): logger.info( "Project {0} exists, reading it from database".format(p_name)) project = Project(p_name) elif not all([sys_name, m_freq, p_freq, platform]): raise ValueError( "Must define all parameters [{0}] to initialize new project\nHave: {1}" .format("sys_name,m_freq,p_freq,platform", [sys_name, m_freq, p_freq, platform].__repr__())) else: project = Project(p_name) from adaptivemd import File, OpenMMEngine from adaptivemd.analysis.pyemma import PyEMMAAnalysis # Initialize w/ config file: 1 of multiple options # TODO add config filename argument configuration_file = 'configuration.cfg' project.initialize(configuration_file) f_name = '{0}.pdb'.format(sys_name) # FIXME add system specifications to configuration file f_base = 'file:///$ADMD_FILES/{0}/'.format(sys_name) f_structure = File(f_base + f_name).load() f_system_2 = File(f_base + 'system-2.xml').load() f_integrator_2 = File(f_base + 'integrator-2.xml').load() f_system_5 = File(f_base + 'system-5.xml').load() f_integrator_5 = File(f_base + 'integrator-5.xml').load() sim_args = '-r -p {0}'.format(platform) engine_2 = OpenMMEngine(f_system_2, f_integrator_2, f_structure, sim_args).named('openmm-2') engine_5 = OpenMMEngine(f_system_5, f_integrator_5, f_structure, sim_args).named('openmm-5') # FIXME this is dumb and hard for user to deal with # TODO engine selection by name m_freq_2 = m_freq p_freq_2 = p_freq m_freq_5 = m_freq * 2 / 5 p_freq_5 = p_freq * 2 / 5 engine_2.add_output_type('master', 'allatoms.dcd', stride=m_freq_2) engine_2.add_output_type('protein', 'protein.dcd', stride=p_freq_2, selection='protein') engine_5.add_output_type('master', 'allatoms.dcd', stride=m_freq_5) engine_5.add_output_type('protein', 'protein.dcd', stride=p_freq_5, selection='protein') ca_features = {'add_distances_ca': None} #features = {'add_inverse_distances': {'select_Backbone': None}} ca_modeller_2 = PyEMMAAnalysis(engine_2, 'protein', ca_features).named('pyemma-ca-2') ca_modeller_5 = PyEMMAAnalysis(engine_5, 'protein', ca_features).named('pyemma-ca-5') pos = [ '(rescode K and mass > 13) ' + 'or (rescode R and mass > 13) ' + 'or (rescode H and mass > 13)' ] neg = ['(rescode D and mass > 13) ' + 'or (rescode E and mass > 13)'] ionic_features = { 'add_distances': { 'select': pos }, 'kwargs': { 'indices2': { 'select': neg } } } all_features = [ca_features, ionic_features] inv_ca_features = {'add_inverse_distances': {'select_Ca': None}} #ok#ionic_modeller = {'add_distances': {'select': #ok# ['rescode K or rescode R or rescode H']}, #ok# 'kwargs': {'indices2': {'select': #ok# 'rescode D or rescode E']}}} #contact_features = [ {'add_inverse_distances': # {'select_Backbone': None}}, # {'add_residue_mindist': None, # 'kwargs': {'threshold': 0.6}} # ] all_modeller_2 = PyEMMAAnalysis(engine_2, 'protein', all_features).named('pyemma-ionic-2') all_modeller_5 = PyEMMAAnalysis(engine_5, 'protein', all_features).named('pyemma-ionic-5') inv_modeller_2 = PyEMMAAnalysis( engine_2, 'protein', inv_ca_features).named('pyemma-invca-2') inv_modeller_5 = PyEMMAAnalysis( engine_5, 'protein', inv_ca_features).named('pyemma-invca-5') project.generators.add(ca_modeller_2) project.generators.add(all_modeller_2) project.generators.add(inv_modeller_2) project.generators.add(ca_modeller_5) project.generators.add(all_modeller_5) project.generators.add(inv_modeller_5) project.generators.add(engine_2) project.generators.add(engine_5) #[print(g) for g in project.generators] return project