Source code for capalyzer.packet_builder.sub_factories.macrobes
from .subfactory import SubFactory
from pandas import DataFrame
from json import loads
from numpy import percentile
[docs]def jloads(fname):
return loads(open(fname).read())
[docs]class MacrobeFactory(SubFactory):
[docs] def table(self):
macrobefs = self.factory.get_results(
module='quantify_macrobial',
result='tbl'
)
tbl = DataFrame.from_dict({
sname: {
taxa: vals['rpkm'] for taxa, vals in jloads(fname).items()
} for sname, fname in macrobefs
}, orient='index')
return tbl