Skip to content

Commit

Permalink
fix: MANE Summary data >= v1.1 updated GRCh38_chr (#149) (#150)
Browse files Browse the repository at this point in the history
- < v1.1 used 1...22, X, Y. >= v1.1 uses NC accessions
  • Loading branch information
korikuzma authored May 1, 2023
1 parent 28f3e9c commit a5617d0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions cool_seq_tool/data_sources/mane_transcript_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ def get_mane_from_transcripts(self, transcripts: List[str]) -> List[Dict]:
return []
return result.to_dict("records")

def get_mane_data_from_chr_pos(self, chromosome: str, start: int,
end: int) -> List[Dict]:
def get_mane_data_from_chr_pos(
self, alt_ac: str, start: int, end: int
) -> List[Dict]:
"""Get MANE data given chromosome, start pos, end end pos. Assumes GRCh38.
:param str chromosome: Chromosome. Case sensitive for X, Y chromosomes.
Do not prefix. Valid examples: "1" ... "22", "X", "Y"
:param str alt_ac: NC Accession
:param int start: Start genomic position. Assumes residue coordinates.
:param int end: End genomic position. Assumes residue coordinates.
:return: List of MANE data. Will return sorted list:
MANE Select then MANE Plus Clinical.
"""
mane_rows = self.df[(start >= self.df["chr_start"].astype(int)) & (end <= self.df["chr_end"].astype(int)) & (self.df["GRCh38_chr"] == chromosome)] # noqa: E501
mane_rows = self.df[(start >= self.df["chr_start"].astype(int)) & (end <= self.df["chr_end"].astype(int)) & (self.df["GRCh38_chr"] == alt_ac)] # noqa: E501
if len(mane_rows) == 0:
return []
mane_rows = mane_rows.sort_values("MANE_status", ascending=False)
Expand Down
2 changes: 1 addition & 1 deletion cool_seq_tool/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.12"
__version__ = "0.1.13"
18 changes: 9 additions & 9 deletions tests/unit/test_mane_transcript_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def braf_select():
"Ensembl_nuc": "ENST00000646891.2",
"Ensembl_prot": "ENSP00000493543.1",
"MANE_status": "MANE Select",
"GRCh38_chr": "7",
"GRCh38_chr": "NC_000007.14",
"chr_start": 140730665,
"chr_end": 140924929,
"chr_strand": "-"
Expand All @@ -45,7 +45,7 @@ def braf_plus_clinical():
"Ensembl_nuc": "ENST00000644969.2",
"Ensembl_prot": "ENSP00000496776.1",
"MANE_status": "MANE Plus Clinical",
"GRCh38_chr": "7",
"GRCh38_chr": "NC_000007.14",
"chr_start": 140719337,
"chr_end": 140924929,
"chr_strand": "-"
Expand All @@ -66,7 +66,7 @@ def ercc6_plus_clinical():
"Ensembl_nuc": "ENST00000447839.7",
"Ensembl_prot": "ENSP00000387966.2",
"MANE_status": "MANE Plus Clinical",
"GRCh38_chr": "10",
"GRCh38_chr": "NC_000010.11",
"chr_start": 49515198,
"chr_end": 49539121,
"chr_strand": "-"
Expand All @@ -87,7 +87,7 @@ def ercc6_select():
"Ensembl_nuc": "ENST00000355832.10",
"Ensembl_prot": "ENSP00000348089.5",
"MANE_status": "MANE Select",
"GRCh38_chr": "10",
"GRCh38_chr": "NC_000010.11",
"chr_start": 49454470,
"chr_end": 49539121,
"chr_strand": "-"
Expand Down Expand Up @@ -159,12 +159,12 @@ def test_get_mane_data_from_chr_pos(test_mane_transcript_mappings, braf_select,
braf_plus_clinical):
"""Test that get_mane_data_from_chr_pos method works correctly"""
resp = test_mane_transcript_mappings.get_mane_data_from_chr_pos(
"7", 140753336, 140753336)
"NC_000007.14", 140753336, 140753336)
assert len(resp) == 2
assert resp == [braf_select, braf_plus_clinical]

resp = test_mane_transcript_mappings.get_mane_data_from_chr_pos(
"X", 37994300, 37994310)
"NC_000023.11", 37994300, 37994310)
assert len(resp) == 1
assert resp == [{
"#NCBI_GeneID": "GeneID:115482686",
Expand All @@ -177,13 +177,13 @@ def test_get_mane_data_from_chr_pos(test_mane_transcript_mappings, braf_select,
"Ensembl_nuc": "ENST00000448797.3",
"Ensembl_prot": "ENSP00000498087.1",
"MANE_status": "MANE Select",
"GRCh38_chr": "X",
"GRCh38_chr": "NC_000023.11",
"chr_start": 37994272,
"chr_end": 37994904,
"chr_strand": "+"
}]

# Invalid chromosome
# Invalid alt_ac (no version)
resp = test_mane_transcript_mappings.get_mane_data_from_chr_pos(
"x", 37994300, 37994310)
"NC_000023", 37994300, 37994310)
assert resp == []

0 comments on commit a5617d0

Please sign in to comment.