From d035d8eb7bd13bc9f2dec0bdf9e38c9aa10f4f23 Mon Sep 17 00:00:00 2001 From: chartl Date: Wed, 8 Jun 2011 14:42:31 +0000 Subject: [PATCH] Updating the bam list is a bit trickier than most of us originally thought. Need to ensure that *3* files exist: the .bam, the .bai, and the finished.txt (or else bad things can happen) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5960 348d0f76-0448-11de-a6fe-93d51630548a --- python/getRecentBamList.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 python/getRecentBamList.py diff --git a/python/getRecentBamList.py b/python/getRecentBamList.py new file mode 100644 index 000000000..97f382797 --- /dev/null +++ b/python/getRecentBamList.py @@ -0,0 +1,30 @@ +import sys +import os + +in_list = sys.argv[1] +out_list = sys.argv[2] + +inp = open(in_list) +out = open(out_list,'w') + +for line in inp.readlines(): + path = line.strip() + #print(path) + tries = 0 + index = path.strip(".bam")+".bai" + finished = path.rsplit("/",1)[0]+"/finished.txt" + while ( not (os.path.exists(path) and os.path.exists(finished) and os.path.exists(index) ) and tries < 15 ): + base = path.rsplit("/",1)[0] + vers = base.rsplit("/",1)[1] + base = base.rsplit("/",1)[0] + bam = path.rsplit("/",1)[1] + vers = "v%d" % (int(vers.lstrip("v"))+1) + path = "%s/%s/%s" % (base,vers,bam) + finished = "%s/%s/%s" % (base,vers,"finished.txt") + index = path.strip(".bam")+".bai" + #print(path) + tries += 1 + if ( os.path.exists(path) and os.path.exists(finished) and os.path.exists(index) ): + out.write(path+"\n") + else: + print("No filepath on the file system contains bam, index, and finished.txt for entry "+path)