From a469cde156f59221bca9c21385da2878e7f12b05 Mon Sep 17 00:00:00 2001 From: Daniel Himmelstein Date: Thu, 14 Oct 2021 13:39:21 -0700 Subject: [PATCH] set enable_mhc to False for rat since we do not yet know the actual MHC/xMHC boundaries --- ensembl_genes/species.py | 12 +++++++++--- tests/species_test.py | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ensembl_genes/species.py b/ensembl_genes/species.py index 38c07ec..d69fcba 100644 --- a/ensembl_genes/species.py +++ b/ensembl_genes/species.py @@ -1,5 +1,5 @@ from dataclasses import dataclass -from typing import Union +from typing import Optional, Union from ensembl_genes.models import GeneForMHC @@ -10,6 +10,7 @@ class Species: common_name: str reference_genome: str ensembl_gene_pattern: str + enable_mhc: bool mhc_chromosome: str mhc_lower: int mhc_upper: int @@ -17,8 +18,10 @@ class Species: xmhc_upper: int chromosomes: list[str] - def get_mhc_category(self, gene: GeneForMHC) -> str: + def get_mhc_category(self, gene: GeneForMHC) -> Optional[str]: """Assign MHC status of MHC, xMHC, or no to an ensembl gene record.""" + if not self.enable_mhc: + return None import pandas as pd chromosome: str = gene.chromosome @@ -48,6 +51,7 @@ def get_mhc_category(self, gene: GeneForMHC) -> str: ensembl_gene_pattern=r"^ENSG[0-9]{11}$", # Refs MHC boundary discussion internal Related Sciences issue 127. # https://bioinformatics.stackexchange.com/a/14719/9750 + enable_mhc=True, mhc_chromosome="6", mhc_lower=28_510_120, mhc_upper=33_480_577, @@ -65,7 +69,9 @@ def get_mhc_category(self, gene: GeneForMHC) -> str: # https://github.com/related-sciences/ensembl-genes/issues/4#issuecomment-941556912 ensembl_gene_pattern=r"^ENSRNOG[0-9]{11}$", # FIXME: mhc coordinates - mhc_chromosome="6", + # https://github.com/related-sciences/ensembl-genes/pull/6#discussion_r729259953 + enable_mhc=False, + mhc_chromosome="20", mhc_lower=28_510_120, mhc_upper=33_480_577, xmhc_lower=25_726_063, diff --git a/tests/species_test.py b/tests/species_test.py index dd789d9..02daf88 100644 --- a/tests/species_test.py +++ b/tests/species_test.py @@ -1,7 +1,7 @@ import pytest from ensembl_genes.models import GeneForMHC as Gene -from ensembl_genes.species import get_species, human +from ensembl_genes.species import get_species, human, rat def test_get_species() -> None: @@ -31,3 +31,9 @@ def test_get_species() -> None: ) def test_get_mhc_category_human(gene: Gene, category: str) -> None: assert human.get_mhc_category(gene) == category + + +def test_get_mhc_category_rat() -> None: + gene = Gene("20", 0, 0) + assert rat.enable_mhc is False + assert rat.get_mhc_category(gene) is None