From 1a0df5008499ecb9bc7e375397d2690c5583e1dc Mon Sep 17 00:00:00 2001 From: Pablo Riesgo Ferreiro Date: Fri, 16 Dec 2022 15:55:59 +0100 Subject: [PATCH] make RNA VAF as default instead of DNA VAF --- neofox/published_features/expression.py | 4 ++-- neofox/tests/unit_tests/test_expression.py | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/neofox/published_features/expression.py b/neofox/published_features/expression.py index 9045384d..ce687805 100755 --- a/neofox/published_features/expression.py +++ b/neofox/published_features/expression.py @@ -46,9 +46,9 @@ def _get_expression_annotation( def get_annotations(self, neoantigen: Neoantigen) -> List[Annotation]: - vaf = neoantigen.dna_variant_allele_frequency + vaf = neoantigen.rna_variant_allele_frequency if vaf is None or vaf == -1: - vaf = neoantigen.rna_variant_allele_frequency + vaf = neoantigen.dna_variant_allele_frequency return [ AnnotationFactory.build_annotation( diff --git a/neofox/tests/unit_tests/test_expression.py b/neofox/tests/unit_tests/test_expression.py index 9c20b5d4..dcd54f63 100755 --- a/neofox/tests/unit_tests/test_expression.py +++ b/neofox/tests/unit_tests/test_expression.py @@ -19,7 +19,7 @@ from unittest import TestCase -from neofox.model.factories import NOT_AVAILABLE_VALUE +from neofox.model.factories import NOT_AVAILABLE_VALUE, NeoantigenFactory from neofox.model.neoantigen import Neoantigen from neofox.published_features.expression import Expression @@ -30,20 +30,28 @@ def setUp(self) -> None: self.expression = Expression() def test_calculate_expression_mutation(self): - neoantigen = Neoantigen(rna_expression=12.0, dna_variant_allele_frequency=0.2) + neoantigen = NeoantigenFactory.build_neoantigen( + rna_expression=12.0, dna_variant_allele_frequency=0.2, patient_identifier="patient1", + mutated_xmer="DDDDD") result = self.expression.get_annotations(neoantigen=neoantigen)[0] - self.assertGreater(result.value, "0.0") + self.assertGreater(float(result.value), 0.0) # no reads for mut - neoantigen = Neoantigen(rna_expression=12.0, dna_variant_allele_frequency=0.0) + neoantigen = NeoantigenFactory.build_neoantigen( + rna_expression=12.0, dna_variant_allele_frequency=0.0, patient_identifier="patient1", + mutated_xmer="DDDDD") result = self.expression.get_annotations(neoantigen=neoantigen)[0] self.assertEqual(result.value, "0") # no reads for mut/wt - neoantigen = Neoantigen(rna_expression=12.0, dna_variant_allele_frequency=-1, rna_variant_allele_frequency=-1) + neoantigen = NeoantigenFactory.build_neoantigen( + rna_expression=12.0, dna_variant_allele_frequency=-1, rna_variant_allele_frequency=-1, patient_identifier="patient1", + mutated_xmer="DDDDD") result = self.expression.get_annotations(neoantigen=neoantigen)[0] self.assertEqual(result.value, NOT_AVAILABLE_VALUE) - neoantigen = Neoantigen(rna_expression=None, dna_variant_allele_frequency=-1, rna_variant_allele_frequency=-1) + neoantigen = NeoantigenFactory.build_neoantigen( + rna_expression=None, dna_variant_allele_frequency=-1, rna_variant_allele_frequency=-1, + patient_identifier="patient1", mutated_xmer="DDDDD") result = self.expression.get_annotations(neoantigen=neoantigen)[0] self.assertEqual(result.value, NOT_AVAILABLE_VALUE)