diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index 1deaecbd..9e587fe9 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -76,6 +76,11 @@ def process_scope_r209(karyo, genocolorectal, _moleculartestingtype) end def process_scope_r210(karyo, genocolorectal, moleculartestingtype) + if karyo.downcase.match(/r240.1\s::\sdiagnostic\sfamilial/) + karyo='R240.1 :: Diagnostic familial' + elsif karyo.downcase.match(/r242.1\s::\spredictive\stesting/) + karyo='R242.1 :: Predictive testing' + end if R210_PANEL_GENE_MAPPING_FS.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" genocolorectal.add_test_scope(:full_screen) @@ -123,6 +128,16 @@ def process_scope_r414(karyo, genocolorectal, moleculartestingtype) end end + def process_scope_r216(karyo, genocolorectal, moleculartestingtype) + if R216_PANEL_GENE_MAPPING_FS.keys.include? karyo + @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" + genocolorectal.add_test_scope(:full_screen) + @genes_set = R216_PANEL_GENE_MAPPING_FS[karyo] + else + genocolorectal.add_test_scope(:no_genetictestscope) + end + end + def process_scope_fap_familial(karyo, genocolorectal, _moleculartestingtype) if FAP_FAM_PANEL_GENE_MAPPING_TAR.keys.include? karyo @logger.debug "ADDED TARGETED TEST for: #{karyo}" @@ -183,10 +198,33 @@ def process_scope_colo_ovarian_panel(karyo, genocolorectal, _moleculartestingtyp end def add_test_type(genocolorectal, record) - moltestingtype = record.raw_fields['moleculartestingtype'] + karyo = record.raw_fields['karyotypingmethod'].strip + moleculartestingtype = record.raw_fields['moleculartestingtype'].strip.downcase + + test_type = determine_test_type(moleculartestingtype, karyo) + genocolorectal.add_molecular_testing_type_strict(test_type) if test_type + end + + def determine_test_type(moleculartestingtype, karyo) + # First priority: moleculartestingtype + return TEST_TYPE_MAPPING_COLO[moleculartestingtype] if TEST_TYPE_MAPPING_COLO.key?(moleculartestingtype) + return :predictive if moleculartestingtype.match?(/unaffected/i) - genocolorectal.add_molecular_testing_type_strict(TEST_TYPE_MAPPING_COLO[moltestingtype. - downcase]) + # Second priority: karyo R-number patterns + test_type_from_karyo(karyo) + end + + def test_type_from_karyo(karyo) + case karyo + when /^R(240|205|206|207|208|209|210|211|430|444|216|414|370)/ + :diagnostic + when /^R242/ + :predictive + when /^R(244|246)/ + :carrier + when /^R448/ + :prenatal + end end def process_variants_from_record(genocolorectal, record) @@ -276,11 +314,10 @@ def process_normal_full_screen(genocolorectal, genocolorectals) negative_genes = @genes_set if !negative_genes.empty? add_other_genes_with_status(negative_genes, genocolorectal, genocolorectals, 1) - else + else genocolorectals.append(genocolorectal) end - - + genocolorectals end diff --git a/lib/import/helpers/colorectal/providers/rcu/constants.rb b/lib/import/helpers/colorectal/providers/rcu/constants.rb index b2877619..78cd0e91 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -48,8 +48,7 @@ module Constants 'r218 :: multiple endocrine neoplasia type 2', 'r365 :: fumarate hydratase-related tumour syndromes - sdgs', 'r240 - familial diagnostic testing - hered cancers', - 'r206 :: inherited breast cancer and ovarian cancer at high familial risk levels', - 'r216 :: li fraumeni syndrome - sdgs' + 'r206 :: inherited breast cancer and ovarian cancer at high familial risk levels' ].freeze GENETICTESTSCOPE_METHOD_MAPPING = { @@ -57,14 +56,17 @@ module Constants 'r209 :: inherited colorectal cancer '\ '(with or without polyposis)' => :process_scope_r209, 'r210 :: inherited mmr deficiency (lynch syndrome)' => :process_scope_r210, + 'r210' => :process_scope_r210, 'r211 :: inherited polyposis - germline test' => :process_scope_r211, + 'r211' => :process_scope_r211, 'fap' => :process_scope_fap, 'fap familial mutation' => :process_scope_fap_familial, 'hnpcc' => :process_scope_hnpcc, 'myh' => :process_scope_myh, 'breast ovarian & colorectal cancer panel' => :process_scope_colo_ovarian_panel, 'r211 :: inherited polyposis and early onset colorectal cancer, germline testing'=> :process_scope_r211, - 'r414 :: apc associated polyposis'=> :process_scope_r414 + 'r414 :: apc associated polyposis'=> :process_scope_r414, + 'r216 :: li fraumeni syndrome - sdgs' => :process_scope_r216 }.freeze COLO_PANEL_GENE_MAPPING_FS = { @@ -117,18 +119,18 @@ module Constants 'R210.2 :: Small panel in Leeds' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM], 'R210.2 :: Unknown mutation(s) by Small panel' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM], 'R210.5 :: Unknown mutation(s) by MLPA or equivalent' => %w[MLH1 MSH2 EPCAM], - 'R210.1 :: Unknown mutation(s) by Microsatellite instability'=> %w[MLH1 MSH2 MSH6 PMS2 EPCAM], - 'R210.2 :: Small panel in Leeds - Send DNA'=> %w[MLH1 MSH2 MSH6 PMS2 EPCAM] + 'R210.1 :: Unknown mutation(s) by Microsatellite instability' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM], + 'R210.2 :: Small panel in Leeds - Send DNA' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM], + 'R210.2 :: Small panel in Leeds - DNA in Newcastle' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM] }.freeze R210_PANEL_GENE_MAPPING_TAR = { 'R240.1 :: Diagnostic familial' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM], 'R242.1 :: Predictive MLPA' => %w[MLH1 MSH2 EPCAM], 'R242.1 :: Predictive testing' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM], - 'R242.1 :: Predictive testing - MLPA in Leeds - Send Blood'=> %w[MLH1 MSH2 MSH6 PMS2 EPCAM], - 'R242.1 :: Predictive testing - MLPA in Leeds - Send DNA'=> %w[MLH1 MSH2 MSH6 PMS2 EPCAM], - 'R242.1 :: Predictive testing - Seq in Leeds - Send Blood'=> %w[MLH1 MSH2 MSH6 PMS2 EPCAM], - 'R242.1 :: Predictive testing - Seq in Leeds - Send DNA'=> %w[MLH1 MSH2 MSH6 PMS2 EPCAM] + 'R240 :: Diagnostic testing for known pathogenic variant(s) - Hereditary Cancers' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM], + 'R242 :: Predictive testing for known familial pathogenic variant(s) - Hereditary Cancers' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM], + 'R448.1 :: Sequence analysis - Sanger in Newcastle' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM] }.freeze R210_PANEL_GENE_MAPPING_MOL = { @@ -140,7 +142,8 @@ module Constants 'R211.1 :: Small Panel in Leeds' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11], 'R211.1 :: Small panel in Leeds - send DNA sample'=> %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11], 'R211.1 :: APC and MUTYH genes in Leeds' => %w[APC MUTYH], - 'R211.2 :: Unknown mutation(s) by MLPA or equivalent' => %w[APC MUTYH] + 'R211.2 :: Unknown mutation(s) by MLPA or equivalent' => %w[APC MUTYH], + 'R246.1 :: Small panel Carrier testing of partners at population risk' => %w[] }.freeze R211_PANEL_GENE_MAPPING_TAR = { @@ -149,7 +152,10 @@ module Constants 'R242.1 :: Predictive testing' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11], 'R242.1 :: Predictive testing - Seq in Leeds - Send Blood' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11], 'R242.1 :: Predictive testing - Seq in Leeds - Analysis only'=> %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11], - 'R242.1 :: Predictive testing - Seq in Leeds - Send DNA'=> %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11] + 'R242.1 :: Predictive testing - Seq in Leeds - Send DNA'=> %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11], + 'R242.1 :: Predictive testing - Seq in Leeds' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11], + 'R242 :: Predictive testing for known familial pathogenic variant(s) - Hereditary Cancers' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 + PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11] }.freeze R211_PANEL_GENE_MAPPING_MOL = { @@ -157,6 +163,10 @@ module Constants 'R244.1 :: Carrier testing' => %w[MUTYH] }.freeze + R216_PANEL_GENE_MAPPING_FS = { + 'R216.1 :: TP53 NGS in Leeds Analysis only' => %w[TP53] + }.freeze + FAP_PANEL_GENE_MAPPING_MOL = { 'APC gene MLPA' => %w[APC], 'APC gene sequencing' => %w[APC], @@ -192,6 +202,7 @@ module Constants PTEN RAD51C RAD51D STK11 TP53 PMS2] }.freeze + MOLECULAR_SCOPE_MAPPING = { 'carrier testing' => :no_genetictestscope, 'confirmation of familial mutation' => :targeted_mutation, diff --git a/test/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal_test.rb b/test/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal_test.rb index 64e07720..a5ee62e7 100644 --- a/test/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal_test.rb +++ b/test/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal_test.rb @@ -23,6 +23,22 @@ def setup assert_equal 'Targeted Colorectal Lynch or MMR', @genotype.attribute_map['genetictestscope'] end + test 'add_test_scope_from_fs_r211' do + r211_fs_record = build_raw_record('pseudo_id1' => 'bob') + r211_fs_record.raw_fields['genetictestscope'] = 'R211' + r211_fs_record.raw_fields['karyotypingmethod'] = 'R211.1 :: Small panel in Leeds - send DNA sample' + @handler.add_test_scope_from_geno_karyo(@genotype, r211_fs_record) + assert_equal 'Full screen Colorectal Lynch or MMR', @genotype.attribute_map['genetictestscope'] + end + + test 'add_test_scope_from_fs_r216' do + r216_fs_record = build_raw_record('pseudo_id1' => 'bob') + r216_fs_record.raw_fields['genetictestscope'] = 'R216 :: Li Fraumeni Syndrome - SDGS' + r216_fs_record.raw_fields['karyotypingmethod'] = 'R216.1 :: TP53 NGS in Leeds Analysis only' + @handler.add_test_scope_from_geno_karyo(@genotype, r216_fs_record) + assert_equal 'Full screen Colorectal Lynch or MMR', @genotype.attribute_map['genetictestscope'] + end + test 'add_no_scope_from_karyo_targeted' do no_scope_record = build_raw_record('pseudo_id1' => 'bob') no_scope_record.raw_fields['genetictestscope'] = 'XYZ' @@ -31,6 +47,44 @@ def setup assert_equal 'Unable to assign Colorectal Lynch or MMR genetictestscope', @genotype.attribute_map['genetictestscope'] end + test 'add_moltestingtype_from_mapping' do + diagnostic_record = build_raw_record('pseudo_id1' => 'bob') + diagnostic_record.raw_fields['moleculartestingtype'] = 'Confirmation of Familial Mutation' + @handler.add_test_type(@genotype, diagnostic_record) + assert_equal 1, @genotype.attribute_map['moleculartestingtype'] + predictive_record = build_raw_record('pseudo_id1' => 'bob') + predictive_record.raw_fields['moleculartestingtype'] = 'Family Studies' + @handler.add_test_type(@genotype, predictive_record) + assert_equal 2, @genotype.attribute_map['moleculartestingtype'] + end + + test 'add_moltestingtype_from_karyo' do + diagnostic_record = build_raw_record('pseudo_id1' => 'bob') + diagnostic_record.raw_fields['moleculartestingtype'] = 'cabbage' + diagnostic_record.raw_fields['karyotypingmethod'] = 'R210.2 :: Small panel in Leeds' + @handler.add_test_type(@genotype, diagnostic_record) + assert_equal 1, @genotype.attribute_map['moleculartestingtype'] + predictive_record = build_raw_record('pseudo_id1' => 'bob') + predictive_record.raw_fields['moleculartestingtype'] = 'cabbage' + predictive_record.raw_fields['karyotypingmethod'] = 'R242 :: Predictive testing for known familial pathogenic variant(s) - Hereditary Cancers' + @handler.add_test_type(@genotype, predictive_record) + assert_equal 2, @genotype.attribute_map['moleculartestingtype'] + carrier_record = build_raw_record('pseudo_id1' => 'bob') + carrier_record.raw_fields['moleculartestingtype'] = 'cabbage' + carrier_record.raw_fields['karyotypingmethod'] = 'R246.1 :: Small panel Carrier testing of partners at population risk' + @handler.add_test_type(@genotype, carrier_record) + assert_equal 3, @genotype.attribute_map['moleculartestingtype'] + end + + test 'add_moletestingtype_from_mapping_as_priority' do + # priority should be given to moleculartestingtype field over karyotypingmethod field + diagnostic_record = build_raw_record('pseudo_id1' => 'bob') + diagnostic_record.raw_fields['moleculartestingtype'] = 'Diagnostic testing for known mutation' + diagnostic_record.raw_fields['karyotypingmethod'] = 'R242 :: Predictive testing for known familial pathogenic variant(s) - Hereditary Cancers' + @handler.add_test_type(@genotype, diagnostic_record) + assert_equal 1, @genotype.attribute_map['moleculartestingtype'] + end + test 'add_colorectal_from_raw_test_full_screen' do @handler.add_test_scope_from_geno_karyo(@genotype, @record) raw_test = @handler.process_variants_from_record(@genotype, @record) @@ -163,7 +217,7 @@ def setup assert_nil genocolorectals[0].attribute_map['gene'] end - test 'process_targeted_no_scope_failure' do + test 'process_targeted_no_scope_failure' do exon_record = build_raw_record('pseudo_id1' => 'bob') exon_record.raw_fields['genetictestscope'] = 'efgh' exon_record.raw_fields['karyotypingmethod'] = 'abcd' @@ -177,7 +231,7 @@ def setup assert_equal 9, genocolorectals[0].attribute_map['teststatus'] end - test 'process_targeted_no_scope_normal' do + test 'process_targeted_no_scope_normal' do exon_record = build_raw_record('pseudo_id1' => 'bob') exon_record.raw_fields['genetictestscope'] = 'efgh' exon_record.raw_fields['karyotypingmethod'] = 'abcd' @@ -193,7 +247,7 @@ def setup assert_nil genocolorectals[0].attribute_map['gene'] end - test 'process_targeted_no_scope_abnormal' do + test 'process_targeted_no_scope_abnormal' do exon_record = build_raw_record('pseudo_id1' => 'bob') exon_record.raw_fields['genetictestscope'] = 'efgh' exon_record.raw_fields['karyotypingmethod'] = 'abcd' @@ -209,6 +263,42 @@ def setup assert_equal 2804, genocolorectals[0].attribute_map['gene'] end + test 'process_targeted_diagnostic_familial_r240' do + diag_fam_record = build_raw_record('pseudo_id1' => 'bob') + diag_fam_record.raw_fields['genetictestscope'] = 'R210' + diag_fam_record.raw_fields['karyotypingmethod'] = 'R240.1 :: Diagnostic familial - MLPA in Leeds - Send Blood' + diag_fam_record.raw_fields['genotype'] = 'MSH2-c.1234_5678del-p.(Gln321fs)-Heterozygous-UV5' + @handler.add_test_scope_from_geno_karyo(@genotype, diag_fam_record) + @handler.add_test_type(@genotype, diag_fam_record) + genocolorectals = @handler.process_variants_from_record(@genotype, diag_fam_record) + assert_equal 1, genocolorectals.size + assert_equal 'Targeted Colorectal Lynch or MMR', @genotype.attribute_map['genetictestscope'] + assert_equal 1, @genotype.attribute_map['moleculartestingtype'] + assert_equal 2, genocolorectals[0].attribute_map['teststatus'] + assert_equal 2804, genocolorectals[0].attribute_map['gene'] + assert_equal 'p.Gln321fs', genocolorectals[0].attribute_map['proteinimpact'] + assert_equal 'c.1234_5678del', genocolorectals[0].attribute_map['codingdnasequencechange'] + end + + test 'process_targeted_predictive_testing_r242' do + predictive_record = build_raw_record('pseudo_id1' => 'bob') + predictive_record.raw_fields['genetictestscope'] = 'R210' + predictive_record.raw_fields['karyotypingmethod'] = 'R242 :: Predictive testing for known familial pathogenic variant(s) - Hereditary Cancers' + predictive_record.raw_fields['genotype'] = 'MSH2-c.1234_5678del-p.(Gln321fs)-Heterozygous-UV5' + predictive_record.raw_fields['moleculartestingtype'] = 'cabbage' + @handler.add_test_scope_from_geno_karyo(@genotype, predictive_record) + # get moleculartestingtype from karyo (priority 2) + @handler.add_test_type(@genotype, predictive_record) + genocolorectals = @handler.process_variants_from_record(@genotype, predictive_record) + assert_equal 1, genocolorectals.size + assert_equal 'Targeted Colorectal Lynch or MMR', @genotype.attribute_map['genetictestscope'] + assert_equal 2, @genotype.attribute_map['moleculartestingtype'] + assert_equal 2, genocolorectals[0].attribute_map['teststatus'] + assert_equal 2804, genocolorectals[0].attribute_map['gene'] + assert_equal 'p.Gln321fs', genocolorectals[0].attribute_map['proteinimpact'] + assert_equal 'c.1234_5678del', genocolorectals[0].attribute_map['codingdnasequencechange'] + end + test 'process_cdna_change' do @logger.expects(:debug).with('SUCCESSFUL cdna change parse for: 1653dup') @handler.process_cdna_change(@genotype, @record.raw_fields['genotype'])