def bam(args):
    """
    %prog snp input.gsnap ref.fasta

    Convert GSNAP output to BAM.
    """
    from jcvi.formats.sizes import Sizes
    from jcvi.formats.sam import index

    p = OptionParser(bam.__doc__)
    p.set_home("eddyyeh")
    p.set_cpus()
    opts, args = p.parse_args(args)

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

    gsnapfile, fastafile = args
    EYHOME = opts.eddyyeh_home
    pf = gsnapfile.rsplit(".", 1)[0]
    uniqsam = pf + ".unique.sam"
    samstats = uniqsam + ".stats"
    sizesfile = Sizes(fastafile).filename
    if need_update((gsnapfile, sizesfile), samstats):
        cmd = op.join(EYHOME, "gsnap2gff3.pl")
        cmd += " --format sam -i {0} -o {1}".format(gsnapfile, uniqsam)
        cmd += " -u -l {0} -p {1}".format(sizesfile, opts.cpus)
        sh(cmd)

    index([uniqsam])

    return uniqsam
def bam ( args ) : from jcvi . formats . sizes import Sizes from jcvi . formats . sam import index p = OptionParser ( bam . __doc__ ) p . set_home ( "eddyyeh" ) p . set_cpus ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) gsnapfile , fastafile = args EYHOME = opts . eddyyeh_home pf = gsnapfile . rsplit ( "." , 1 ) [ 0 ] uniqsam = pf + ".unique.sam" samstats = uniqsam + ".stats" sizesfile = Sizes ( fastafile ) . filename if need_update ( ( gsnapfile , sizesfile ) , samstats ) : cmd = op . join ( EYHOME , "gsnap2gff3.pl" ) cmd += " --format sam -i {0} -o {1}" . format ( gsnapfile , uniqsam ) cmd += " -u -l {0} -p {1}" . format ( sizesfile , opts . cpus ) sh ( cmd ) index ( [ uniqsam ] ) return uniqsam
%prog snp input.gsnap ref.fasta

    Convert GSNAP output to BAM.