Skip to content
Snippets Groups Projects
Commit 79c8824d authored by Véronique  LEGRAND's avatar Véronique LEGRAND
Browse files

fixed bug that caused checkpoint file to be generated several time in the same...

fixed bug that caused checkpoint file to be generated several time in the same second. Now have millisecond precision to avoid teh problem
parent 0fb36a15
No related branches found
No related tags found
No related merge requests found
......@@ -202,13 +202,16 @@ class RCCheckpoint:
str(self.count_line)+chk_fname_sep+str(self.read_match)
full_fname = os.path.join(dir_chk, filename)
self.res.save(full_fname)
print("created checkpoint: ",filename+".npz")
# remove old breakpoint file
list_f=os.listdir(dir_chk)
sub_s=base_chk_fname+ str(core_id) + chk_fname_sep + str(idx_refseq) + chk_fname_sep
for f in list_f:
print("found ", f, " in ",dir_chk)
if f!=filename+".npz" and sub_s in f:
print("removing checkpoint: ",f)
os.remove(os.path.join(dir_chk,f))
print("end of RCCheckpoint.save()")
class RCCheckpoint_handler:
def __init__(self,chk_freq,dir_chk,test_mode=False):
......@@ -216,9 +219,7 @@ class RCCheckpoint_handler:
self.test_mode = test_mode
self.start_t=time.perf_counter_ns()
self.dir_chk = dir_chk
# if self.test_mode == True:
# self.v38_C5 = checkpoint_visitor_38_Cos5()
# self.v11150_C5 = checkpoint_visitor_11150_Cos5()
print("RCCheckpoint_handler starting at: ",self.start_t)
if self.test_mode==True:
if os.path.exists(dir_chk):
if not (os.path.isdir(dir_chk)):
......@@ -259,17 +260,12 @@ class RCCheckpoint_handler:
break
if chk_f != "":
interm_res=loadRCRes(os.path.join(self.dir_chk,chk_f))
# if self.test_mode==True:
# interm_res.accept(self.v38_C5)
l=chk_f.split(chk_fname_sep)
cnt_line=int(l[-2])
tmp=l[-1] # get rid of .npz extension
l2=tmp.split(".")
read_match=int(l2[0])
partial_res=RCWorkingS(interm_res,cnt_line,read_match)
# if self.test_mode:
# partial_res.accept(self.v38_C5)
# partial_res.make_visit()
return partial_res
else: # no checkpoint found for this sequence, start from beginning
return None
......@@ -282,10 +278,14 @@ class RCCheckpoint_handler:
host_whole_coverage,list_hybrid,insert,paired_mismatch,reads_tested,read_match):
cur_t = time.perf_counter_ns()
elapsed_t = cur_t - self.start_t
#convert elapsed_t tp to seconds; then minutes
elapsed_t=elapsed_t * 0.000000001
elapsed_t=elapsed_t/60
#print("check, elspsed_t in ns =",elapsed_t)
#convert elapsed_t tp to milliseconds; then minutes
#elapsed_t=elapsed_t * 0.000000001
elapsed_t=elapsed_t//1000000
elapsed_t=elapsed_t/60000
#print("check, elspsed_t in minutes=",elapsed_t)
if (self.test_mode==True or (self.chk_freq!=0 and (elapsed_t % self.chk_freq == 0))): # time to create checkpoint.
print("creating checkpoint at minute: ",elapsed_t)
chkp=RCCheckpoint(count_line,core_id,idx_seq,termini_coverage,whole_coverage,paired_whole_coverage,\
phage_hybrid_coverage, host_hybrid_coverage, \
host_whole_coverage,list_hybrid,insert,paired_mismatch,reads_tested,read_match)
......@@ -299,6 +299,7 @@ class RCCheckpoint_handler:
sub_s=base_chk_fname+str(core_id)+chk_fname_sep
for f in list_f:
if sub_s in f:
print("end : remove file :",f)
os.remove(os.path.join(self.dir_chk, f))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment