def parse_args(args):
"""
Takes in the command-line arguments list (args), and returns a nice argparse
result with fields for all the options.
Borrows heavily from the argparse documentation examples:
<http://docs.python.org/library/argparse.html>
"""
# Construct the parser (which is stored in parser)
# Module docstring lives in __doc__
# See http://python-forum.com/pythonforum/viewtopic.php?f=3&t=36847
# And a formatter class so our examples in the docstring look good. Isn't it
# convenient how we already wrapped it to 80 characters?
# See http://docs.python.org/library/argparse.html#formatter-class
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
# General options
parser.add_argument("--input_sam", type=argparse.FileType("r"),
default=sys.stdin,
help="input SAM in name-sorted order.")
parser.add_argument("--fq1", type=argparse.FileType("w"),
default=sys.stdout,
help="FASTQ file to save the READ1 reads in (+READ2 if interleaved)")
parser.add_argument("--fq2", type=argparse.FileType("w"),
default=sys.stdout,
help="FASTQ file to save the READ2 reads in")
parser.add_argument("--interleaved", action="store_true",
help="write interleaved FASTQ to fq1")
parser.add_argument("--drop_secondary", action="store_true",
help="drop pairs where a primary alignment is not seen at both ends")
parser.add_argument("--expect_paired", action="store_true",
help="expect all reads to have a pair partner and abort otherwise")
# The command line arguments start with the program name, which we don't
# want to treat as an argument for argparse. So we remove it.
args = args[1:]
return parser.parse_args(args)
评论列表
文章目录