-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmiRquant.py
More file actions
60 lines (49 loc) · 1.66 KB
/
miRquant.py
File metadata and controls
60 lines (49 loc) · 1.66 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python2
import os
import sys
import argparse
import glob
from bin.utils import load_mirquant_config_file, \
load_sys_config_file, \
build_job
usage='''
miRquant is a pipeline for quantification and annotation of small RNA
sequencing data, specifically miRNAs.
'''
def check_config_path(conf_path):
'''
Make sure that configuration directory path exists
'''
if not os.path.isdir(conf_path):
print "Configuration directory does not exist at specified location"
sys.exit()
def get_fastqs(proj_dir):
'''
Get all files ending in .fastq or .fq and passes fastq to miRquant
'''
fqs = []
for type in ['*.fq', '*.fastq']:
fqs.extend(glob.glob('{}/{}'.format(proj_dir, type)))
if len(fqs) == 0:
print "No fastqs in project directory"
print "If fastqs exist, must end with extension .fq or .fastq"
sys.exit()
else:
return fqs
def main(args):
check_config_path(args.conf)
cfg = load_mirquant_config_file(args.conf)
scfg = load_sys_config_file(args.conf)
job = build_job(scfg['job'])
fastqs = get_fastqs(cfg['paths']['project'])
for sample in fastqs:
print 'Running for sample: {}'.format(sample)
os.system('{} python ./bin/chainSubmission.py {} {}'.format(job, args.conf, sample))
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description=usage,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('conf',
action='store',
help='Path to configuration directory')
main(parser.parse_args())