import_igc_sequences.py 1.21 KB
Newer Older
1
2
3
4
import logging

from django.core.management.base import BaseCommand

5
from metagenedb.apps.catalog.management.commands.commons.import_gene_sequences import ImportGeneSequences
6
7
8
9
10

logging.basicConfig(format='[%(asctime)s] %(levelname)s:%(name)s:%(message)s')
logger = logging.getLogger(__name__)


11
12
class ImportIGCGeneSequences(ImportGeneSequences):
    CATALOG = "IGC"
13
14
15


class Command(BaseCommand):
16
    help = 'Add IGC gene sequences to corresponding genes.'
17
18
19
20

    def add_arguments(self, parser):
        parser.add_argument('fasta', help='IGC.fa.gz file from IGC. Genes need to exist in DB for this script to work.')
        parser.add_argument('--test', action='store_true', help='Run only on first 10000 sequences.')
21
        parser.add_argument('--skip_n', type=int, default=0, help='Number of sequence to skip')
22
23
24
25
26
27
28
29
30
31

    def set_logger_level(self, verbosity):
        if verbosity > 2:
            logger.setLevel(logging.DEBUG)
        elif verbosity > 1:
            logger.setLevel(logging.INFO)

    def handle(self, *args, **options):
        self.set_logger_level(int(options['verbosity']))
        import_igc = ImportIGCGeneSequences(options['fasta'])
32
        import_igc.load_all(test=options['test'], skip_n_sequences=options['skip_n'])