Mercurial > repos > weilong-guo > bs_seeker2
comparison BSseeker2/bs_seeker2-build.py @ 1:8b26adf64adc draft default tip
V2.0.5
author | weilong-guo |
---|---|
date | Tue, 05 Nov 2013 01:55:39 -0500 |
parents | e6df770c0e58 |
children |
comparison
equal
deleted
inserted
replaced
0:e6df770c0e58 | 1:8b26adf64adc |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/env python |
2 | 2 |
3 import os | 3 import os |
4 from optparse import OptionParser, OptionGroup | 4 from optparse import OptionParser, OptionGroup |
5 from bs_index.wg_build import * | 5 from bs_index.wg_build import * |
6 from bs_index.rrbs_build import * | 6 from bs_index.rrbs_build import * |
10 if __name__ == '__main__': | 10 if __name__ == '__main__': |
11 | 11 |
12 parser = OptionParser() | 12 parser = OptionParser() |
13 | 13 |
14 parser.add_option("-f", "--file", dest="filename", help="Input your reference genome file (fasta)", metavar="FILE") | 14 parser.add_option("-f", "--file", dest="filename", help="Input your reference genome file (fasta)", metavar="FILE") |
15 parser.add_option("--aligner", dest="aligner", help="Aligner program to perform the analysis: " + ', '.join(supported_aligners) + " [Default: %default]", metavar="ALIGNER", default = BOWTIE2) | 15 parser.add_option("--aligner", dest="aligner", help="Aligner program to perform the analysis: " + ', '.join(supported_aligners) + " [Default: %default]", metavar="ALIGNER", default = BOWTIE) |
16 parser.add_option("-p", "--path", dest="aligner_path", help="Path to the aligner program. Defaults: " +' '*70+ '\t'.join(('%s: %s '+' '*70) % (al, aligner_path[al]) for al in sorted(supported_aligners)), | 16 parser.add_option("-p", "--path", dest="aligner_path", help="Path to the aligner program. Detected: " +' '*70+ '\t'.join(('%s: %s '+' '*70) % (al, aligner_path[al]) for al in sorted(supported_aligners)), |
17 metavar="PATH") | 17 metavar="PATH") |
18 parser.add_option("-d", "--db", type="string", dest="dbpath", help="Path to the reference genome library (generated in preprocessing genome) [Default: %default]", metavar="DBPATH", default = reference_genome_path) | 18 parser.add_option("-d", "--db", type="string", dest="dbpath", help="Path to the reference genome library (generated in preprocessing genome) [Default: %default]", metavar="DBPATH", default = reference_genome_path) |
19 | 19 |
20 parser.add_option("-v", "--version", action="store_true", dest="version", help="show version of BS-Seeker2", default=False) | 20 parser.add_option("-v", "--version", action="store_true", dest="version", help="show version of BS-Seeker2", default=False) |
21 | 21 |
22 # RRBS options | 22 # RRBS options |
23 rrbs_opts = OptionGroup(parser, "Reduced Representation Bisulfite Sequencing Options", | 23 rrbs_opts = OptionGroup(parser, "Reduced Representation Bisulfite Sequencing Options", |
24 "Use this options with conjuction of -r [--rrbs]") | 24 "Use this options with conjuction of -r [--rrbs]") |
25 rrbs_opts.add_option("-r", "--rrbs", action="store_true", dest="rrbs", help = 'Build index specially for Reduced Representation Bisulfite Sequencing experiments. Genome other than certain fragments will be masked. [Default: %default]', default = False) | 25 rrbs_opts.add_option("-r", "--rrbs", action="store_true", dest="rrbs", help = 'Build index specially for Reduced Representation Bisulfite Sequencing experiments. Genome other than certain fragments will be masked. [Default: %default]', default = False) |
26 rrbs_opts.add_option("-l", "--low",type= "int", dest="low_bound", help="lower bound of fragment length (excluding recognition sequence such as C-CGG) [Default: %default]", default = 40) | 26 rrbs_opts.add_option("-l", "--low",type= "int", dest="low_bound", help="lower bound of fragment length (excluding recognition sequence such as C-CGG) [Default: %default]", default = 20) |
27 rrbs_opts.add_option("-u", "--up", type= "int", dest="up_bound", help="upper bound of fragment length (excluding recognition sequence such as C-CGG ends) [Default: %default]", default = 500) | 27 rrbs_opts.add_option("-u", "--up", type= "int", dest="up_bound", help="upper bound of fragment length (excluding recognition sequence such as C-CGG ends) [Default: %default]", default = 500) |
28 rrbs_opts.add_option("-c", "--cut-site", type= "string", dest="cut_format", help="Cut sites of restriction enzyme. Ex: MspI(C-CGG), Mael:(C-TAG), double-enzyme MspI&Mael:(C-CGG,C-TAG). [Default: %default]", default = "C-CGG") | 28 rrbs_opts.add_option("-c", "--cut-site", type= "string", dest="cut_format", help="Cut sites of restriction enzyme. Ex: MspI(C-CGG), Mael:(C-TAG), double-enzyme MspI&Mael:(C-CGG,C-TAG). [Default: %default]", default = "C-CGG") |
29 parser.add_option_group(rrbs_opts) | 29 parser.add_option_group(rrbs_opts) |
30 | 30 |
31 | 31 |
32 (options, args) = parser.parse_args() | 32 (options, args) = parser.parse_args() |
33 | 33 |
34 # if no options were given by the user, print help and exit | 34 # if no options were given by the user, print help and exit |
35 if len(sys.argv) == 1: | 35 if len(sys.argv) == 1: |
36 print parser.print_help() | 36 parser.print_help() |
37 exit(0) | 37 exit(0) |
38 | 38 |
39 if options.version : | 39 if options.version : |
40 show_version() | 40 show_version() |
41 exit (-1) | 41 exit (-1) |
42 else : | 42 else : |
43 show_version() | 43 show_version() |
44 | 44 |
45 rrbs = options.rrbs | 45 rrbs = options.rrbs |
46 | 46 |
47 fasta_file=os.path.expanduser(options.filename) | 47 if options.filename is not None : |
48 fasta_file=os.path.expanduser(options.filename) | |
49 else : | |
50 error("Please specify the genome file (Fasta) using \"-f\"") | |
51 | |
48 if fasta_file is None: | 52 if fasta_file is None: |
49 error('Fasta file for the reference genome must be supported') | 53 error('Fasta file for the reference genome must be supported') |
50 | 54 |
51 if not os.path.isfile(fasta_file): | 55 if not os.path.isfile(fasta_file): |
52 error('%s cannot be found' % fasta_file) | 56 error('%s cannot be found' % fasta_file) |
67 }[options.aligner] | 71 }[options.aligner] |
68 | 72 |
69 | 73 |
70 print "Reference genome file: %s" % fasta_file | 74 print "Reference genome file: %s" % fasta_file |
71 print "Reduced Representation Bisulfite Sequencing: %s" % rrbs | 75 print "Reduced Representation Bisulfite Sequencing: %s" % rrbs |
76 print "Short reads aligner you are using: %s" % options.aligner | |
72 print "Builder path: %s" % builder_exec | 77 print "Builder path: %s" % builder_exec |
78 | |
73 #--------------------------------------------------------------- | 79 #--------------------------------------------------------------- |
80 | |
81 if not os.path.isfile( builder_exec ) : | |
82 error("Cannot file program %s for execution." % builder_exec) | |
74 | 83 |
75 ref_path = options.dbpath | 84 ref_path = options.dbpath |
76 | 85 |
77 if os.path.exists(ref_path): | 86 if os.path.exists(ref_path): |
78 if not os.path.isdir(ref_path): | 87 if not os.path.isdir(ref_path): |