annotate SeqSero/SeqSero.py @ 4:ab0802d77891 draft default tip

Uploaded
author estrain
date Thu, 12 Sep 2019 06:46:00 -0400
parents c577b57b7c74
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
1 #!/usr/bin/env python
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
2
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
3 ############################################################################
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
4 # Copyright (c) 2014-2015 University of Georgia
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
5 # All Rights Reserved
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
6 ############################################################################
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
7
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
8 import argparse,os,sys,time,random
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
9
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
10 def main():
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
11 parser = argparse.ArgumentParser(usage='SeqSero.py -m <data_type> -i <input_data> [-b <BWA_algorithm>]\n\nDevelopper: Shaokang Zhang (zskzsk@uga.edu) and Xiangyu Deng (xdeng@uga.edu)\n\nContact email:seqsero@gmail.com')
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
12 parser.add_argument("-m", choices=['1','2','3', '4'],help="<int>: '1'(pair-end reads, interleaved),'2'(pair-end reads, seperated),'3'(single-end reads), '4'(assembly)")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
13 parser.add_argument("-i", nargs="+", help="<string>: path/to/input_data")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
14 parser.add_argument("-b",choices=['sam','mem','nanopore'],default="sam",help="<string>: 'sam'(bwa samse/sampe), 'mem'(bwa mem), default=sam")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
15 args=parser.parse_args()
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
16 dirpath = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
17 if len(sys.argv)==1:
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
18 os.system(dirpath+"/SeqSero.py -h")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
19 else:
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
20 request_id = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime())
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
21 request_id += str(random.randint(1, 10000000))
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
22 make_dir="SeqSero_result_"+request_id
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
23 os.system("mkdir "+make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
24 os.system("cp -rf "+dirpath+"/database "+make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
25 mode_choice=args.m
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
26 mapping_mode=args.b
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
27 dataset=args.i
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
28 if mode_choice=="1":
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
29 print dataset[0]
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
30 os.system("cp "+dataset[0]+" "+make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
31 os.chdir(make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
32 os.system("python2.7 "+dirpath+"/libs/run_auto_All_for_web_multi_revise.py "+dataset[0].split("/")[-1]+" "+mapping_mode+" 1")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
33 print "\n\n\nResult:\n"
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
34 os.system("cat Seqsero_result.txt")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
35 os.system("rm "+dataset[0].split("/")[-1])
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
36 elif mode_choice=="2":
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
37 os.system("cp "+dataset[0]+" "+make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
38 os.system("cp "+dataset[1]+" "+make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
39 fnameA=dataset[0].split("/")[-1]
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
40 fnameB=dataset[1].split("/")[-1]
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
41 os.chdir(make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
42 print "check fastq id and make them in accordance with each other...please wait..."
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
43 os.system("python2.7 "+dirpath+"/libs/run_auto_All_for_web_multi_revise.py "+fnameA+" "+mapping_mode+" "+fnameB+" 2")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
44 print "\n\n\nResult:\n"
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
45 os.system("cat Seqsero_result.txt")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
46 elif mode_choice=="3":
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
47 os.system("cp "+dataset[0]+" "+make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
48 os.chdir(make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
49 os.system("python2.7 "+dirpath+"/libs/run_auto_All_for_web_multi_revise.py "+dataset[0].split("/")[-1]+" "+mapping_mode+" 3")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
50 print "\n\n\nResult:\n"
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
51 os.system("cat Seqsero_result.txt")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
52 elif mode_choice=="4":
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
53 os.system("cp "+dataset[0]+" "+make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
54 os.chdir(make_dir)
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
55 os.system("python2.7 "+dirpath+"/libs/run_auto_All_for_assemblies.py "+dataset[0].split("/")[-1])
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
56 print "\n\n\nResult:\n"
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
57 os.system("cat Seqsero_result.txt")
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
58
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
59 if __name__ == '__main__':
c577b57b7c74 Uploaded
estrain
parents:
diff changeset
60 main()