Commit d96600fc authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

add taxonomy repartition for all gene sources

parent d61bc345
Pipeline #30505 passed with stages
in 3 minutes and 15 seconds
......@@ -12,6 +12,7 @@ logger = logging.getLogger(__name__)
class ComputeStatistics:
GENE_SOURCES = ['all', 'igc', 'virgo']
def _save_to_db(self, payload):
try:
......@@ -37,7 +38,6 @@ class ComputeCounts(ComputeStatistics):
'count_all', 'count_has_function', 'count_has_taxonomy', 'count_has_function_has_taxonomy'
]
FUNCTION_SOURCES = ['kegg', 'eggnog']
GENE_SOURCES = ['all', 'igc', 'virgo']
def compute_count(self, method, gene_source, filters=None, **kwargs):
if filters is None:
......@@ -86,7 +86,6 @@ class ComputeGeneLength(ComputeStatistics):
'functions__isnull': False
},
}
GENE_SOURCES = ['all', 'igc', 'virgo']
def _compute_gene_length(self, filters, category, gene_source):
gene_stats = GeneLengthDistribution(
......@@ -118,18 +117,27 @@ class ComputeGeneLength(ComputeStatistics):
class ComputeTaxonomyRepartition(ComputeStatistics):
ALL_LEVEL = [
'kingdom', 'superkingdom', 'phylum', 'class', 'order', 'family', 'genus'
'kingdom', 'superkingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'
]
def all(self):
gene_stats = GeneStatistics()
for level in self.ALL_LEVEL:
logger.info("Call GeneStatistics.taxonomy_repartition(%s)", level)
payload = {
'stats_id': slugify(f"GeneStatistics.taxonomy_repartition-{level}"),
'body': gene_stats.taxonomy_repartition(level=level)
}
self._save_to_db(payload)
for gene_source in self.GENE_SOURCES:
if gene_source == 'all':
filters = {}
else:
filters = {'source': gene_source}
gene_stats = GeneStatistics(filters=filters)
for level in self.ALL_LEVEL:
stats_id = slugify(f"GeneStatistics({gene_source}).taxonomy_repartition({level})")
logger.info(
"Call GeneStatistics.taxonomy_repartition(%s) and saving under id <%s>",
level, stats_id
)
payload = {
'stats_id': stats_id,
'body': gene_stats.taxonomy_repartition(level=level)
}
self._save_to_db(payload)
class Command(BaseCommand):
......
......@@ -35,7 +35,7 @@ export default {
},
computed: {
selectLevel() {
return ['kingdom', 'superkingdom', 'phylum', 'class', 'order', 'family', 'genus'];
return ['kingdom', 'superkingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'];
},
geneSources() {
return [
......@@ -219,7 +219,8 @@ export default {
this.getGeneCountsFull();
},
getTaxoCounts() {
axios.get(`/api/catalog/v1/statistics/genestatistics-all-taxonomy-repartition-${this.taxLevel}`, {
var endpoint = `/api/catalog/v1/statistics/genestatistics-${this.geneSource}-taxonomy-repartition-${this.taxLevel}`;
axios.get(endpoint.toLowerCase(), {
headers: {
Accept: 'application/json',
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment