def stutter(args):
    """
    %prog stutter a.vcf.gzi sample_id

    Extract info from lobSTR vcf file. Generates a file that has the following
    fields:

    CHR, POS, MOTIF, RL, ALLREADS, Q
    """
    p = OptionParser(stutter.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    vcf, = args
    pf = op.basename(vcf).split(".")[0]
    execid, sampleid = pf.split("_")

    C = "vcftools --remove-filtered-all --min-meanDP 10"
    C += " --gzvcf {} --out {}".format(vcf, pf)
    C += " --indv {}".format(sampleid)

    info = pf + ".INFO"
    if need_update(vcf, info):
        cmd = C + " --get-INFO MOTIF --get-INFO RL"
        sh(cmd)

    allreads = pf + ".ALLREADS.FORMAT"
    if need_update(vcf, allreads):
        cmd = C + " --extract-FORMAT-info ALLREADS"
        sh(cmd)

    q = pf + ".Q.FORMAT"
    if need_update(vcf, q):
        cmd = C + " --extract-FORMAT-info Q"
        sh(cmd)

    outfile = pf + ".STUTTER"
    if need_update((info, allreads, q), outfile):
        cmd = "cut -f1,2,5,6 {}".format(info)
        cmd += r" | sed -e 's/\t/_/g'"
        cmd += " | paste - {} {}".format(allreads, q)
        cmd += " | cut -f1,4,7"
        sh(cmd, outfile=outfile)
dataset/ETHPy150Open tanghaibao/jcvi/variation/str.py/stutter/original