

@merge(loadMetaphlanRelativeAbundances, 'metaphlan.dir/taxonomic.abundances')
def buildMetaphlanTaxonomicAbundances(infiles, outfile):
    '\n    build a file that combines taxonomic abundances \n    from each sample\n    '
    dbh = connect()
    cc = dbh.cursor()
    outf = open(outfile, 'w')
    outf.write('track\ttaxon_level\ttaxon\tabundance\tidx\n')
    for infile in infiles:
        table = P.toTable(infile)
        track = P.snip(table, '_relab')
        for data in cc.execute(('SELECT taxon_level, taxon, rel_abundance FROM %s' % table)).fetchall():
            idx = track.split('_')[1]
            outf.write(('\t'.join([track, data[0], data[1], str(data[2]), idx]) + '\n'))
    outf.close()

dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_metagenomecommunities.py buildMetaphlanTaxonomicAbundances/original