Skip to content

Commit

Permalink
Add gene symbol check in translator methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbesfeld committed Dec 12, 2024
1 parent 7d54354 commit a611b4d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/fusor/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ def _get_gene_element(self, genes: str, caller: Caller) -> GeneElement:
ge = self.fusor.gene_element(gene=gene)
return ge[0] if ge[0] else self._get_gene_element_unnormalized(gene)

def _fusion_symbol_check(self, gene_5prime: str, gene_3prime: str) -> bool:
"""Check if the normalized gene symbols for the two fusion partners
are different. If not, this event is not a fusion
:param gene_5prime: The 5' gene partner
:param gene_3prime: The 3' gene partner
:return ``True`` if the gene symbols are different, ``False`` if not
"""
if gene_5prime != gene_3prime:
return True
_logger.error(
"The supplied fusion is not valid as the two fusion partners are the same"
)
return False

def _get_genomic_ac(self, chrom: str, build: Assembly) -> str:
"""Return a RefSeq genomic accession given a chromosome and a reference build
Expand Down Expand Up @@ -190,6 +205,9 @@ async def from_jaffa(
gene_5prime = gene_5prime_element.gene.label
gene_3prime = gene_3prime_element.gene.label

if not self._fusion_symbol_check(gene_5prime, gene_3prime):
return None

tr_5prime = await self.fusor.transcript_segment_element(
tx_to_genomic_coords=False,
genomic_ac=self._get_genomic_ac(chrom1, rb),
Expand Down
9 changes: 9 additions & 0 deletions tests/test_translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ def test_gene_element_arriba(translator_instance):
assert gene.gene.label == "MIR3672"


def test_valid_fusion_partners(translator_instance):
"""Test that the fusion partners supplied to the translator are different"""
partners_check = translator_instance._fusion_symbol_check("BCR", "ABL1")
assert partners_check

partners_check = translator_instance._fusion_symbol_check("BCR", "BCR")
assert not partners_check


@pytest.mark.asyncio()
async def test_jaffa(
fusion_data_example, fusion_data_example_nonexonic, translator_instance
Expand Down

0 comments on commit a611b4d

Please sign in to comment.