-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathVerTect_cutadapt.py
83 lines (52 loc) · 2.32 KB
/
VerTect_cutadapt.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
##################################################################################
# Author: Atlas Khan ([email protected])
# Created Time: 2017-05-31
# Wang genomics lab http://wglab.org/
# Description: python script for trimming of RNA-seq data using cutadapt
##################################################################################
#!/usr/bin/env python
import sys
import argparse
import os
import subprocess
import os.path
prog="cutadapt.py"
version = """%prog
Copyright (C) 2017 Wang Genomic Lab
VerTect is free for non-commercial use without warranty.
Please contact the authors for commercial use.
Written by Atlas Khan, [email protected] and [email protected].
============================================================================
"""
usage = """usage: cutadapt.py [-h] -1 read1.fastq -2 read2.fastq -F adapt1 -R adapt2"""
def main():
parser = argparse.ArgumentParser(description='Trimming of RNA-seq data')
parser.add_argument('-1', '--fq1', required = True, metavar = 'read1.fastq', type = str, help ='The read 1 of the paired end RNA-seq')
parser.add_argument('-2', '--fq2', required = True, metavar = 'read2.fastq', type = str, help ='The read 2 of the paired end RNA-seq')
parser.add_argument('-F', '--adapt1', required = True, metavar = 'adapt1', type = str, help ='The forward adapter')
parser.add_argument('-R', '--adapt2', required = True, metavar = 'adapt2', type = str, help ='The reverse adapter')
args = parser.parse_args()
fq1 = os.path.abspath(args.fq1)
fq2 = os.path.abspath(args.fq2)
adapt1 = args.adapt1
adapt2 = args.adapt2
try:
#f1=open(fq1,'r')
os.path.isfile(fq1)
f1=open(fq1,'r')
except IOError:
print('Error: There was no Read 1 FASTQ file!')
sys.exit()
fq2 = os.path.abspath(args.fq2)
try:
#os.path.isfile(fq2)
f2=open(fq2,'r')
except IOError:
print('Error: There was no Read 2 FASTQ file!')
sys.exit()
os.system('''mkdir -p trimmed_data''')
sample1=fq1.split('.')[0]
sample2=fq2.split('.')[0]
os.system('''~/.local/bin/cutadapt -a '''+ adapt1 +''' -A '''+ adapt2 +''' -m 40 -q 20,20 -o sample1'''+'''"_trimmed_1.fq" -p sample2'''+'''"_trimmed_2.fq" '''+fq1+''' '''+ fq2 +'''''')
if __name__ == '__main__':
main()