예제 #1
0
    def reverse_migrate_interpretation_request_rd_to_v3(
            json_dict, ig_json_dict):
        ig_types = [InterpretedGenomeRD_5_0_0, InterpretedGenome_6_0_0]
        ig_migrations = [
            lambda x: x,
            MigrateReports600To500().
            migrate_interpreted_genome_to_interpreted_genome_rd
        ]
        part_migrated_ig = MigrationHelpers.migrate(ig_json_dict, ig_types,
                                                    ig_migrations)
        types = [
            InterpretationRequestRD_3_0_0, InterpretationRequestRD_4_0_0,
            InterpretationRequestRD_5_0_0, InterpretationRequestRD_6_0_0,
            InterpretationRequestRD_6_0_1
        ]
        migrations = [
            lambda x: x,
            MigrateReports400To300().migrate_interpretation_request_rd,
            lambda x: MigrateReports500To400(
            ).migrate_interpretation_request_rd(x, old_ig=part_migrated_ig),
            MigrateReports600To500().migrate_interpretation_request_rd,
            MigrateReports601To600().migrate_interpretation_request_rd
        ]

        return MigrationHelpers.migrate(json_dict, types, migrations)
예제 #2
0
 def reverse_migrate_interpretation_request_cancer_to_v4(
         json_dict, ig_json_dict):
     """
     :type json_dict: dict
     :type ig_json_dict: dict
     :type assembly: Assembly
     :rtype: CancerInterpretationRequest_4_0_0
     """
     ig_types = [CancerInterpretedGenome_5_0_0, InterpretedGenome_6_0_0]
     ig_migrations = [
         lambda x: x,
         MigrateReports600To500().migrate_cancer_interpreted_genome,
     ]
     part_migrated_ig = MigrationHelpers.migrate(ig_json_dict, ig_types,
                                                 ig_migrations)
     types = [
         CancerInterpretationRequest_4_0_0,
         CancerInterpretationRequest_5_0_0,
         CancerInterpretationRequest_6_0_0
     ]
     migrations = [
         lambda x: x,
         lambda x: MigrateReports500To400().
         migrate_interpretation_request_cancer_plus_cancer_interpreted_genome(
             x, part_migrated_ig),
         MigrateReports600To500().migrate_interpretation_request_cancer,
     ]
     return MigrationHelpers.migrate(json_dict, types, migrations)
 def test_migrate_variant_call_to_called_genotype(self):
     old_instance = GenericFactoryAvro.get_factory_avro(
         self.old_model.VariantCall, VERSION_61, fill_nullables=True
     ).create()
     new_instance = MigrateReports500To400()._migrate_variant_call_to_called_genotype(variant_call=old_instance)
     self.assertTrue(isinstance(new_instance, self.new_model.CalledGenotype))
     self._validate(new_instance)
    def test_migrate_rd_interpretation_request(self, fill_nullables=True):
        old_instance = GenericFactoryAvro.get_factory_avro(
            self.old_model.InterpretationRequestRD, VERSION_61, fill_nullables=fill_nullables
        ).create(interpretationRequestVersion=1)
        old_instance.additionalInfo = {}
        old_instance.additionalInfo['cellbaseVersion'] = '1.0'
        old_instance.additionalInfo['tieringVersion'] = '1.0'
        old_instance.additionalInfo['analysisReturnUri'] = 'uri.com'

        self._validate(old_instance)
        if fill_nullables:
            self._check_non_empty_fields(old_instance)

        old_ig = GenericFactoryAvro.get_factory_avro(
            self.old_model.InterpretedGenomeRD, VERSION_61, fill_nullables=fill_nullables
        ).create(interpretationRequestVersion=1, interpretationRequestId=old_instance.interpretationRequestId)

        self._validate(old_ig)
        if fill_nullables:
            self._check_non_empty_fields(old_ig)

        new_instance = MigrateReports500To400().migrate_interpretation_request_rd(
            old_instance=old_instance, old_ig=old_ig)
        self.assertTrue(isinstance(new_instance, self.new_model.InterpretationRequestRD))
        self._validate(new_instance)
        if fill_nullables:
            self._check_variant_coordinates(
                old_variants=old_ig.variants,
                new_variants=new_instance.tieredVariants,
            )
 def test_migrate_variant_consequence_to_so_term(self):
     vc_5 = self.get_valid_object(object_type=self.old_model.VariantConsequence, version=self.version_6_1)
     so_4 = MigrateReports500To400()._migrate_variant_consequence_to_so_term(vc=vc_5)
     self.assertIsInstance(so_4, self.new_model.SoTerm)
     self.assertTrue(so_4.validate(so_4.toJsonDict()))
     self.assertEqual(so_4.name, vc_5.name)
     self.assertEqual(so_4.id, vc_5.id)
 def test_migrate_rd_exit_questionnaire(self, fill_nullables=True):
     old_instance = GenericFactoryAvro.get_factory_avro(
         self.old_model.RareDiseaseExitQuestionnaire, VERSION_61, fill_nullables=fill_nullables
     ).create()
     self._validate(old_instance)
     if fill_nullables:
         self._check_non_empty_fields(old_instance)
     new_instance = MigrateReports500To400().migrate_exit_questionnaire_rd(old_instance=old_instance)
     self.assertTrue(isinstance(new_instance, self.new_model.RareDiseaseExitQuestionnaire))
     self._validate(new_instance)
 def test_migrate_genomic_entities_to_genomic_feature_cancer(self):
     ge_5 = self.get_valid_object(object_type=self.old_model.GenomicEntity, version=self.version_6_1)
     test_ref_seq_transcript_id = "test_refSeqTranscriptId"
     test_ref_seq_protein_id = "test_refSeqProteinId"
     ge_5.otherIds["refSeqTranscriptId"] = test_ref_seq_transcript_id
     ge_5.otherIds["refSeqProteinId"] = test_ref_seq_protein_id
     gfc_4 = MigrateReports500To400()._migrate_genomic_entities_to_genomic_feature_cancer(genomic_entities=[ge_5])
     self.assertIsInstance(gfc_4, self.new_model.GenomicFeatureCancer)
     self.assertTrue(gfc_4.validate(gfc_4.toJsonDict()))
     self.assertEqual(gfc_4.refSeqProteinId, test_ref_seq_protein_id)
     self.assertEqual(gfc_4.refSeqTranscriptId, test_ref_seq_transcript_id)
    def test_migrate_cancer_interpreted_genome(self, fill_nullables=True):
        # creates a random clinical report RD for testing filling null values
        old_instance = GenericFactoryAvro.get_factory_avro(
            self.old_model.CancerInterpretedGenome, VERSION_61, fill_nullables=fill_nullables
        ).create(interpretationRequestVersion=1)

        self._validate(old_instance)
        if fill_nullables:
            self._check_non_empty_fields(old_instance)
        new_instance = MigrateReports500To400().migrate_cancer_interpreted_genome(old_instance=old_instance)
        self.assertTrue(isinstance(new_instance, self.new_model.CancerInterpretedGenome))
        self._validate(new_instance)
예제 #9
0
    def reverse_migrate_interpreted_genome_cancer_to_v4(json_dict):
        types = [
            CancerInterpretedGenome_4_0_0, CancerInterpretedGenome_5_0_0,
            InterpretedGenome_6_0_0
        ]
        migrations = [
            lambda x: x,
            MigrateReports500To400().migrate_cancer_interpreted_genome,
            MigrateReports600To500().migrate_cancer_interpreted_genome
        ]

        return MigrationHelpers.migrate(json_dict, types, migrations)
예제 #10
0
    def reverse_migrate_clinical_report_cancer_to_v4(json_dict):
        types = [
            ClinicalReportCancer_4_0_0, ClinicalReportCancer_5_0_0,
            ClinicalReport_6_0_0
        ]
        migrations = [
            lambda x: x,
            MigrateReports500To400().migrate_cancer_clinical_report,
            MigrateReports600To500().migrate_clinical_report_cancer
        ]

        return MigrationHelpers.migrate(json_dict, types, migrations)
 def test_migrate_genomic_entity_to_feature(self):
     old_entity = GenericFactoryAvro.get_factory_avro(self.old_model.GenomicEntity, VERSION_61, fill_nullables=True).create()
     entity_type = old_entity.type
     feature_type_map = {
         self.old_model.GenomicEntityType.regulatory_region: self.new_model.FeatureTypes.RegulatoryRegion,
         self.old_model.GenomicEntityType.gene: self.new_model.FeatureTypes.Gene,
         self.old_model.GenomicEntityType.transcript: self.new_model.FeatureTypes.Transcript,
     }
     expected_feature_type = feature_type_map.get(entity_type)
     new_feature = MigrateReports500To400()._migrate_genomic_entity_to_feature(old_entity)
     self.assertTrue(isinstance(new_feature, self.new_model.GenomicFeature))
     self._validate(new_feature)
     self.assertEqual(new_feature.featureType, expected_feature_type)
예제 #12
0
    def reverse_migrate_exit_questionnaire_rd_to_v3(json_dict):
        types = [
            RareDiseaseExitQuestionnaire_3_0_0,
            RareDiseaseExitQuestionnaire_4_0_0,
            RareDiseaseExitQuestionnaire_5_0_0,
            RareDiseaseExitQuestionnaire_6_0_0
        ]
        migrations = [
            lambda x: x,
            MigrateReports400To300().migrate_exit_questionnaire_rd,
            MigrateReports500To400().migrate_exit_questionnaire_rd,
            MigrateReports600To500().migrate_exit_questionnaire_rd
        ]

        return MigrationHelpers.migrate(json_dict, types, migrations)
 def test_migrate_interpretation_request_cancer_plus_cancer_interpreted_genome(self, fill_nullables=True):
     ir_c_5 = self.get_valid_object(object_type=self.old_model.CancerInterpretationRequest,
                                    version=self.version_6_1, fill_nullables=fill_nullables)
     ir_c_5.additionalInfo = {
         'interpretGenome': 'True',
         'analysisUri': 'blah.com',
         'analysisVersion': '1',
         'tieringVersion': '1'
     }
     ig_c_5 = self.get_valid_object(object_type=self.old_model.CancerInterpretedGenome,
                                    version=self.version_6_1, fill_nullables=fill_nullables)
     ir_c_4 = MigrateReports500To400().migrate_interpretation_request_cancer_plus_cancer_interpreted_genome(
         old_instance=ir_c_5, old_interpreted_genome=ig_c_5
     )
     self.assertIsInstance(ir_c_4, self.new_model.CancerInterpretationRequest)
     self.assertTrue(ir_c_4.validate(ir_c_4.toJsonDict()))
    def test_migrate_rd_clinical_report(self, fill_nullables=True):
        # creates a random clinical report RD for testing filling null values
        old_instance = GenericFactoryAvro.get_factory_avro(
            self.old_model.ClinicalReportRD, VERSION_61, fill_nullables=fill_nullables
        ).create(interpretationRequestVersion=1)

        self._validate(old_instance)
        if fill_nullables:
            self._check_non_empty_fields(old_instance)
        new_instance = MigrateReports500To400().migrate_clinical_report_rd(old_instance=old_instance)
        self.assertTrue(isinstance(new_instance, self.new_model.ClinicalReportRD))
        self._validate(new_instance)
        if fill_nullables:
            self._check_variant_coordinates(
                old_variants=old_instance.variants,
                new_variants=new_instance.candidateVariants,
            )
예제 #15
0
    def reverse_migrate_clinical_report_rd_to_v3(json_dict):
        """
        Whether html or json, the clinical report data needs to be migrated from v5 to v3 for RD
        :param json_dict: ClinicalReport RD v(6 to 3) json
        :return: ClinicalReport model object with cr.clinical_report_data migrated to v3
        """
        types = [
            ClinicalReportRD_3_0_0, ClinicalReportRD_4_0_0,
            ClinicalReportRD_5_0_0, ClinicalReport_6_0_0
        ]
        migrations = [
            lambda x: x,
            MigrateReports400To300().migrate_clinical_report_rd,
            MigrateReports500To400().migrate_clinical_report_rd,
            MigrateReports600To500().migrate_clinical_report_rd
        ]

        return MigrationHelpers.migrate(json_dict, types, migrations)
예제 #16
0
    def reverse_migrate_interpreted_genome_rd_to_v3(json_dict):
        """
        :type json_dict: dict
        :rtype: InterpretedGenomeRD_3_0_0
        """
        types = [
            InterpretedGenomeRD_3_0_0, InterpretedGenomeRD_4_0_0,
            InterpretedGenomeRD_5_0_0, InterpretedGenome_6_0_0
        ]
        migrations = [
            lambda x: x,
            MigrateReports400To300().migrate_interpreted_genome_rd,
            MigrateReports500To400().migrate_interpreted_genome_rd,
            MigrateReports600To500().
            migrate_interpreted_genome_to_interpreted_genome_rd
        ]

        return MigrationHelpers.migrate(json_dict, types, migrations)
 def test_migrate_analysis_panel(self):
     old_panel = GenericFactoryAvro.get_factory_avro(
         self.old_model.AdditionalAnalysisPanel, VERSION_61, fill_nullables=True
     ).create()
     new_panel = MigrateReports500To400()._migrate_analysis_panel(old_panel=old_panel)
     self.assertTrue(new_panel.validate(new_panel.toJsonDict()))
 def test_migrate_report_event(self):
     old_report_event = GenericFactoryAvro.get_factory_avro(self.old_model.ReportEvent, VERSION_61, fill_nullables=True).create()
     new_report_event = BaseMigration.convert_class(reports_4_0_0.ReportEvent, old_report_event)
     new_report_event = MigrateReports500To400()._migrate_report_event((old_report_event, new_report_event))
     self.assertTrue(isinstance(new_report_event, self.new_model.ReportEvent))
     self._validate(new_report_event)
 def test_migrate_reported_variant(self):
     old_reported_variant = GenericFactoryAvro.get_factory_avro(self.old_model.ReportedVariant, VERSION_61, fill_nullables=True).create()
     new_reported_variant = MigrateReports500To400()._migrate_reported_variant(old_reported_variant=old_reported_variant)
     self.assertTrue(isinstance(new_reported_variant, self.new_model.ReportedVariant))
     self._validate(new_reported_variant)
 def test_migrate_cancer_clinical_report(self, fill_nullables=True):
     cr_c_5 = self.get_valid_object(object_type=self.old_model.ClinicalReportCancer, version=self.version_6_1, fill_nullables=fill_nullables)
     cr_c_4 = MigrateReports500To400().migrate_cancer_clinical_report(old_instance=cr_c_5)
     self.assertIsInstance(cr_c_4, self.new_model.ClinicalReportCancer)
     self.assertTrue(cr_c_4.validate(cr_c_4.toJsonDict()))
 def test_migrate_reported_variant_cancer(self):
     rvc_5 = self.get_valid_object(object_type=self.old_model.ReportedVariantCancer, version=self.version_6_1)
     rvc_4 = MigrateReports500To400()._migrate_reported_variant_cancer(old_rvc=rvc_5)
     self.assertIsInstance(rvc_4, self.new_model.ReportedVariantCancer)
     self.assertTrue(rvc_4.validate(rvc_4.toJsonDict()))