Mercurial > repos > cstrittmatter > seqsero_v2
annotate SeqSero2.py @ 0:6275272ebcbc draft
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
author | cstrittmatter |
---|---|
date | Thu, 21 Dec 2017 12:45:31 -0500 |
parents | |
children |
rev | line source |
---|---|
0
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
1 #!/usr/bin/env python |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
2 |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
3 ############################################################################ |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
4 # Copyright (c) 2014-2015 University of Georgia |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
5 # Developer: Shaokang Zhang, zskzsk@uga.edu |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
6 # All Rights Reserved |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
7 ############################################################################ |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
8 |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
9 import argparse,os,sys,time,random |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
10 |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
11 def main(): |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
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 |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
13 parser.add_argument("-i",nargs="+", help="<string>: path/to/input_data") |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
14 parser.add_argument("-b",choices=['sam','mem'],default="mem",help="<string>: 'sam'(bwa samse/sampe), 'mem'(bwa mem),default=mem") |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
15 parser.add_argument("-p",default="1",help="<int>: if p>4, only 4 threads will be used for assembly, default=1") |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
16 args=parser.parse_args() |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
17 dirpath = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
18 if len(sys.argv)==1: |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
19 os.system(dirpath+"/SeqSero2.py -h") |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
20 else: |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
21 request_id = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
22 request_id += str(random.randint(1, 10000000)) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
23 make_dir="SeqSero_result_"+request_id |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
24 os.system("mkdir "+make_dir) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
25 os.system("cp -rf "+dirpath+"/database/H_and_O_and_specific_genes.fasta "+make_dir) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
26 #mode_choice=args.m |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
27 mapping_mode=args.b |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
28 threads=args.p |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
29 dataset=args.i |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
30 os.system("cp "+dataset[0]+" "+make_dir) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
31 # print len(dataset) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
32 os.system("cp "+dataset[1]+" "+make_dir) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
33 fnameA=dataset[0].split("/")[-1] |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
34 fnameB=dataset[1].split("/")[-1] |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
35 os.chdir(make_dir) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
36 os.system("python2.7 "+dirpath+"/libs/mapping_and_assembly_hybrid.py H_and_O_and_specific_genes.fasta "+mapping_mode+" "+str(threads)+" "+fnameA+" "+fnameB) |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
37 os.system("rm H_and_O_and_specific_genes.fasta* *.bam *.sam *.fastq *.fastq.gz *.fq temp.txt *.xml "+fnameA+"*_db* 2> /dev/null") |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
38 print "Output_directory:",make_dir |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
39 #print "\n\n\nResult:\n" |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
40 #os.system("cat Seqsero_result.txt") |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
41 |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
42 if __name__ == '__main__': |
6275272ebcbc
planemo upload commit 9b152b4a900a8cd70df992da881c7e3fa00d4e4c-dirty
cstrittmatter
parents:
diff
changeset
|
43 main() |