Skip to content

Commit

Permalink
feat!: change EnFusion fusion detection algorithm input parameters (#208
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jarbesfeld authored Nov 25, 2024
1 parent 4013480 commit 9ebda76
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 34 deletions.
34 changes: 22 additions & 12 deletions src/fusor/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,38 +575,48 @@ async def from_mapsplice(
return self._format_fusion(gene_5prime, gene_3prime, tr_5prime, tr_3prime, ce)

async def from_enfusion(
self, enfusion_row: pl.DataFrame, rb: Assembly
self,
gene_5prime: str,
gene_3prime: str,
chr_5prime: int,
chr_3prime: int,
break_5prime: int,
break_3prime: int,
rb: Assembly,
) -> AssayedFusion:
"""Parse EnFusion output to create AssayedFusion object
:param enfusion_row: A row of EnFusion output
:param gene_5prime: The 5' gene fusion partner
:param gene_3prime: The 3' gene fusion partner
:param chr_5prime: The 5' gene fusion partner chromosome
:param chr_3prime: The 3' gene fusion partner chromosome
:param break_5prime: The 5' gene fusion partner genomic breakpoint
:param break_3prime: The 3' gene fusion partner genomic breakpoint
:param rb: The reference build used to call the fusion
:return: An AssayedFusion object, if construction is successful
"""
gene1 = enfusion_row.get_column("Gene1").item()
gene2 = enfusion_row.get_column("Gene2").item()
gene_5prime = self._get_gene_element(gene1, "enfusion")[0].gene.label
gene_3prime = self._get_gene_element(gene2, "enfusion")[0].gene.label
gene_5prime = self._get_gene_element(gene_5prime, "enfusion")[0].gene.label
gene_3prime = self._get_gene_element(gene_3prime, "enfusion")[0].gene.label

tr_5prime = await self.fusor.transcript_segment_element(
tx_to_genomic_coords=False,
genomic_ac=self._get_genomic_ac(enfusion_row.get_column("Chr1").item(), rb),
seg_end_genomic=int(enfusion_row.get_column("Break1").item()),
genomic_ac=self._get_genomic_ac(chr_5prime, rb),
seg_end_genomic=break_5prime,
gene=gene_5prime,
get_nearest_transcript_junction=True,
)

tr_3prime = await self.fusor.transcript_segment_element(
tx_to_genomic_coords=False,
genomic_ac=self._get_genomic_ac(enfusion_row.get_column("Chr2").item(), rb),
seg_start_genomic=int(enfusion_row.get_column("Break2").item()),
genomic_ac=self._get_genomic_ac(chr_3prime, rb),
seg_start_genomic=break_3prime,
gene=gene_3prime,
get_nearest_transcript_junction=True,
)

ce = self._get_causative_event(
enfusion_row.get_column("Chr1").item(),
enfusion_row.get_column("Chr2").item(),
chr_5prime,
chr_3prime,
)
return self._format_fusion(gene_5prime, gene_3prime, tr_5prime, tr_3prime, ce)

Expand Down
50 changes: 28 additions & 22 deletions tests/test_translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,34 +472,40 @@ async def test_enfusion(
):
"""Test EnFusion translator"""
# Test exonic breakpoint
enfusion_data = pl.DataFrame(
{
"Gene1": "TPM3",
"Gene2": "PDGFRB",
"Chr1": "1",
"Break1": "154170465",
"Chr2": "5",
"Break2": "150126612",
}
)
gene_5prime = "TPM3"
gene_3prime = "PDGFRB"
chr_5prime = 1
chr_3prime = 5
break_5prime = 154170465
break_3prime = 150126612

enfusion_fusor = await translator_instance.from_enfusion(
enfusion_data, Assembly.GRCH38.value
gene_5prime,
gene_3prime,
chr_5prime,
chr_3prime,
break_5prime,
break_3prime,
Assembly.GRCH38.value,
)
assert enfusion_fusor.structure == fusion_data_example.structure

# Test non-exonic breakpoint
enfusion_data_nonexonic = pl.DataFrame(
{
"Gene1": "TPM3",
"Gene2": "PDGFRB",
"Chr1": "1",
"Break1": "154173078",
"Chr2": "5",
"Break2": "150127173",
}
)
gene_5prime = "TPM3"
gene_3prime = "PDGFRB"
chr_5prime = 1
chr_3prime = 5
break_5prime = 154173078
break_3prime = 150127173

enfusion_fusor_nonexonic = await translator_instance.from_enfusion(
enfusion_data_nonexonic, Assembly.GRCH38.value
gene_5prime,
gene_3prime,
chr_5prime,
chr_3prime,
break_5prime,
break_3prime,
Assembly.GRCH38.value,
)
assert enfusion_fusor_nonexonic.structure == fusion_data_example_nonexonic.structure

Expand Down

0 comments on commit 9ebda76

Please sign in to comment.