-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch-bowtie2.py
38 lines (31 loc) · 1.02 KB
/
batch-bowtie2.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
from glob import glob
import re
import subprocess
import sys
import os
files = glob('/data/covid/SRR*.trim.fastq')
# determine sample names
pat = re.compile("SRR[0-9]+")
samples = [pat.findall(f)[0] for f in files]
samples = set(samples)
for sample in samples:
# skip those already processed
samfile = '/data/covid/{}.sam'.format(sample)
if samfile in files:
print('skipping {}, already processed'.format(sample))
continue
if '/data/covid/{}_1.trim.fastq'.format(sample) in files:
subprocess.check_call([
'bowtie2', '-x', 'data/NC_045512',
'-1', '/data/covid/{}_1.trim.fastq'.format(sample),
'-2', '/data/covid/{}_2.trim.fastq'.format(sample),
'-S', samfile,
'--local', '-p', '6', '--quiet'
])
else:
subprocess.check_call([
'bowtie2', '-x', 'data/NC_045512',
'-U', '/data/covid/{}.trim.fastq'.format(sample),
'-S', samfile,
'--local', '-p', '6', '--quiet'
])