Mercurial > repos > geoffrey.dintilhac > bam_to_bed
comparison bamtobed.py @ 0:68f7b5a4b1e2 draft
Uploaded
author | geoffrey.dintilhac |
---|---|
date | Sat, 21 Dec 2019 12:56:50 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:68f7b5a4b1e2 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import argparse | |
4 import os | |
5 | |
6 parser = argparse.ArgumentParser(description='Call bamtobed with parameters') | |
7 parser.add_argument('-i', '--inputBAM', required=True, help='input BAM file') | |
8 parser.add_argument('-o', '--outputBED', required=True, help='output BED file') | |
9 parser.add_argument('-oot', '--otherOutputType', required=True, help='Y or N') | |
10 parser.add_argument('-f', '--outputFormat', required=False, help='output file format') | |
11 parser.add_argument('-sc', '--scoreCalculation', required=True, help='calculation for BED score') | |
12 parser.add_argument('-tag', '--tag', required=False, help='another tag') | |
13 parser.add_argument('-spt', '--splitD', required=False, help='split : with "N" CIGAR and "D" operation', action="store_true") | |
14 parser.add_argument('-cgr', '--cigar', required=False, help='cigar string', action="store_true") | |
15 | |
16 args = parser.parse_args() | |
17 | |
18 # Displays the other output format if selected. | |
19 if args.otherOutputType == "Y": | |
20 print('format output chosen : ' + args.outputFormat) | |
21 | |
22 # Construction of the command line calling the tool. | |
23 myCommandLine = ('bedtools bamtobed'+' -i ' + args.inputBAM) | |
24 | |
25 # Other output format options. | |
26 if args.otherOutputType == "Y": | |
27 if args.outputFormat == "BEDPE": | |
28 myCommandLine += (' -bedpe ') | |
29 elif args.outputFormat == "BED12": | |
30 myCommandLine += (' -bed12 ') | |
31 | |
32 # Score calculation options. | |
33 if args.scoreCalculation == "ed": | |
34 myCommandLine += (' -ed ') | |
35 elif args.scoreCalculation == "tag": | |
36 myCommandLine += (' -tag ' + args.tag) | |
37 | |
38 # Split option. | |
39 if args.splitD: | |
40 myCommandLine += (' -splitD ') | |
41 print('Splitted BAM') | |
42 | |
43 # CIGAR option. | |
44 if args.cigar: | |
45 myCommandLine += (' -cigar ') | |
46 print('CIGAR string column added') | |
47 | |
48 myCommandLine += (' > ' + args.outputBED) | |
49 | |
50 # Running of the command line. | |
51 os.system(myCommandLine) | |
52 | |
53 | |
54 | |
55 |