Пример #1
0
def main():
    args = docopt(__doc__)
    #print(args)
    bam_f = args['--bam']
    include_f = args['--include']
    exclude_f = args['--exclude']
    out_prefix = args['--out']
    read_format = args['--read_format']
    if not read_format in set(['fq', 'fa']):
        sys.exit("[X] Read format must be fq or fa!")
    noninterleaved = args['--noninterleaved']
    include_unmapped = True
    if args['--exclude_unmapped']:
        include_unmapped = False
    out_f = BtIO.getOutFile(bam_f, out_prefix, None)
    if include_f and exclude_f:
        print(BtLog.error('43'))
    elif include_f:
        sequence_list = BtIO.parseList(include_f)
        BtIO.parseBamForFilter(bam_f, include_unmapped, noninterleaved, out_f, sequence_list, None, read_format)
    elif exclude_f:
        sequence_list = BtIO.parseList(exclude_f)
        BtIO.parseBamForFilter(bam_f, include_unmapped, noninterleaved, out_f, None, sequence_list, read_format)
    else:
        BtIO.parseBamForFilter(bam_f, include_unmapped, noninterleaved, out_f, None, None, read_format)
Пример #2
0
def main():
    args = docopt(__doc__)
    bam_f = args['--bam']
    include_f = args['--include']
    exclude_f = args['--exclude']
    out_prefix = args['--out']
    include_unmapped = args['--include_unmapped']
    gzip = None
    do_sort = args['--sort']
    keep_sorted = args['--keep']
    sort_threads = int(args['--threads'])
    out_f = BtIO.getOutFile(bam_f, out_prefix, None)
    if include_f and exclude_f:
        print BtLog.error('43')
    elif include_f:
        sequence_list = BtIO.parseList(include_f)
        BtIO.parseBamForFilter(bam_f, include_unmapped, out_f, sequence_list, None, gzip, do_sort, keep_sorted, sort_threads)
    elif exclude_f:
        sequence_list = BtIO.parseList(exclude_f)
        BtIO.parseBamForFilter(bam_f, include_unmapped, out_f, None, sequence_list, gzip, do_sort, keep_sorted, sort_threads)
    else:
        BtIO.parseBamForFilter(bam_f, include_unmapped, out_f, None, None, gzip, do_sort, keep_sorted, sort_threads)
Пример #3
0
def main():
    #print(data_dir)
    args = docopt(__doc__)
    blobdb_f = args['--input']
    prefix = args['--out']
    ranks = args['--rank']
    taxrule = args['--taxrule']
    hits_flag = args['--hits']
    seq_list_f = args['--list']
    concoct = args['--concoct']
    cov = args['--cov']
    notable = args['--notable']
    experimental = args['--experimental']
    # Does blobdb_f exist ?
    if not isfile(blobdb_f):
        BtLog.error('0', blobdb_f)

    out_f = BtIO.getOutFile(blobdb_f, prefix, None)

    # Are ranks sane ?
    if 'all' in ranks:
        temp_ranks = RANKS[0:-1]
        ranks = temp_ranks[::-1]
    else:
        for rank in ranks:
            if rank not in RANKS:
                BtLog.error('9', rank)

    # Does seq_list file exist?
    seqs = []
    if (seq_list_f):
        if isfile(seq_list_f):
            seqs = BtIO.parseList(seq_list_f)
        else:
            BtLog.error('0', seq_list_f)

    # Load BlobDb
    blobDb = BtCore.BlobDb('new')
    print(BtLog.status_d['9'] % (blobdb_f))
    blobDb.load(blobdb_f)
    blobDb.version = interface.__version__

    # Is taxrule sane and was it computed?
    if (blobDb.hitLibs) and taxrule not in blobDb.taxrules:
        BtLog.error('11', taxrule, blobDb.taxrules)

    # view(s)
    viewObjs = []
    print(BtLog.status_d['14'])
    if not (notable):
        tableView = None
        if len(blobDb.hitLibs) > 1:
            tableView = BtCore.ViewObj(name="table",
                                       out_f=out_f,
                                       suffix="%s.table.txt" % (taxrule),
                                       body=[])
        else:
            tableView = BtCore.ViewObj(name="table",
                                       out_f=out_f,
                                       suffix="table.txt",
                                       body=[])
        viewObjs.append(tableView)
    if not experimental == 'False':
        meta = {}
        if isfile(experimental):
            meta = BtIO.readYaml(experimental)
        experimentalView = BtCore.ExperimentalViewObj(name="experimental",
                                                      view_dir=out_f,
                                                      blobDb=blobDb,
                                                      meta=meta)
        viewObjs.append(experimentalView)
    if (concoct):
        concoctTaxView = None
        concoctCovView = None
        if len(blobDb.hitLibs) > 1:
            concoctTaxView = BtCore.ViewObj(
                name="concoct_tax",
                out_f=out_f,
                suffix="%s.concoct_taxonomy_info.csv" % (taxrule),
                body=dict())
            concoctCovView = BtCore.ViewObj(
                name="concoct_cov",
                out_f=out_f,
                suffix="%s.concoct_coverage_info.tsv" % (taxrule),
                body=[])
        else:
            concoctTaxView = BtCore.ViewObj(name="concoct_tax",
                                            out_f=out_f,
                                            suffix="concoct_taxonomy_info.csv",
                                            body=dict())
            concoctCovView = BtCore.ViewObj(name="concoct_cov",
                                            out_f=out_f,
                                            suffix="concoct_coverage_info.tsv",
                                            body=[])
        viewObjs.append(concoctTaxView)
        viewObjs.append(concoctCovView)
    if (cov):
        for cov_lib_name, covLibDict in blobDb.covLibs.items():
            out_f = BtIO.getOutFile(covLibDict['f'], prefix, None)
            covView = BtCore.ViewObj(name="covlib",
                                     out_f=out_f,
                                     suffix="cov",
                                     body=[])
            blobDb.view(viewObjs=[covView],
                        ranks=None,
                        taxrule=None,
                        hits_flag=None,
                        seqs=None,
                        cov_libs=[cov_lib_name],
                        progressbar=True)
    if (viewObjs):
        #for viewObj in viewObjs:
        #    print(viewObj.name)
        blobDb.view(viewObjs=viewObjs,
                    ranks=ranks,
                    taxrule=taxrule,
                    hits_flag=hits_flag,
                    seqs=seqs,
                    cov_libs=[],
                    progressbar=True)
    print(BtLog.status_d['19'])
Пример #4
0
    # Does blobdb_f exist ?
    if not isfile(blobdb_f):
        BtLog.error('0', blobdb_f)

    # Are ranks sane ?
    for rank in ranks:
        if rank not in RANKS:
            BtLog.error('9', rank)
    if 'all' in ranks:
        ranks = RANKS[0:-1]            

    # Is list a list of sequence names or a file?
    seqs = []
    if (seq_list):
        if isfile(seq_list):
            seqs = BtIO.parseList(seq_list)
        elif "," in seq_list:
            seqs = seq_list.split(",")
        else:
            seqs = [seq_list]

    # Load BlobDb
    blobDB = bt.BlobDb('new')
    blobDB.load(blobdb_f)

    # Is taxrule sane and was it computed?
    if (blobDB.hitLibs) and taxrule not in blobDB.taxrules:
        BtLog.error('11', taxrule, blobDB.taxrules)
    blobDB.view(out_f, ranks, taxrule, hits_flag, seqs)

Пример #5
0
    if not isfile(blobdb_f):
        BtLog.error('0', blobdb_f)

    # Are ranks sane ?
    for rank in ranks:
        if rank not in RANKS:
            BtLog.error('9', rank)
    if 'all' in ranks:
        temp_ranks = RANKS[0:-1]
        ranks = temp_ranks[::-1]           

    # Is list a list of sequence names or a file?
    seqs = []
    if (seq_list):
        if isfile(seq_list):
            seqs = BtIO.parseList(seq_list)
        elif "," in seq_list:
            seqs = seq_list.split(",")
        else:
            seqs = [seq_list]

    # Load BlobDb
    blobDB = bt.BlobDb('new')
    blobDB.load(blobdb_f)

    # Is taxrule sane and was it computed?
    if (blobDB.hitLibs) and taxrule not in blobDB.taxrules:
        BtLog.error('11', taxrule, blobDB.taxrules)
    blobDB.view(out_f, ranks, taxrule, hits_flag, seqs)