<commit_before>import sys
from django.core.exceptions import ObjectDoesNotExist
from django.core.management.base import BaseCommand
from xbrowse_server.base.models import Project, ProjectTag, VariantTag, Individual
from xbrowse_server.mall import get_mall
from xbrowse import genomeloc


class Command(BaseCommand):
    """Command to print out basic stats on some or all projects. Optionally takes a list of project_ids. """

    def handle(self, *args, **options):
        if len(args) < 2:
            print("Please provide the project_id and individual_id as command line args")
            return

        project_id = args[0]

        individual_id = args[1]
        
        try:
            project = Project.objects.get(project_id=project_id)
        except ObjectDoesNotExist:
            sys.exit("Invalid project id: " + project_id)
            
        try:
            individual = Individual.objects.get(project=project, indiv_id=individual_id)
        except ObjectDoesNotExist:
            sys.exit("Invalid individual id: " + individual_id)

        genotype_map = {0: "ref", 1: "het", 2: "hom"}
        with open("report_for_%s_%s.txt" % (project_id, individual_id), "w") as out:
            header = ["gene_name", "genotype", "variant", "hgvs_c", "hgvs_p", "rsid", "exac_af_all", "exac_af_pop_max", "clinvar_clinsig", "comments"]
            print("\t".join(header))
            out.write("\t".join(header) + "\n")

            # get variants that have been tagged
            for variant_tag in VariantTag.objects.filter(project_tag__project=project):  #, project_tag__tag="report"):<commit_msg>Only report variants tagged with 'report' tag<commit_after>import sys
from django.core.exceptions import ObjectDoesNotExist
from django.core.management.base import BaseCommand
from xbrowse_server.base.models import Project, ProjectTag, VariantTag, Individual
from xbrowse_server.mall import get_mall
from xbrowse import genomeloc


class Command(BaseCommand):
    """Command to print out basic stats on some or all projects. Optionally takes a list of project_ids. """

    def handle(self, *args, **options):
        if len(args) < 2:
            print("Please provide the project_id and individual_id as command line args")
            return

        project_id = args[0]

        individual_id = args[1]
        
        try:
            project = Project.objects.get(project_id=project_id)
        except ObjectDoesNotExist:
            sys.exit("Invalid project id: " + project_id)
            
        try:
            individual = Individual.objects.get(project=project, indiv_id=individual_id)
        except ObjectDoesNotExist:
            sys.exit("Invalid individual id: " + individual_id)

        genotype_map = {0: "ref", 1: "het", 2: "hom"}
        with open("report_for_%s_%s.txt" % (project_id, individual_id), "w") as out:
            header = ["gene_name", "genotype", "variant", "hgvs_c", "hgvs_p", "rsid", "exac_af_all", "exac_af_pop_max", "clinvar_clinsig", "comments"]
            print("\t".join(header))
            out.write("\t".join(header) + "\n")

            # get variants that have been tagged
            for variant_tag in VariantTag.objects.filter(project_tag__project=project, project_tag__tag="report"):
{'fraction_non_alphanumeric': 0.10715382253607614, 'fraction_numerical': 0.00368437212158428, 'mean_word_length': 2.9877600979192165, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1565247', 'n_tokens_mistral': 988, 'n_tokens_neox': 946, 'n_words': 253}