diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index ae0099c4..dc1ab824 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -11,7 +11,7 @@ class SheffieldHandlerColorectal < Import::Germline::ProviderHandler def process_fields(record) genotype_str = record.raw_fields['genetictestscope'].strip - return if NON_CRC_GENTICTESCOPE.include? genotype_str.downcase + return if NON_CRC_GENETICTESTSCOPE.include? genotype_str.downcase genocolorectal = Import::Colorectal::Core::Genocolorectal.new(record) genocolorectal.add_passthrough_fields(record.mapped_fields, @@ -32,6 +32,9 @@ def add_test_scope_from_geno_karyo(genocolorectal, record) genotype_str = record.raw_fields['genetictestscope'].strip karyo = record.raw_fields['karyotypingmethod'].strip moleculartestingtype = record.raw_fields['moleculartestingtype'].strip + if genotype_str.downcase.match(/r211\s::\sinherited\spolyposis\sand\searly\sonset\scolorectal\scancer/) + genotype_str="r211 :: inherited polyposis and early onset colorectal cancer, germline testing" + end process_method = GENETICTESTSCOPE_METHOD_MAPPING[genotype_str.downcase] if process_method public_send(process_method, karyo, genocolorectal, moleculartestingtype) @@ -90,6 +93,9 @@ def process_scope_r210(karyo, genocolorectal, moleculartestingtype) end def process_scope_r211(karyo, genocolorectal, moleculartestingtype) + if karyo.downcase.match(/r211.1\s::\ssmall\spanel\sin\sleeds.*send\sdna\ssample/) + karyo='R211.1 :: Small panel in Leeds - send DNA sample' + end if R211_PANEL_GENE_MAPPING_FS.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" genocolorectal.add_test_scope(:full_screen) @@ -106,6 +112,17 @@ def process_scope_r211(karyo, genocolorectal, moleculartestingtype) end end + + def process_scope_r414(karyo, genocolorectal, moleculartestingtype) + if R414_PANEL_GENE_MAPPING_FS.keys.include? karyo + @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" + genocolorectal.add_test_scope(:full_screen) + @genes_set = R414_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}" @@ -149,7 +166,7 @@ def process_scope_myh(karyo, genocolorectal, moleculartestingtype) scope = MOLECULAR_SCOPE_MAPPING[moleculartestingtype.downcase] @logger.debug "ADDED #{scope} TEST for: #{moleculartestingtype}" genocolorectal.add_test_scope(scope) - @genes_set = %w[APC MUTYH] + @genes_set = %w[MUTYH] else genocolorectal.add_test_scope(:no_genetictestscope) end @@ -218,12 +235,25 @@ def process_fullscreen_records(genocolorectal, record, genocolorectals) def process_targeted_no_scope_records(genocolorectal, record, genocolorectals) genotype_str = record.raw_fields['genotype'] - if normal?(genotype_str) + if genotype_str.scan(/fail/i).size.positive? + gene=get_gene(record) + genocolorectal.add_status(9) + genocolorectals.append(genocolorectal) + elsif normal?(genotype_str) process_normal_targeted(genocolorectal, record, genocolorectals) elsif positive_cdna?(genotype_str) || positive_exonvariant?(genotype_str) process_variant_targeted(genocolorectal, record, genocolorectals) elsif only_protein_impact?(genotype_str) process_only_protein_rec(genocolorectal, record, genocolorectals) + elsif genotype_str.scan(/^pathogenic\smutation\sdetected/).size.positive? + gene = get_gene(record) + genocolorectal.add_status(2) + genocolorectals.append(genocolorectal) + else + gene=get_gene(record) + genocolorectal.add_status(4) + genocolorectals.append(genocolorectal) + end end @@ -242,7 +272,13 @@ def process_normal_targeted(genocolorectal, record, genocolorectals) def process_normal_full_screen(genocolorectal, genocolorectals) negative_genes = @genes_set - add_other_genes_with_status(negative_genes, genocolorectal, genocolorectals, 1) + if !negative_genes.empty? + add_other_genes_with_status(negative_genes, genocolorectal, genocolorectals, 1) + else + genocolorectals.append(genocolorectal) + end + + genocolorectals end @@ -256,8 +292,7 @@ def add_other_genes_with_status(other_genes, genocolorectal, genocolorectals, st genotype_othr.add_gene_location(nil) genocolorectals.append(genotype_othr) end - genocolorectals - end + end def positive_cdna?(genotype_string) genotype_string.scan(CDNA_REGEX).size.positive? diff --git a/lib/import/helpers/colorectal/providers/rcu/constants.rb b/lib/import/helpers/colorectal/providers/rcu/constants.rb index b2606572..d08f9194 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -22,7 +22,7 @@ module Constants genotype age].freeze - NON_CRC_GENTICTESCOPE = [ + NON_CRC_GENETICTESTSCOPE = [ 'r208 :: inherited breast cancer and ovarian cancer', 'r208 :: brca1 and brca2 testing at high familial risk', 'r205 :: inherited breast cancer (without ovarian cancer) at very high familial risk', @@ -62,7 +62,9 @@ module Constants '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 + '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 }.freeze COLO_PANEL_GENE_MAPPING_FS = { @@ -74,8 +76,7 @@ module Constants 'Extended CRC panel - analysis only' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM APC MUTYH BMPR1A PTEN POLD1 POLE SMAD4 STK11], - 'Full panel' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM APC MUTYH BMPR1A PTEN POLD1 POLE SMAD4 - STK11], + 'Full panel' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM APC MUTYH BMPR1A PTEN POLD1 POLE SMAD4 STK11], 'MLH1 MSH2 MSH6 PMS1 & PMS2' => %w[MLH1 MSH2 MSH6 PMS1 PMS2], 'MLH1 MSH2 MSH6 and PMS2' => %w[MLH1 MSH2 MSH6 PMS2], 'MLH1 MSH2 and MSH6' => %w[MLH1 MSH2 MSH6], @@ -90,6 +91,11 @@ module Constants 'STK11 familial mutation' => %w[STK11] }.freeze + + R414_PANEL_GENE_MAPPING_FS = { + 'R414.1 :: APC sequencing in Leeds' => %w[APC] + }.freeze + R209_PANEL_GENE_MAPPING_FS = { 'R209.1 :: NGS - APC and MUTYH only' => %w[APC MUTYH], 'R209.1 :: Small panel in Leeds' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM APC MUTYH BMPR1A @@ -110,13 +116,19 @@ module Constants R210_PANEL_GENE_MAPPING_FS = { '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.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] }.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' => %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] }.freeze R210_PANEL_GENE_MAPPING_MOL = { @@ -125,13 +137,19 @@ module Constants }.freeze R211_PANEL_GENE_MAPPING_FS = { + '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] }.freeze R211_PANEL_GENE_MAPPING_TAR = { 'R240.1 :: Diagnostic familial' => %w[APC MUTYH], - 'R242.1 :: Predictive testing' => %w[APC MUTYH] + 'R240.1 :: Diagnostic familial - 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' => %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] }.freeze R211_PANEL_GENE_MAPPING_MOL = { @@ -185,7 +203,7 @@ module Constants # rubocop:disable Lint/MixedRegexpCaptureTypes NORMAL_VAR_REGEX = %r{(?no|not)[a-z /]+ - (?detected|reported|deteected|deteceted)+}ix.freeze + (?detected|reported|deteected|deteceted|present)+}ix.freeze CDNA_REGEX = /c\.\[?(? ([0-9]+[+>_-][0-9][+>_-][0-9]+[+>_-][0-9][ACGTdelinsup]+)| 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 73362961..64e07720 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 @@ -163,6 +163,52 @@ def setup assert_nil genocolorectals[0].attribute_map['gene'] end + 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' + exon_record.raw_fields['genotype'] = 'Fail' + exon_record.raw_fields['moleculartestingtype'] = 'Diagnostic testing' + @handler.add_test_scope_from_geno_karyo(@genotype, exon_record) + genocolorectals = @handler.process_variants_from_record(@genotype, exon_record) + assert_equal 1, genocolorectals.size + assert_equal 'Unable to assign Colorectal Lynch or MMR genetictestscope', @genotype.attribute_map['genetictestscope'] + assert_nil genocolorectals[0].attribute_map['proteinimpact'] + assert_equal 9, genocolorectals[0].attribute_map['teststatus'] + end + + 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' + exon_record.raw_fields['genotype'] = 'no pathogenic variant detected' + exon_record.raw_fields['moleculartestingtype'] = 'Diagnostic testing' + @handler.add_test_scope_from_geno_karyo(@genotype, exon_record) + genocolorectals = @handler.process_variants_from_record(@genotype, exon_record) + assert_equal 1, genocolorectals.size + assert_equal 'Unable to assign Colorectal Lynch or MMR genetictestscope', @genotype.attribute_map['genetictestscope'] + assert_nil genocolorectals[0].attribute_map['proteinimpact'] + assert_nil genocolorectals[0].attribute_map['codingdnasequencechange'] + assert_equal 1, genocolorectals[0].attribute_map['teststatus'] + assert_nil genocolorectals[0].attribute_map['gene'] + end + + 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' + exon_record.raw_fields['genotype'] = 'MSH2-c.1234_1345del-p.(Gln123fs)-Heterozygous-UV4' + exon_record.raw_fields['moleculartestingtype'] = 'Diagnostic testing' + @handler.add_test_scope_from_geno_karyo(@genotype, exon_record) + genocolorectals = @handler.process_variants_from_record(@genotype, exon_record) + assert_equal 1, genocolorectals.size + assert_equal 'Unable to assign Colorectal Lynch or MMR genetictestscope', @genotype.attribute_map['genetictestscope'] + assert_equal 2, genocolorectals[0].attribute_map['teststatus'] + assert_equal 'p.Gln123fs', genocolorectals[0].attribute_map['proteinimpact'] + assert_equal 'c.1234_1345del', genocolorectals[0].attribute_map['codingdnasequencechange'] + assert_equal 2804, genocolorectals[0].attribute_map['gene'] + 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']) @@ -202,6 +248,22 @@ def setup assert_equal 1, genocolorectals[0].attribute_map['variantgenotype'] end + test 'unusual characters in panel name' do + exon_record = build_raw_record('pseudo_id1' => 'bob') + exon_record.raw_fields['genetictestscope'] = 'R211 :: Inherited polyposis and early onset colorectal cancer – germline testing' + exon_record.raw_fields['karyotypingmethod'] = 'R211.1 :: Small panel in Leeds – send DNA sample' + exon_record.raw_fields['genotype'] = 'PMS2-c.[1234A>G]-Heterozygous-UV5' + exon_record.raw_fields['moleculartestingtype'] = 'Diagnostic testing' + @handler.add_test_scope_from_geno_karyo(@genotype, exon_record) + genocolorectals = @handler.process_variants_from_record(@genotype, exon_record) + assert_equal 15, genocolorectals.size + assert_equal 'Full screen Colorectal Lynch or MMR', genocolorectals[0].attribute_map['genetictestscope'] + assert_nil genocolorectals[0].attribute_map['proteinimpact'] + assert_equal 'c.1234A>G', genocolorectals[0].attribute_map['codingdnasequencechange'] + assert_equal 1, genocolorectals[0].attribute_map['sequencevarianttype'] + assert_equal 3394, genocolorectals[0].attribute_map['gene'] + end + private def clinical_json