def optparser():
print("Parse command line options")
# Usage and version strings
program_name = "pyssw"
program_version = 0.1
version_string = "{}\t{}".format(program_name, program_version)
usage_string = "{}.py -s subject.fasta -q fastq (or fasta) [Facultative options]".format(program_name)
optparser = optparse.OptionParser(usage = usage_string, version = version_string)
# Define optparser options
hstr = "Path of the fasta file containing the subject genome sequence. Can be gziped. [REQUIRED] "
optparser.add_option( '-s', '--subject', dest="subject", help=hstr)
hstr = "Path of the fastq or fasta file containing the short read to be aligned. Can be gziped. [REQUIRED]"
optparser.add_option( '-q', '--query', dest="query", help=hstr)
hstr = "Type of the query file = fastq or fasta. [default: fastq]"
optparser.add_option( '-t', '--qtype', dest="qtype", default="fastq", help=hstr)
hstr = "Positive integer for weight match in genome sequence alignment. [default: 2]"
optparser.add_option( '-m', '--match', dest="match",default=2, help=hstr)
hstr = "Positive integer. The negative value will be used as weight mismatch in genome sequence alignment. [default: 2]"
optparser.add_option( '-x', '--mismatch', dest="mismatch", default=2, help=hstr)
hstr = "Positive integer. The negative value will be used as weight for the gap opening. [default: 3]"
optparser.add_option( '-o', '--gap_open', dest="gap_open", default=3, help=hstr)
hstr = "Positive integer. The negative value will be used as weight for the gap opening. [default: 1]"
optparser.add_option( '-e', '--gap_extend', dest="gap_extend", default=1, help=hstr)
hstr = "Integer. Consider alignments having a score <= as not aligned. [default: 0]"
optparser.add_option( '-f', '--min_score', dest="min_score", default=0, help=hstr)
hstr = "Integer. Consider alignments having a length <= as not aligned. [default: 0]"
optparser.add_option( '-l', '--min_len', dest="min_len", default=0, help=hstr)
hstr = "Flag. Align query in forward and reverse orientation and choose the best alignment. [Set by default]"
optparser.add_option( '-r', '--reverse', dest="reverse", action="store_true", default=True, help=hstr)
hstr = "Flag. Write unaligned reads in sam output [Unset by default]"
optparser.add_option( '-u', '--unaligned', dest="unaligned", action="store_true", default=False, help=hstr)
# Parse arg and return a dictionnary_like object of options
opt, args = optparser.parse_args()
if not opt.subject:
print ("\nERROR: a subject fasta file has to be provided (-s option)\n")
optparser.print_help()
sys.exit()
if not opt.query:
print ("\nERROR: a query fasta or fastq file has to be provided (-q option)\n")
optparser.print_help()
sys.exit()
return opt
#~~~~~~~TOP LEVEL INSTRUCTIONS~~~~~~~#
评论列表
文章目录