-
Notifications
You must be signed in to change notification settings - Fork 6
/
GC_bias.py
41 lines (40 loc) · 1.98 KB
/
GC_bias.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
import sys,os
import random
import string
from math import log,exp
from optparse import OptionParser
import getopt
import time
def main():
usage = """%prog -i <file> -g <GC_file> -b <name_sort_sam file> -o <out_fastq> -m <mode> -k <y/n>
GC v1.0.1
Author: Yuchao Xia
Description: accord GC content to filter paired-end reads from name sorted simulate bam file.
"""
parser = OptionParser(usage)
parser.add_option("-i", "--inFile", dest="inFile", help="A reference fasta file.",metavar="FILE")
parser.add_option("-g","--GC",dest='input_GC',help='GC_function file,splited by \t,the filst col is GC content',metavar="FILE")
parser.add_option("-b","--bam",dest='input_sam',help='the name sorted sam/bam format file generated by ART ',metavar="FILE")
parser.add_option('-o','--output',dest='output',help='output fastq file',metavar="file")
parser.add_option('-k','--keepsam',dest='keepsam',help='generate sam file',metavar='y/n')
parser.add_option('-m','--mode',dest='mode',help='the function of GC content',metavar='int')
(opts, args) = parser.parse_args()
if opts.keepsam is None:
keepsam='n'
else:
keepsam=opts.keepsam
if opts.input_GC is None:
input_GC='GC_content.txt'
else:
input_GC=opts.input_GC
if int(opts.mode)==1:
cmd='python GC_v1.0.1.py -i '+opts.inFile+' -g '+input_GC+' -b '+opts.input_sam+' -o '+opts.output+' -k '+keepsam+' -m '+opts.mode
elif int(opts.mode)==2:
cmd='python GC_v1.0.2.py -i '+opts.inFile+' -g '+input_GC+' -b '+opts.input_sam+' -o '+opts.output+' -k '+keepsam+' -m '+opts.mode
elif int(opts.mode)==2:
cmd='python GC_v1.0.3.py -i '+opts.inFile+' -g '+input_GC+' -b '+opts.input_sam+' -o '+opts.output+' -k '+keepsam+' -m '+opts.mode
else:
cmd='python GC_v1.0.4.py -i '+opts.inFile+' -g '+input_GC+' -b '+opts.input_sam+' -o '+opts.output+' -k '+keepsam+' -m '+opts.mode
os.system(cmd)
if __name__ == "__main__":
main()