jpayne@4
|
1 #!/usr/bin/env python
|
jpayne@4
|
2
|
jpayne@4
|
3 ############################################################################
|
jpayne@4
|
4 # Copyright (c) 2014-2015 University of Georgia
|
jpayne@4
|
5 # Developer: Shaokang Zhang, zskzsk@uga.edu
|
jpayne@4
|
6 # All Rights Reserved
|
jpayne@4
|
7 ############################################################################
|
jpayne@4
|
8
|
jpayne@4
|
9 import argparse,os,sys,time,random
|
jpayne@4
|
10
|
jpayne@4
|
11 def main():
|
jpayne@4
|
12 parser = argparse.ArgumentParser(usage='SeqSero2.py -i <input_data> [-p <number of threads>] [-b <BWA_algorithm>]\n\nDevelopper: Shaokang Zhang (zskzsk@uga.edu) and Xiangyu Deng (xdeng@uga.edu)\n\nContact email:seqsero@gmail.com')#add "-m <data_type>" in future
|
jpayne@4
|
13 parser.add_argument("-i",nargs="+", help="<string>: path/to/input_data")
|
jpayne@4
|
14 parser.add_argument("-b",choices=['sam','mem'],default="mem",help="<string>: 'sam'(bwa samse/sampe), 'mem'(bwa mem),default=mem")
|
jpayne@4
|
15 parser.add_argument("-p",default="1",help="<int>: if p>4, only 4 threads will be used for assembly, default=1")
|
jpayne@4
|
16 args=parser.parse_args()
|
jpayne@4
|
17 dirpath = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
|
jpayne@4
|
18 if len(sys.argv)==1:
|
jpayne@4
|
19 os.system(dirpath+"/SeqSero2.py -h")
|
jpayne@4
|
20 else:
|
jpayne@4
|
21 request_id = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime())
|
jpayne@4
|
22 request_id += str(random.randint(1, 10000000))
|
jpayne@4
|
23 make_dir="SeqSero_result_"+request_id
|
jpayne@4
|
24 os.system("mkdir "+make_dir)
|
jpayne@4
|
25 os.system("cp -rf "+dirpath+"/database/H_and_O_and_specific_genes.fasta "+make_dir)
|
jpayne@4
|
26 #mode_choice=args.m
|
jpayne@4
|
27 mapping_mode=args.b
|
jpayne@4
|
28 threads=args.p
|
jpayne@4
|
29 dataset=args.i
|
jpayne@4
|
30 os.system("cp "+dataset[0]+" "+make_dir)
|
jpayne@4
|
31 os.system("cp "+dataset[1]+" "+make_dir)
|
jpayne@4
|
32 fnameA=dataset[0].split("/")[-1]
|
jpayne@4
|
33 fnameB=dataset[1].split("/")[-1]
|
jpayne@4
|
34 os.chdir(make_dir)
|
jpayne@4
|
35 os.system("python2.7 "+dirpath+"/libs/mapping_and_assembly_hybrid.py H_and_O_and_specific_genes.fasta "+mapping_mode+" "+str(threads)+" "+fnameA+" "+fnameB)
|
jpayne@4
|
36 os.system("rm H_and_O_and_specific_genes.fasta* *.bam *.sam *.fastq *.fastq.gz *.fq temp.txt *.xml "+fnameA+"*_db* 2> /dev/null")
|
jpayne@4
|
37 print "Output_directory:",make_dir
|
jpayne@4
|
38 #print "\n\n\nResult:\n"
|
jpayne@4
|
39 #os.system("cat Seqsero_result.txt")
|
jpayne@4
|
40
|
jpayne@4
|
41 if __name__ == '__main__':
|
jpayne@4
|
42 main()
|