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

add options and way to clean all statistics

parent b36a71e2
Pipeline #30355 passed with stages
in 3 minutes and 38 seconds
......@@ -27,6 +27,10 @@ class ComputeStatistics:
raise(validation_error)
statistics.save()
def clean_db(self):
logger.info("Deleting all statistics entries...")
Statistics.objects.all().delete()
class ComputeCounts(ComputeStatistics):
METHODS = [
......@@ -102,6 +106,10 @@ class ComputeTaxonomyRepartition(ComputeStatistics):
class Command(BaseCommand):
help = "Compute gene catalog statistics."
STEP_CHOICES = ['clean', 'counts', 'gene-length', 'taxonomy']
def add_arguments(self, parser):
parser.add_argument('--only', help=f'Run only one step (choices: {self.STEP_CHOICES}).')
def set_logger_level(self, verbosity):
if verbosity > 2:
......@@ -111,6 +119,18 @@ class Command(BaseCommand):
def handle(self, *args, **options):
self.set_logger_level(int(options['verbosity']))
ComputeCounts().all()
ComputeGeneLength().all()
ComputeTaxonomyRepartition().all()
only_step = str(options['only'])
if only_step is not None:
if only_step not in self.STEP_CHOICES:
logger.warning(
"Choice '%s' is not a valid choice. Please choose among %s",
only_step, self.STEP_CHOICES
)
if only_step is None or only_step == "clean":
ComputeStatistics().clean_db()
if only_step is None or only_step == "counts":
ComputeCounts().all()
if only_step is None or only_step == "gene-length":
ComputeGeneLength().all()
if only_step is None or only_step == "taxonomy":
ComputeTaxonomyRepartition().all()
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