def build_parser(parser):
    """
    Generate a subparser
    """
    parser.add_argument(
        'sequence_file',
        type=FileType('r'),
        help="""Input fastq file. A fasta-format file may also be provided
            if --input-qual is also specified.""")
    parser.add_argument(
        '--input-qual',
        type=FileType('r'),
        help="""The quality scores associated with the input file. Only
            used if input file is fasta.""")
    parser.add_argument(
        'output_file',
        type=FileType('w'),
        help="""Output file. Format determined from extension.""")

    output_group = parser.add_argument_group("Output")
    output_group.add_argument(
        '--report-out',
        type=FileType('w'),
        default=sys.stdout,
        help="""Output file for report [default:
            stdout]""")
    output_group.add_argument(
        '--details-out',
        type=FileType('w'),
        help="""Output file to report fate of each sequence""")
    output_group.add_argument(
        '--no-details-comment',
        action='store_false',
        default=True,
        dest='details_comment',
        help="""Do not write comment
            lines with version and call to start --details-out""")

    parser.add_argument(
        '--min-mean-quality',
        metavar='QUALITY',
        type=float,
        default=DEFAULT_MEAN_SCORE,
        help="""Minimum mean quality score for
            each read [default: %(default)s]""")
    parser.add_argument(
        '--min-length',
        metavar='LENGTH',
        type=int,
        default=200,
        help="""Minimum length to keep sequence [default:
            %(default)s]""")
    parser.add_argument(
        '--max-length',
        metavar='LENGTH',
        type=int,
        default=1000,
        help="""Maximum length to keep before truncating
            [default: %(default)s]. This operation occurs before
            --max-ambiguous""")

    window_group = parser.add_argument_group('Quality window options')
    window_group.add_argument(
        '--quality-window-mean-qual',
        type=float,
        help="""Minimum quality score within the window defined by
            --quality-window. [default: same as --min-mean-quality]""")
    window_group.add_argument(
        '--quality-window-prop',
        help="""Proportion of
            reads within quality window to that must pass filter. Floats are [default:
            %(default).1f]""",
        default=1.0,
        type=typed_range(float, 0.0, 1.0))
    window_group.add_argument(
        '--quality-window',
        type=int,
        metavar='WINDOW_SIZE',
        default=0,
        help="""Window size for truncating sequences.  When set
            to a non-zero value, sequences are truncated where the mean mean
            quality within the window drops below --min-mean-quality.
            [default: %(default)s]""")

    parser.add_argument(
        '--ambiguous-action',
        choices=('truncate', 'drop'),
        help="""Action to take on ambiguous base in sequence (N's).
            [default: no action]""")
    parser.add_argument(
        '--max-ambiguous',
        default=None,
        help="""Maximum number
            of ambiguous bases in a sequence. Sequences exceeding this count
            will be removed.""",
        type=int)
    parser.add_argument(
        '--pct-ambiguous',
        help="""Maximun percent of
            ambiguous bases in a sequence.  Sequences exceeding this percent
            will be removed.""",
        type=float)

    barcode_group = parser.add_argument_group('Barcode/Primer')
    primer_group = barcode_group.add_mutually_exclusive_group()
    primer_group.add_argument(
        '--primer', help="""IUPAC ambiguous primer to
            require""")
    primer_group.add_argument(
        '--no-primer',
        help="""Do not use a primer.""",
        action='store_const',
        const='',
        dest='primer')
    barcode_group.add_argument(
        '--barcode-file',
        help="""CSV file containing
            sample_id,barcode[,primer] in the rows. A single primer for all
            sequences may be specified with `--primer`, or `--no-primer` may be
            used to indicate barcodes should be used without a primer
            check.""",
        type=FileType('r'))
    barcode_group.add_argument(
        '--barcode-header',
        action='store_true',
        default=False,
        help="""Barcodes have a header row [default:
            %(default)s]""")
    barcode_group.add_argument(
        '--map-out',
        help="""Path to write
            sequence_id,sample_id pairs""",
        type=FileType('w'),
        metavar='SAMPLE_MAP')
    barcode_group.add_argument(
        '--quoting',
        help="""A string naming an
            attribute of the csv module defining the quoting behavior for
            `SAMPLE_MAP`.  [default: %(default)s]""",
        default='QUOTE_MINIMAL',
        choices=[s for s in dir(csv) if s.startswith('QUOTE_')])