Пример #1
0
def _read_data(
        candidate_file, json_file, patients_data, patient_id,
        mhc_database: MhcDatabase) -> Tuple[List[Neoantigen], List[Patient]]:
    # parse patient data
    patients = ModelConverter.parse_patients_file(patients_data, mhc_database)
    # parse the neoantigen candidate data
    if candidate_file is not None:
        neoantigens = ModelConverter.parse_candidate_file(
            candidate_file, patient_id)
    else:
        neoantigens = ModelConverter.parse_neoantigens_json_file(json_file)

    return neoantigens, patients
Пример #2
0
 def setUp(self):
     self.references, self.configuration = integration_test_tools.load_references(
     )
     self.references_mouse, self.configuration_mouse = integration_test_tools.load_references(
         organism=ORGANISM_MUS_MUSCULUS)
     # self.fastafile = integration_test_tools.create_temp_aminoacid_fasta_file()
     # self.runner = Runner()
     self.patient_id = "Pt29"
     input_file = pkg_resources.resource_filename(
         neofox.tests.__name__, "resources/test_candidate_file.txt")
     patients_file = pkg_resources.resource_filename(
         neofox.tests.__name__, "resources/test_patient_file.txt")
     patients_file_mouse = pkg_resources.resource_filename(
         neofox.tests.__name__, "resources/test_patient_file_mouse.txt")
     self.hla_database = self.references.get_mhc_database()
     self.h2_database = self.references_mouse.get_mhc_database()
     self.patients = ModelConverter.parse_patients_file(
         patients_file, self.hla_database)
     self.patients_mouse = ModelConverter.parse_patients_file(
         patients_file_mouse, self.h2_database)
     self.neoantigens = ModelConverter.parse_candidate_file(input_file)
     self.neoantigens_mouse = ModelConverter.parse_candidate_file(
         input_file)
Пример #3
0
 def test_neofox_only_one_neoantigen(self):
     """"""
     input_file = pkg_resources.resource_filename(
         neofox.tests.__name__, "resources/test_data_only_one.txt")
     neoantigens = ModelConverter.parse_candidate_file(input_file)
     annotations = NeoFox(
         neoantigens=neoantigens,
         patient_id=self.patient_id,
         patients=self.patients,
         num_cpus=4,
     ).get_annotations()
     self.assertEqual(1, len(annotations))
     self.assertIsInstance(annotations[0], Neoantigen)
     self.assertTrue(
         len(annotations[0].neofox_annotations.annotations) > 10)
Пример #4
0
    def test_neofox_performance_single_neoantigen(self):

        input_file = pkg_resources.resource_filename(
            neofox.tests.__name__, "resources/test_data_only_one.txt")
        neoantigens, _ = ModelConverter.parse_candidate_file(input_file)

        def compute_annotations():
            return NeoFox(
                neoantigens=neoantigens,
                patient_id=self.patient_id,
                patients=self.patients,
                num_cpus=4,
            ).get_annotations()

        print("Average time: {}".format(
            timeit.timeit(compute_annotations, number=10)))
Пример #5
0
 def test_no_expression_imputation(self):
     input_file = pkg_resources.resource_filename(
         neofox.tests.__name__, "resources/test_candidate_file.txt"
     )
     patients_file = pkg_resources.resource_filename(
         neofox.tests.__name__, "resources/test_patient_file.txt"
     )
     patients = ModelConverter.parse_patients_file(patients_file, self.hla_database)
     neoantigens = ModelConverter.parse_candidate_file(input_file)
     neofox_runner = NeoFox(
         neoantigens=neoantigens,
         patients=patients,
         reference_folder=FakeReferenceFolder(),
         configuration=FakeDependenciesConfiguration(),
     )
     for neoantigen in neoantigens:
         for neoantigen_imputed in neofox_runner.neoantigens:
             if neoantigen.mutation.mutated_xmer == neoantigen_imputed.mutation.mutated_xmer:
                 self.assertEqual(
                     neoantigen.rna_expression, neoantigen_imputed.rna_expression
                 )
Пример #6
0
    def test_with_expression_imputation(self):
        input_file = pkg_resources.resource_filename(
            neofox.tests.__name__, "resources/test_candidate_file_Pty.txt"
        )
        neoantigens= ModelConverter.parse_candidate_file(input_file)
        import copy

        original_neoantigens = copy.deepcopy(neoantigens)
        patients_file = pkg_resources.resource_filename(
            neofox.tests.__name__, "resources/test_patient_file.txt"
        )
        patients = ModelConverter.parse_patients_file(patients_file, self.hla_database)
        neofox_runner = NeoFox(
            neoantigens=neoantigens,
            patients=patients,
            reference_folder=FakeReferenceFolder(),
            configuration=FakeDependenciesConfiguration(),
        )
        for neoantigen in original_neoantigens:
            for neoantigen_imputed in neofox_runner.neoantigens:
                self.assertFalse(
                    neoantigen.rna_expression == neoantigen_imputed.rna_expression
                )