-
Notifications
You must be signed in to change notification settings - Fork 1
/
kraken2.py
49 lines (31 loc) · 1.18 KB
/
kraken2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
import sys
import re
import glob
import subprocess
import os
digits = re.compile(r'(\d+)')
def tokenize(filename):
return tuple(int(token) if match else token
for token, match in
((fragment, digits.search(fragment))
for fragment in digits.split(filename)))
folder = sys.argv[1]
folder = os.path.expanduser(folder)
filelist=glob.glob(folder)
filelist.sort(key=tokenize)
for i in filelist:
print i;
outfolder=sys.argv[2]
subprocess.Popen("mkdir -p %s" %outfolder,shell=True).wait()
subprocess.Popen("module load kraken2",shell=True).wait()
outsuffix=sys.argv[3]
conf= sys.argv[4]
threads=sys.argv[5]
db= sys.argv[6]
for i in filelist:
print 'Processing:',i
rootname=i.split("/")[-1].split(".")[0]
outname=outfolder+"/"+rootname+outsuffix
outnohits=outfolder+"/"+rootname+outsuffix
subprocess.Popen("/stornext/System/data/apps/kraken2/kraken2-2.0.7-beta/bin/kraken2 --db %s %s --threads %s --classified-out %s_hits.fa --confidence %s --report %s.report --use-mpa-style --use-names -output %s.out --unclassified-out %s.nohit.fasta" %(db,i,threads,outname,conf,outname,outname,outnohits),shell=True).wait()