

@merge(loadMetaphlanReadmaps, 'metaphlan.dir/taxonomic.counts')
def countMetaphlanTaxonomicGroups(infiles, outfile):
    '\n    count the total number of species that\n    were found by metaphlan\n    '
    outf = open(outfile, 'w')
    outf.write('track\ttaxon_level\tcount\n')
    taxons = ['_order', 'class', 'family', 'genus', 'kingdom', 'phylum', 'species']
    dbh = connect()
    cc = cc.cursor()
    for infile in infiles:
        table = P.toTable(infile)
        track = P.snip(table, '_readmap')
        for taxon in taxons:
            count = cc.execute(('SELECT COUNT(DISTINCT %s) FROM %s' % (taxon, table))).fetchone()[0]
            outf.write(('\t'.join([track, taxon, str(count)]) + '\n'))
    outf.close()

dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_metagenomecommunities.py countMetaphlanTaxonomicGroups/VarMisuse@64/155 `dbh`->`cc`