Skip to content

Commit

Permalink
set enable_mhc to False for rat
Browse files Browse the repository at this point in the history
since we do not yet know the actual MHC/xMHC boundaries
  • Loading branch information
dhimmel committed Oct 14, 2021
1 parent dcef0c6 commit fafcce3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 9 additions & 3 deletions ensembl_genes/species.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Union
from typing import Optional, Union

from ensembl_genes.models import GeneForMHC

Expand All @@ -10,15 +10,18 @@ class Species:
common_name: str
reference_genome: str
ensembl_gene_pattern: str
enable_mhc: bool
mhc_chromosome: str
mhc_lower: int
mhc_upper: int
xmhc_lower: int
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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion tests/species_test.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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

0 comments on commit fafcce3

Please sign in to comment.