Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add gene symbol check in translator methods #214

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
jarbesfeld marked this conversation as resolved.
Show resolved Hide resolved
"""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
Loading