<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

import logging

from django.core.management.base import BaseCommand

from emgapi import models as emg_models

logger = logging.getLogger(__name__)


class EMGBaseCommand(BaseCommand):

    obj_list = list()
    rootpath = None
    accession = None

    def add_arguments(self, parser):
        parser.add_argument('accession', type=str)
        parser.add_argument('rootpath', type=str, default='')

    def handle(self, *args, **options):
        logger.info("CLI %r" % options)
        self.find_accession(options)
        self.populate_from_accession(options)

    def find_accession(self, options):
        self.accession = options.get('accession', None)
        if self.accession:
            self.obj_list = emg_models.AnalysisJob.objects \
                .filter(study__accession=self.accession).available()
            if len(self.obj_list) < 1:
                self.obj_list = emg_models.AnalysisJob.objects \
                    .filter(sample__accession=self.accession).available()
            if len(self.obj_list) < 1:
                self.obj_list = emg_models.AnalysisJob.objects \
                    .filter(accession=self.accession).available()
            if len(self.obj_list) < 1:
                logger.error(
                    "No runs %s, SKIPPING!" % self.accession)

    def populate_from_accession(self, options):
        raise NotImplementedError()
<commit_msg>find all the runs for given accession<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

import logging

from django.core.management.base import BaseCommand

from emgapi import models as emg_models

logger = logging.getLogger(__name__)


class EMGBaseCommand(BaseCommand):

    obj_list = list()
    rootpath = None
    accession = None

    def add_arguments(self, parser):
        parser.add_argument('accession', type=str)
        parser.add_argument('rootpath', type=str, default='')

    def handle(self, *args, **options):
        logger.info("CLI %r" % options)
        self.find_accession(options)
        self.populate_from_accession(options)

    def find_accession(self, options):
        self.accession = options.get('accession', None)
        if self.accession:
            self.obj_list = emg_models.AnalysisJob.objects \
                .filter(study__accession=self.accession).all()
            if len(self.obj_list) < 1:
                self.obj_list = emg_models.AnalysisJob.objects \
                    .filter(sample__accession=self.accession).all()
            if len(self.obj_list) < 1:
                self.obj_list = emg_models.AnalysisJob.objects \
                    .filter(accession=self.accession).all()
            if len(self.obj_list) < 1:
                logger.error(
                    "No runs %s, SKIPPING!" % self.accession)

    def populate_from_accession(self, options):
        raise NotImplementedError()

{'fraction_non_alphanumeric': 0.1094287680660702, 'fraction_numerical': 0.0027529249827942187, 'mean_word_length': 2.4402366863905325, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '113687', 'n_tokens_mistral': 888, 'n_tokens_neox': 846, 'n_words': 164}