def check_masters(self, idle): if time.time() - self.last_heartbeat_from_master > self.max_wait: terminate = False with helpers.ExclusiveConnect(self.hbdb_path) as cursor: cursor.execute("SELECT * FROM heartbeat WHERE thread_type='master' " "AND pulse>?", (time.time() - self.max_wait - cursor.lag,)) masters = cursor.fetchall() if not masters: terminate = True self.last_heartbeat_from_master = time.time() if terminate: self.terminate("%s of master inactivity (spent %s%% time idle)" % (br.pretty_time(self.max_wait), idle)) return
def check_masters(self, idle): if time.time() - self.last_heartbeat_from_master > self.max_wait: terminate = False with helpers.ExclusiveConnect(self.hbdb_path) as cursor: cursor.execute( "SELECT * FROM heartbeat WHERE thread_type='master' " "AND pulse>?", (time.time() - self.max_wait - cursor.lag, )) masters = cursor.fetchall() if not masters: terminate = True self.last_heartbeat_from_master = time.time() if terminate: self.terminate( "%s of master inactivity (spent %s%% time idle)" % (br.pretty_time(self.max_wait), idle)) return
def total_elapsed(self, prefix="", postfix=""): return "%s%s%s" % (prefix, br.pretty_time(round(time()) - self.start), postfix)
def split(self, prefix="", postfix=""): split = round(time()) - self.split_time self.split_time = round(time()) return "%s%s%s" % (prefix, br.pretty_time(split), postfix)
with open("./analysis/best_scheme.txt", "r") as ifile: content = ifile.read() content = re.findall(r"RaxML-style partition definitions\n(.*)", content, re.DOTALL)[0] with open("./RAxML/partition.txt", "w") as ofile: ofile.write(content) shutil.copy("%s/%s.phy" % (new_dir, file_name), "./RAxML/") with open("./RAxML/RAxML.sh", "w") as ofile: model = "PROTGAMMAGTR" if alphabet == IUPAC.protein else "GTRGAMMA" sh_output = "source /home/bondsr/.bashrc;\n" sh_output += "/usr/lib64/openmpi/1.4-gcc/bin/mpirun -np 20 /home/kochbj/bin/bin/raxmlHPC-MPI " \ "-s !!!1!!!/%s/%s.phy -n %s -m %s -f d -p 12345 -N 20 -w !!!1!!!/%s/ML_trees/ " \ "-q !!!1!!!/%s/partition.txt;\n" % (file_name, file_name, file_name, model, file_name, file_name) sh_output += "/usr/lib64/openmpi/1.4-gcc/bin/mpirun -np 20 /home/kochbj/bin/bin/raxmlHPC-MPI " \ "-s !!!1!!!/%s/%s.phy -n %s -m %s -f d -p 12345 -b 12345 -N 100 " \ "-w !!!1!!!/%s/bootstraps/ -q !!!1!!!/%s/partition.txt;\n" % (file_name, file_name, file_name, model, file_name, file_name) sh_output += "/home/bondsr/bin/best_ML_tree.py !!!1!!!/%s/ML_trees/RAxML_info.%s;\n" % (file_name, file_name) sh_output += "/home/bondsr/bin/raxmlHPC-PTHREADS-SSE3 -n %s -m %s -f b -p 12345 -T 2 " \ "-w !!!1!!!/%s/cons_tree/ -t !!!1!!!/%s/ML_trees/RAxML_best.%s " \ "-z !!!1!!!/%s/bootstraps/RAxML_bootstrap.%s;\n" % (file_name, model, file_name, file_name, file_name, file_name, file_name) ofile.write(sh_output) os.chdir(blocks_file_dir) print("Job complete, it ran in %s" % br.pretty_time(round(clock()) - start_time))
all_by_all_handle = open("%s/all_by_all.csv" % in_args.outdir, "a") printer = br.DynamicPrint(quiet=in_args.quiet, log=in_args.log) counter = 1 start_time = round(time()) for hit in blast_p_hits_handle: counter += 1 if counter % 1000 == 0: printer.write("\t--> formatting %s of %s hits" % (counter, total_hits)) if hit == "": continue data = hit.split("\t") if data[0] == data[1]: continue if data[10] == '0.0': data[10] = '1e-181' try: data[1] = total_hash_map[data[1]] data[0] = total_hash_map[data[0]] all_by_all_handle.write("%s" % "\t".join(data)) except KeyError: print("Error:\t", data) printer.write("\t--> formatting %s of %s hits" % (counter, total_hits)) print("\n\tDone formatting in %s" % br.pretty_time(round(time()) - start_time)) os.remove("%s/temp_blast_hits.csv" % in_args.outdir)