def create_dbs(self): self.logger_freshs.debug(cc.c_magenta + __name__ + ': create_dbs' + cc.reset) try: if self.algo_name == 'ffs' or self.algo_name == 'perm_ffs': import configpoints # create instance of DB for configpoint-handling / open existing DB confdbfile = self.timestamp + '_configpoints.sqlite' self.storepoints=configpoints.configpoints(self, self.folder_db + confdbfile) # create instance of DB for pre-runs: ghostdbfile = self.timestamp + '_ghost.sqlite' self.ghostpoints=configpoints.configpoints(self, self.folder_db + ghostdbfile) # Symlink DBs try: os.remove(self.folder_db + 'configpoints.sqlite') os.remove(self.folder_db + 'ghostpoints.sqlite') except: pass try: os.symlink(confdbfile, self.folder_db + 'configpoints.sqlite') os.symlink(ghostdbfile, self.folder_db + 'ghostpoints.sqlite') except: pass elif self.algo_name == 'spres': ##open or create a DB with the correct timepoint confdbfile = self.timestamp + '_configpoints.sqlite' if self.configfile.has_option('spres_control','use_multDB'): if self.configfile.getint('spres_control','use_multDB') > 0: import configpoints_spres_multDB self.storepoints=configpoints_spres_multDB.configpoints(self, self.folder_db + confdbfile, self.epoch) else: import configpoints_spres self.storepoints=configpoints_spres.configpoints(self, self.folder_db + confdbfile) else: self.logger_freshs.warn(cc.c_red + 'No option use_multDB in spres_control!' + cc.reset) self.logger_freshs.warn(cc.c_red + 'Defaulting to use multiple DBs anyway.' + cc.reset) import configpoints_spres_multDB self.storepoints=configpoints_spres_multDB.configpoints(self, self.folder_db + confdbfile, self.epoch) elif self.algo_name == 'nsffs': import configpoints # create instance of DB for configpoint-handling / open existing DB confdbfile = self.timestamp + '_configpoints.sqlite' self.storepoints=configpoints.configpoints(self, self.folder_db + confdbfile) except Exception as e: self.logger_freshs.debug(cc.c_red + __name__ + 'Error!:' + str(e) + cc.reset) raise SystemExit(1)
def getP(dbFile): ###DB handler try: cfph = configpoints.configpoints('none', dbFile) except: print("NoDBFile:" + dbFile) exit(1) ###Get a list of nucleating pathways by endpoint. cfpcand = cfph.return_points_on_last_interface() tracecount = 0 maxtr = len(cfpcand) w_list = [] ##backtrace each suvvessful trace to find its Rosenbluth weight for cfp in cfpcand: weight = 1.0 op = cfph.return_origin_point_by_id(cfp[2]) while True: cfph.cur.execute( 'select usecount from configpoints where myid = ?', [op[8]]) result = cfph.cur.fetchone() if result: siblings = int(result[0]) else: print("Error backtracing for rates") exit(1) weight = weight / float(siblings) if 'escape' in op[2]: break op = cfph.return_origin_point_by_id(op[2]) w_list.append(weight) print("cfp: " + cfp[8] + " has weight: " + str(weight)) p_B_given_A = np.sum(np.asarray(w_list)) return p_B_given_A
def getP( dbFile ): ###DB handler try: cfph = configpoints.configpoints('none',dbFile) except: print("NoDBFile:"+dbFile) exit(1) ###Get a list of nucleating pathways by endpoint. cfpcand = cfph.return_points_on_last_interface() tracecount = 0 maxtr = len(cfpcand) w_list = [] ##backtrace each suvvessful trace to find its Rosenbluth weight for cfp in cfpcand: weight = 1.0 op = cfph.return_origin_point_by_id(cfp[2]) while True: cfph.cur.execute('select usecount from configpoints where myid = ?', [op[8]]) result = cfph.cur.fetchone() if result: siblings = int(result[0]) else: print("Error backtracing for rates") exit(1) weight = weight / float(siblings) if 'escape' in op[2]: break op = cfph.return_origin_point_by_id(op[2]) w_list.append(weight) print("cfp: "+cfp[8]+" has weight: "+str(weight)) p_B_given_A = np.sum(np.asarray(w_list)) return p_B_given_A
#if int(op[0]) != 0: if not 'escape' in op[2]: visit(op) # check usage if len(sys.argv) < 2: print("Usage:", sys.argv[0], "<../server/DB/configpoint-DB-file>") exit(1) # construct timestamp out of DB filename timestamp = re.sub('.*/', '', re.sub('_configpoints.*', '', sys.argv[1])) datadir = datadir_base + '/' + timestamp # configpoint handler cfph = configpoints.configpoints('none', sys.argv[1]) # Prepare directories outdir_base = 'OUTPUT' outdir = outdir_base + '/' + timestamp # backtrace plotfile plotfile_trace = outdir + '/tree_success.gnuplot' tmkdir(outdir_base) tmkdir(outdir) # ---------------------------------------------------------------------------- # Backtrace successful trajectories # ----------------------------------------------------------------------------
sys.path.append('../server/modules') sys.path.append('../server/modules/ffs') # custom import configpoints def extract_customdata(interface, dbhandle): customdata = dbhandle.return_customdata(interface) floatdata = [] for el in customdata: for el2 in el.split(): floatdata.append(float(el2)) return floatdata if len(sys.argv) < 2: print("Usage:", sys.argv[0], "<../server/DB/configpoint-DB-file>") exit(1) cfph = configpoints.configpoints('none', sys.argv[1]) maxlam = cfph.biggest_lambda() for i in range(maxlam + 1): print("Interface", i) print(extract_customdata(i, cfph)) # TODO: build histograms
if el <= bin_max and el > bin_min: tmphisto[iq] += 1 return tmphisto # check usage if len(sys.argv) < 2: print("Usage:", sys.argv[0], "<configpoints.sqlite>") exit(1) dbfwd = sys.argv[1] # construct timestamp out of DB filename timestampfwd = re.sub('.*/', '', re.sub('_configpoints.*', '', dbfwd)) # configpoint handler fcfph = configpoints.configpoints('none', dbfwd) # Prepare directories outdir_base = 'OUTPUT' outdir = outdir_base + '/' + timestampfwd tmkdir(outdir_base) tmkdir(outdir) # get endpoint candidates print("Reading forward probabilities") fprobs, fN, fnonsuccess, fM = fcfph.return_probabilities(1) print(fprobs) #ninterfaces = cfphfwd.biggest_lambda() print("Reading forward lambdas")
def create_dbs(self): self.logger_freshs.debug(cc.c_magenta + __name__ + ": create_dbs" + cc.reset) try: if self.algo_name == "ffs" or self.algo_name == "perm_ffs": import configpoints # create instance of DB for configpoint-handling / open existing DB confdbfile = self.timestamp + "_configpoints.sqlite" self.storepoints = configpoints.configpoints(self, self.folder_db + confdbfile) # create instance of DB for pre-runs: ghostdbfile = self.timestamp + "_ghost.sqlite" self.ghostpoints = configpoints.configpoints(self, self.folder_db + ghostdbfile) # Symlink DBs try: os.remove(self.folder_db + "configpoints.sqlite") os.remove(self.folder_db + "ghostpoints.sqlite") except: pass try: os.symlink(confdbfile, self.folder_db + "configpoints.sqlite") os.symlink(ghostdbfile, self.folder_db + "ghostpoints.sqlite") except: pass elif self.algo_name == "spres": ##open or create a DB with the correct timepoint confdbfile = self.timestamp + "_configpoints.sqlite" if self.configfile.has_option("spres_control", "use_multDB"): if self.configfile.getint("spres_control", "use_multDB") > 0: import configpoints_spres_multDB self.storepoints = configpoints_spres_multDB.configpoints( self, self.folder_db + confdbfile, self.epoch ) else: import configpoints_spres self.storepoints = configpoints_spres.configpoints(self, self.folder_db + confdbfile) else: self.logger_freshs.warn(cc.c_red + "No option use_multDB in spres_control!" + cc.reset) self.logger_freshs.warn(cc.c_red + "Defaulting to use multiple DBs anyway." + cc.reset) import configpoints_spres_multDB self.storepoints = configpoints_spres_multDB.configpoints( self, self.folder_db + confdbfile, self.epoch ) elif self.algo_name == "nsffs": import configpoints # create instance of DB for configpoint-handling / open existing DB confdbfile = self.timestamp + "_configpoints.sqlite" self.storepoints = configpoints.configpoints(self, self.folder_db + confdbfile) except Exception as e: self.logger_freshs.debug(cc.c_red + __name__ + "Error!:" + str(e) + cc.reset) raise SystemExit(1)