"""Submodule including some common data sets."""from..workflowsimportload_resultsfromos.pathimportsplit,joinfromnumpy.randomimportrandintimportpandasaspdimportpickle__all__=("agora","test_taxonomy")this_dir,_=split(__file__)
[docs]deftest_taxonomy(n=4):"""Create a simple test taxonomy. Parameters ---------- n : positive int How many species to include. Returns ------- pandas.DataFrame Taxonomy specification for a. """ecoli_file=join(this_dir,"e_coli_core.xml.gz")ids=["Escherichia_coli_{}".format(i)foriinrange(1,n+1)]taxa=pd.DataFrame({"id":ids})taxa["genus"]="Escherichia"taxa["species"]="Escherichia coli"taxa["reactions"]=95taxa["metabolites"]=72taxa["file"]=ecoli_filereturntaxa
deftest_data(n_samples=4,uses_db=True):"""Create a simple test data set. Parameters ---------- n_samples : positive int How many samples to include. uses_db : bool Whether the data is used with a model database. Returns ------- pandas.DataFrame Taxonomy specification for the example data. """samples=["sample_%d"%iforiinrange(1,n_samples+1)]data=[test_taxonomy()forsinsamples]fori,dinenumerate(data):d["sample_id"]=samples[i]d["species"]+=" "+d.index.astype("str")data=pd.concat(data)data["abundance"]=randint(1,1000,data.shape[0])ifuses_db:deldata["file"]returndatadeftest_results():"""Return growth results for a realistic example data sets. This will give you access to the results as produced by the community tutorial at https://github.com/micom-dev/q2-micom/tree/main/docs. Returns ------- GrowthResults The results for running the `grow` workflow with a tradeoff of 0.8. """returnload_results(join(this_dir,"artifacts","results.zip"))deftest_tradeoff():"""Return tradeoff results for a realistic example data set. This will give you access to the tradeoffs as produced by the community tutorial at https://github.com/micom-dev/q2-micom/tree/main/docs. Returns ------- pandas.DataFrame Growth rates for varying tradeoff values. """returnpd.read_csv(join(this_dir,"artifacts","crc_tradeoff.csv"),index_col=0)