From 2a8dc81afc2d92ca907d106ebdfacfe9e1e5bfe6 Mon Sep 17 00:00:00 2001 From: lauramccluskey Date: Tue, 30 Jul 2024 13:42:38 +0100 Subject: [PATCH 01/16] update sheffield colorectal importer rules --- .../sheffield/sheffield_handler_colorectal.rb | 38 ++++++++++++++++++- .../colorectal/providers/rcu/constants.rb | 32 ++++++++++++---- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index ae0099c4..5a3e5a21 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -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) @@ -72,6 +75,17 @@ def process_scope_r209(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_r210(karyo, genocolorectal, moleculartestingtype) if R210_PANEL_GENE_MAPPING_FS.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" @@ -90,6 +104,9 @@ def process_scope_r210(karyo, genocolorectal, moleculartestingtype) end def process_scope_r211(karyo, genocolorectal, moleculartestingtype) + if karyo.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) @@ -218,12 +235,26 @@ 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/).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) + #TODO this will give it a test status of 2 even if it says "No pathogenic mutation detected!!" + 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 @@ -247,6 +278,7 @@ def process_normal_full_screen(genocolorectal, genocolorectals) end def add_other_genes_with_status(other_genes, genocolorectal, genocolorectals, status) + #TODO what if there are no gene names??? other_genes.each do |gene| genotype_othr = genocolorectal.dup_colo @logger.debug "SUCCESSFUL gene parse for #{status} status for: #{gene}" @@ -256,6 +288,10 @@ def add_other_genes_with_status(other_genes, genocolorectal, genocolorectals, st genotype_othr.add_gene_location(nil) genocolorectals.append(genotype_othr) end + + if other_genes.empty? + 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 b2606572..c28e42a0 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -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[ATM BRCA1 BRCA2 BRIP1 CDH1 CHEK2 EPCAM MLH1 MSH2 MSH6 PALB2 PTEN RAD51C RAD51D STK11 TP53 PMS2], '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]+)| From 085bae09b577d416a9d796887f20d652e7c6317f Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Wed, 19 Mar 2025 14:00:22 +0000 Subject: [PATCH 02/16] updated panels --- .../colorectal/providers/rcu/constants.rb | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/import/helpers/colorectal/providers/rcu/constants.rb b/lib/import/helpers/colorectal/providers/rcu/constants.rb index b2606572..0caab920 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -110,13 +110,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 = { @@ -139,6 +145,30 @@ module Constants 'R244.1 :: Carrier testing' => %w[MUTYH] }.freeze + + R211_PANEL_EARLYCRC_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 :: Small panel in Leeds – send DNA sample ' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11] # need to deal with encoding issue in import as in BRCA one, change it to match panel above + }.freeze + + R211_PANEL_EARLYCRC_GENE_MAPPING_TAR={ + 'R242.1 :: Predictive testing' => %w[], + '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 - Send DNA' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11], + '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 - Seq in Leeds - Analysis only' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11] + }.freeze + + R211_PANEL_EARLYCRC_GENE_MAPPING_MOL = { + 'R387.1 :: APC and MUTYH analysis only' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11] + + }.freeze + + R414_PANEL_GENE_MAPPING_FS = { + 'R387.1 :: APC and MUTYH analysis only' => %w[APC] + }.freeze + FAP_PANEL_GENE_MAPPING_MOL = { 'APC gene MLPA' => %w[APC], 'APC gene sequencing' => %w[APC], @@ -174,6 +204,10 @@ module Constants PTEN RAD51C RAD51D STK11 TP53 PMS2] }.freeze + MYH_GENE_MAPPING_MOL = { + 'Default' => %w[MUTYH] + }.freeze + MOLECULAR_SCOPE_MAPPING = { 'carrier testing' => :no_genetictestscope, 'confirmation of familial mutation' => :targeted_mutation, From f525d5f5a00ea70caaa33a9c3c2d69e454cf6948 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Thu, 27 Mar 2025 14:17:38 +0000 Subject: [PATCH 03/16] added new panels, expanded variant regexes --- .../sheffield/sheffield_handler_colorectal.rb | 30 ++++++++- .../colorectal/providers/rcu/constants.rb | 61 ++++++++++--------- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index ae0099c4..ecbb213d 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -106,6 +106,34 @@ def process_scope_r211(karyo, genocolorectal, moleculartestingtype) end end + def process_scope_r211_early_crc(karyo, genocolorectal, moleculartestingtype) + if karyo.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_EARLYCRC_GENE_MAPPING_FS.keys.include? karyo + genocolorectal.add_test_scope(:full_screen) + @genes_set = R211_PANEL_EARLYCRC_GENE_MAPPING_FS[karyo] + @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" + elsif R211_PANEL_EARLYCRC_GENE_MAPPING_TAR.keys.include? karyo + genocolorectal.add_test_scope(:targeted_mutation) + @genes_set = R211_PANEL_EARLYCRC_GENE_MAPPING_TAR[karyo] + @logger.debug "ADDED TARGETED TEST for: #{karyo}" + elsif R211_PANEL_EARLYCRC_GENE_MAPPING_MOL.keys.include? karyo + genocolorectal.add_test_scope(MOLECULAR_SCOPE_MAPPING[moleculartestingtype.downcase]) + @genes_set = R211_PANEL_EARLYCRC_GENE_MAPPING_MOL[karyo] + else + genocolorectal.add_test_scope(:no_genetictestscope) + end + end + + def process_scope_r414(karyo, genocolorectal, _moleculartestingtype) + if R414_PANEL_GENE_MAPPING_FS.keys.include? karyo + genocolorectal.add_test_scope(:full_screen) + @genes_set = R414_PANEL_GENE_MAPPING_FS[karyo] + @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" + 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 +177,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] #'APC' removed 26/3/25 as per new mappings June 2024 else genocolorectal.add_test_scope(:no_genetictestscope) end diff --git a/lib/import/helpers/colorectal/providers/rcu/constants.rb b/lib/import/helpers/colorectal/providers/rcu/constants.rb index 0caab920..c48a5125 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -58,6 +58,8 @@ module Constants '(with or without polyposis)' => :process_scope_r209, 'r210 :: inherited mmr deficiency (lynch syndrome)' => :process_scope_r210, 'r211 :: inherited polyposis - germline test' => :process_scope_r211, + 'r211 :: inherited polyposis and early onset colorectal cancer -germline testing' => :process_scope_r211_early_crc, + 'r414 :: apc associated polyposis' => :process_scope_r414, 'fap' => :process_scope_fap, 'fap familial mutation' => :process_scope_fap_familial, 'hnpcc' => :process_scope_hnpcc, @@ -221,34 +223,34 @@ module Constants NORMAL_VAR_REGEX = %r{(?no|not)[a-z /]+ (?detected|reported|deteected|deteceted)+}ix.freeze - CDNA_REGEX = /c\.\[?(? - ([0-9]+[+>_-][0-9][+>_-][0-9]+[+>_-][0-9][ACGTdelinsup]+)| - ([0-9]+[+>_-][0-9][+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+)| - ([0-9 ?+>_-]+[ACGTdelinsup][?+>_-][ACGTdelinsup])| - ([0-9]+[ACGTdelinsup]+[+>_-][ACGTdelinsup])| - ([0-9]+[+>_-][0-9]+[ACGTdelinsup]+)| - ([0-9]+[+>_-][0-9]+[+>_-][0-9]+[0-9]+[ACGTdelinsup]+)| - ([0-9 ?+>_-]+[ACGTdelinsup]+)| - ([0-9]+[ACGTdelinsup]+) - )\]?/ix.freeze - - EXON_VARIANT_REGEX = /(?(?het|homo)[a-z ]+)? + CDNA_REGEX = /((c(\.)?-?\*?(? + (\[[0-9]+[+>_-][0-9][+>_-][0-9]+[+>_-][0-9][ACGTdelinsup]+\])| + (\[[0-9]+[+>_-][0-9]+[+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+\])| + (\[[0-9]+[+>_-][0-9]+[ACGTdelinsup][+>_-][ACGT]+\])| + (\[[0-9]+[ACGTdelinsup]+[+>_-][ACGT]+\])| + (\[[0-9]+[+>_-][0-9]+[ACGTdelinsup]+\])| + (\[[0-9]+[+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+\])| + (\[[0-9]+[?+>_-]+[0-9]+[?+>_-]+[ACGT]+\])| + (\[[0-9]+[ACGTdelinsup]+\]))) | + (c\.-?\*?(? + ((\[)?[0-9]+[+>_-][0-9][+>_-][0-9]+[+>_-][0-9][ACGTdelinsup]+(\])?)| + ((\[)?[0-9]+[+>_-][0-9]+[+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+(\])?)| + ((\[)?[0-9]+[+>_-][0-9]+[ACGTdelinsup][+>_-][ACGT]+(\])?)| + ((\[)?[0-9]+[ACGTdelinsup]+[+>_-][ACGT]+(\])?)| + ((\[)?[0-9]+[+>_-][0-9]+[ACGTdelinsup]+(\])?)| + ((\[)?[0-9]+[+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+(\])?)| + ((\[)?[0-9]+[?+>_-]+[0-9]+[?+>_-]+[ACGT]+(\])?)| + ((\[)?[0-9]+[ACGTdelinsup]+(\])?))) + )/ix.freeze + + EXON_VARIANT_REGEX = /((?het|homo)[a-z ]+)? (?deletion|duplication|duplicated)\s? - ([a-z 0-9]+ (exon|exons)\s - (?[0-9]+([a-z -]+[0-9]+)?))| - (?(?ex|exon|exons) - (?([a-z 0-9-]+)?) - (?deletion|duplication|duplicated)(-)? - (?het|homo)?)| - (?(?het|homo)[a-z ]+)? - (?(?exon|exons)\s(?[0-9]+([a-z -]+[0-9]+)?)) - ([a-z ]+ - (?deletion|duplication|duplicated))?/ix.freeze - - PROTEIN_REGEX = /p\.[\[=+ \](]*(? - ([a-z 0-9]+([^[:alnum:]][0-9]+)?)| - ([a-z]+[0-9]+[^[:alnum:]]) - )[)\]]?/ix.freeze + ([a-z 0-9]+(?exon|exons)\s(?[0-9]+((to|_|and|&|-|\s)+[0-9]+)?))| + ((?het|homo)[a-z ]+)?(?exon|exons|ex)\s?(?[0-9]+((to|_|and|&|-|\s)+[0-9]+)?) + ([a-z\s]+(?del(etion)?|duplicati?on|dup(licated)?))?/ix.freeze + + PROTEIN_REGEX = /(p(\.|\[)(\[)?(\()?(?([a-z]+[0-9]+[a-z]+([^[:alnum:]][0-9]+)?)| + ([a-z]+[0-9]+[^[:alnum:]]([a-z]+[0-9]+[delinsup]+)?)))/ix.freeze COLORECTAL_GENES_REGEX = /(?APC| BMPR1A| @@ -263,10 +265,11 @@ module Constants PTEN| SMAD4| STK11| - NTHL1)/xi.freeze # Added by + NTHL1| + RNF43)/xi.freeze # Added by NULL_TARGETED_TEST_REGEX = /(?APC|BMPR1A|EPCAM| MLH1|MSH2|MSH6|MUTYH|PMS2|POLD1| - POLE|PTEN|SMAD4|STK11): + POLE|PTEN|SMAD4|STK11|NTHL1|RNF43): \sFamilial\spathogenic\smutation\snot\sdetected/ix.freeze # rubocop:enable Lint/MixedRegexpCaptureTypes end From a4d9fad696c719903093ffd54d4ebc0a83f154e3 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 2 Jun 2025 12:28:11 +0100 Subject: [PATCH 04/16] correcte typo --- .../providers/sheffield/sheffield_handler_colorectal.rb | 2 +- lib/import/helpers/colorectal/providers/rcu/constants.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index ecbb213d..9f9d9caa 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, diff --git a/lib/import/helpers/colorectal/providers/rcu/constants.rb b/lib/import/helpers/colorectal/providers/rcu/constants.rb index c48a5125..3ac7e6c0 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', From 1ee36caa3b28d0c465da2cbfb93143dd659ee6c7 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 2 Jun 2025 14:55:15 +0100 Subject: [PATCH 05/16] corrected variant regexes --- .../colorectal/providers/rcu/constants.rb | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/import/helpers/colorectal/providers/rcu/constants.rb b/lib/import/helpers/colorectal/providers/rcu/constants.rb index 3ac7e6c0..08600019 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -223,34 +223,34 @@ module Constants NORMAL_VAR_REGEX = %r{(?no|not)[a-z /]+ (?detected|reported|deteected|deteceted)+}ix.freeze - CDNA_REGEX = /((c(\.)?-?\*?(? - (\[[0-9]+[+>_-][0-9][+>_-][0-9]+[+>_-][0-9][ACGTdelinsup]+\])| - (\[[0-9]+[+>_-][0-9]+[+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+\])| - (\[[0-9]+[+>_-][0-9]+[ACGTdelinsup][+>_-][ACGT]+\])| - (\[[0-9]+[ACGTdelinsup]+[+>_-][ACGT]+\])| - (\[[0-9]+[+>_-][0-9]+[ACGTdelinsup]+\])| - (\[[0-9]+[+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+\])| - (\[[0-9]+[?+>_-]+[0-9]+[?+>_-]+[ACGT]+\])| - (\[[0-9]+[ACGTdelinsup]+\]))) | - (c\.-?\*?(? - ((\[)?[0-9]+[+>_-][0-9][+>_-][0-9]+[+>_-][0-9][ACGTdelinsup]+(\])?)| - ((\[)?[0-9]+[+>_-][0-9]+[+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+(\])?)| - ((\[)?[0-9]+[+>_-][0-9]+[ACGTdelinsup][+>_-][ACGT]+(\])?)| - ((\[)?[0-9]+[ACGTdelinsup]+[+>_-][ACGT]+(\])?)| - ((\[)?[0-9]+[+>_-][0-9]+[ACGTdelinsup]+(\])?)| - ((\[)?[0-9]+[+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+(\])?)| - ((\[)?[0-9]+[?+>_-]+[0-9]+[?+>_-]+[ACGT]+(\])?)| - ((\[)?[0-9]+[ACGTdelinsup]+(\])?))) - )/ix.freeze - - EXON_VARIANT_REGEX = /((?het|homo)[a-z ]+)? + CDNA_REGEX = /c\.\[?(? + ([0-9]+[+>_-][0-9][+>_-][0-9]+[+>_-][0-9][ACGTdelinsup]+)| + ([0-9]+[+>_-][0-9][+>_-][0-9]+[+>_-][0-9]+[ACGTdelinsup]+)| + ([0-9 ?+>_-]+[ACGTdelinsup][?+>_-][ACGTdelinsup])| + ([0-9]+[ACGTdelinsup]+[+>_-][ACGTdelinsup])| + ([0-9]+[+>_-][0-9]+[ACGTdelinsup]+)| + ([0-9]+[+>_-][0-9]+[+>_-][0-9]+[0-9]+[ACGTdelinsup]+)| + ([0-9 ?+>_-]+[ACGTdelinsup]+)| + ([0-9]+[ACGTdelinsup]+) + )\]?/ix.freeze + + EXON_VARIANT_REGEX = /(?(?het|homo)[a-z ]+)? (?deletion|duplication|duplicated)\s? - ([a-z 0-9]+(?exon|exons)\s(?[0-9]+((to|_|and|&|-|\s)+[0-9]+)?))| - ((?het|homo)[a-z ]+)?(?exon|exons|ex)\s?(?[0-9]+((to|_|and|&|-|\s)+[0-9]+)?) - ([a-z\s]+(?del(etion)?|duplicati?on|dup(licated)?))?/ix.freeze - - PROTEIN_REGEX = /(p(\.|\[)(\[)?(\()?(?([a-z]+[0-9]+[a-z]+([^[:alnum:]][0-9]+)?)| - ([a-z]+[0-9]+[^[:alnum:]]([a-z]+[0-9]+[delinsup]+)?)))/ix.freeze + ([a-z 0-9]+ (exon|exons)\s + (?[0-9]+([a-z -]+[0-9]+)?))| + (?(?ex|exon|exons) + (?([a-z 0-9-]+)?) + (?deletion|duplication|duplicated)(-)? + (?het|homo)?)| + (?(?het|homo)[a-z ]+)? + (?(?exon|exons)\s(?[0-9]+([a-z -]+[0-9]+)?)) + ([a-z ]+ + (?deletion|duplication|duplicated))?/ix.freeze + + PROTEIN_REGEX = /p\.[\[=+ \](]*(? + ([a-z 0-9]+([^[:alnum:]][0-9]+)?)| + ([a-z]+[0-9]+[^[:alnum:]]) + )[)\]]?/ix.freeze COLORECTAL_GENES_REGEX = /(?APC| BMPR1A| From d7b8587522fbd00c890faf8d33bf88726e089568 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 9 Jun 2025 09:23:42 +0100 Subject: [PATCH 06/16] pulled in Laura's original changes' @ --- lib/import/helpers/colorectal/providers/rcu/constants.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/import/helpers/colorectal/providers/rcu/constants.rb b/lib/import/helpers/colorectal/providers/rcu/constants.rb index a1be5937..fe3d3bc0 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -78,7 +78,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[ATM BRCA1 BRCA2 BRIP1 CDH1 CHEK2 EPCAM MLH1 MSH2 MSH6 PALB2 PTEN RAD51C RAD51D STK11 TP53 PMS2], + '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], From 1a3f6eb7dc0972816330bd58f26fc3ed37b614ec Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 16 Jun 2025 08:38:13 +0100 Subject: [PATCH 07/16] small corrections --- .../providers/sheffield/sheffield_handler_colorectal.rb | 5 ++++- lib/import/helpers/colorectal/providers/rcu/constants.rb | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index 805793d3..f2368af3 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -273,7 +273,8 @@ def process_targeted_no_scope_records(genocolorectal, record, genocolorectals) process_variant_targeted(genocolorectal, record, genocolorectals) elsif only_protein_impact?(genotype_str) process_only_protein_rec(genocolorectal, record, genocolorectals) - #TODO this will give it a test status of 2 even if it says "No pathogenic mutation detected!!" + #TODO this will give it a test status of 2 even if it says "No pathogenic mutation detected!!" + #NI: no, it won't because of "^" - but it won't pick up e.g. "familial pathogenic variant detected" elsif genotype_str.scan(/^pathogenic\smutation\sdetected/).size.positive? gene = get_gene(record) genocolorectal.add_status(2) @@ -318,7 +319,9 @@ def add_other_genes_with_status(other_genes, genocolorectal, genocolorectals, st end if other_genes.empty? + genocolorectal.add_status(status) 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 fe3d3bc0..12c55838 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -180,7 +180,7 @@ module Constants }.freeze R414_PANEL_GENE_MAPPING_FS = { - 'R387.1 :: APC and MUTYH analysis only' => %w[APC] + 'R414.1 :: APC and MUTYH analysis only' => %w[APC] }.freeze FAP_PANEL_GENE_MAPPING_MOL = { @@ -219,7 +219,7 @@ module Constants }.freeze MYH_GENE_MAPPING_MOL = { - 'Default' => %w[MUTYH] + 'Default' => %w[MUTYH] }.freeze MOLECULAR_SCOPE_MAPPING = { From 25dbd2a21df3384c6067d2439137b4161e5c5f21 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 16 Jun 2025 10:16:08 +0100 Subject: [PATCH 08/16] removed no gene teststatud addition - causes problems elsewhere --- .../providers/sheffield/sheffield_handler_colorectal.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index f2368af3..fea8416d 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -318,11 +318,6 @@ def add_other_genes_with_status(other_genes, genocolorectal, genocolorectals, st genocolorectals.append(genotype_othr) end - if other_genes.empty? - genocolorectal.add_status(status) - genocolorectals.append(genocolorectal) - - end genocolorectals end From 2853279616d906f0669b181646111e43074895f3 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 16 Jun 2025 13:31:50 +0100 Subject: [PATCH 09/16] added facility to add test status where no genes are present for other_genes --- .../sheffield/sheffield_handler_colorectal.rb | 6 +++ .../colorectal/providers/rcu/constants.rb | 40 +++---------------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index fea8416d..88da2dda 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -17,6 +17,7 @@ def process_fields(record) genocolorectal.add_passthrough_fields(record.mapped_fields, record.raw_fields, PASS_THROUGH_FIELDS_COLO) + add_test_scope_from_geno_karyo(genocolorectal, record) add_organisationcode_testresult(genocolorectal) add_test_type(genocolorectal, record) @@ -318,6 +319,11 @@ def add_other_genes_with_status(other_genes, genocolorectal, genocolorectals, st genocolorectals.append(genotype_othr) end + if other_genes.count < 1 + genocolorectal.add_status(status) + 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 12c55838..ad63a999 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -58,8 +58,6 @@ module Constants '(with or without polyposis)' => :process_scope_r209, 'r210 :: inherited mmr deficiency (lynch syndrome)' => :process_scope_r210, 'r211 :: inherited polyposis - germline test' => :process_scope_r211, - 'r211 :: inherited polyposis and early onset colorectal cancer -germline testing' => :process_scope_r211_early_crc, - 'r414 :: apc associated polyposis' => :process_scope_r414, 'fap' => :process_scope_fap, 'fap familial mutation' => :process_scope_fap_familial, 'hnpcc' => :process_scope_hnpcc, @@ -78,7 +76,8 @@ 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[ATM BRCA1 BRCA2 BRIP1 CDH1 CHEK2 EPCAM MLH1 MSH2 MSH6 PALB2 PTEN RAD51C RAD51D STK11 TP53 PMS2], + '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], @@ -159,30 +158,6 @@ module Constants 'R244.1 :: Carrier testing' => %w[MUTYH] }.freeze - - R211_PANEL_EARLYCRC_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 :: Small panel in Leeds – send DNA sample ' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11] # need to deal with encoding issue in import as in BRCA one, change it to match panel above - }.freeze - - R211_PANEL_EARLYCRC_GENE_MAPPING_TAR={ - 'R242.1 :: Predictive testing' => %w[], - '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 - Send DNA' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11], - '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 - Seq in Leeds - Analysis only' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11] - }.freeze - - R211_PANEL_EARLYCRC_GENE_MAPPING_MOL = { - 'R387.1 :: APC and MUTYH analysis only' => %w[APC BMPR1A EPCAM MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN RNF43 SMAD4 STK11] - - }.freeze - - R414_PANEL_GENE_MAPPING_FS = { - 'R414.1 :: APC and MUTYH analysis only' => %w[APC] - }.freeze - FAP_PANEL_GENE_MAPPING_MOL = { 'APC gene MLPA' => %w[APC], 'APC gene sequencing' => %w[APC], @@ -218,10 +193,6 @@ module Constants PTEN RAD51C RAD51D STK11 TP53 PMS2] }.freeze - MYH_GENE_MAPPING_MOL = { - 'Default' => %w[MUTYH] - }.freeze - MOLECULAR_SCOPE_MAPPING = { 'carrier testing' => :no_genetictestscope, 'confirmation of familial mutation' => :targeted_mutation, @@ -277,11 +248,10 @@ module Constants PTEN| SMAD4| STK11| - NTHL1| - RNF43)/xi.freeze # Added by + NTHL1)/xi.freeze # Added by NULL_TARGETED_TEST_REGEX = /(?APC|BMPR1A|EPCAM| MLH1|MSH2|MSH6|MUTYH|PMS2|POLD1| - POLE|PTEN|SMAD4|STK11|NTHL1|RNF43): + POLE|PTEN|SMAD4|STK11): \sFamilial\spathogenic\smutation\snot\sdetected/ix.freeze # rubocop:enable Lint/MixedRegexpCaptureTypes end @@ -289,4 +259,4 @@ module Constants end end end -end +end \ No newline at end of file From 14307532f1077afa1d7834331c2260173b867909 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 16 Jun 2025 14:58:51 +0100 Subject: [PATCH 10/16] code updated - counts look better --- .../sheffield/sheffield_handler_colorectal.rb | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index 88da2dda..f7548846 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -124,34 +124,17 @@ def process_scope_r211(karyo, genocolorectal, moleculartestingtype) end end - def process_scope_r211_early_crc(karyo, genocolorectal, moleculartestingtype) - if karyo.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_EARLYCRC_GENE_MAPPING_FS.keys.include? karyo - genocolorectal.add_test_scope(:full_screen) - @genes_set = R211_PANEL_EARLYCRC_GENE_MAPPING_FS[karyo] + + def process_scope_r414(karyo, genocolorectal, moleculartestingtype) + if R414_PANEL_GENE_MAPPING_FS.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" - elsif R211_PANEL_EARLYCRC_GENE_MAPPING_TAR.keys.include? karyo - genocolorectal.add_test_scope(:targeted_mutation) - @genes_set = R211_PANEL_EARLYCRC_GENE_MAPPING_TAR[karyo] - @logger.debug "ADDED TARGETED TEST for: #{karyo}" - elsif R211_PANEL_EARLYCRC_GENE_MAPPING_MOL.keys.include? karyo - genocolorectal.add_test_scope(MOLECULAR_SCOPE_MAPPING[moleculartestingtype.downcase]) - @genes_set = R211_PANEL_EARLYCRC_GENE_MAPPING_MOL[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_r414(karyo, genocolorectal, _moleculartestingtype) - if R414_PANEL_GENE_MAPPING_FS.keys.include? karyo - genocolorectal.add_test_scope(:full_screen) - @genes_set = R414_PANEL_GENE_MAPPING_FS[karyo] - @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" - 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}" @@ -308,7 +291,6 @@ def process_normal_full_screen(genocolorectal, genocolorectals) end def add_other_genes_with_status(other_genes, genocolorectal, genocolorectals, status) - #TODO what if there are no gene names??? other_genes.each do |gene| genotype_othr = genocolorectal.dup_colo @logger.debug "SUCCESSFUL gene parse for #{status} status for: #{gene}" @@ -319,11 +301,9 @@ def add_other_genes_with_status(other_genes, genocolorectal, genocolorectals, st genocolorectals.append(genotype_othr) end - if other_genes.count < 1 - genocolorectal.add_status(status) + if other_genes.empty? genocolorectals.append(genocolorectal) - end - + end genocolorectals end From 78291ceb1871e3a66bd904f28b8ebbccd1a809f4 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Thu, 19 Jun 2025 10:34:50 +0100 Subject: [PATCH 11/16] removed duplicate code --- .../sheffield/sheffield_handler_colorectal.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index f7548846..263ea80b 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -76,17 +76,6 @@ def process_scope_r209(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_r210(karyo, genocolorectal, moleculartestingtype) if R210_PANEL_GENE_MAPPING_FS.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" From 9a04eeb33c5dfbbdb8e1713d363e0ed928c65b1c Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Thu, 19 Jun 2025 10:36:49 +0100 Subject: [PATCH 12/16] removed comments --- .../providers/sheffield/sheffield_handler_colorectal.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index 263ea80b..198abc8d 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -167,7 +167,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[MUTYH] #'APC' removed 26/3/25 as per new mappings June 2024 + @genes_set = %w[MUTYH] else genocolorectal.add_test_scope(:no_genetictestscope) end @@ -246,8 +246,8 @@ def process_targeted_no_scope_records(genocolorectal, record, genocolorectals) process_variant_targeted(genocolorectal, record, genocolorectals) elsif only_protein_impact?(genotype_str) process_only_protein_rec(genocolorectal, record, genocolorectals) - #TODO this will give it a test status of 2 even if it says "No pathogenic mutation detected!!" - #NI: no, it won't because of "^" - but it won't pick up e.g. "familial pathogenic variant detected" + #TODO Laura: this will give it a test status of 2 even if it says "No pathogenic mutation detected!!" + #NI: will it?? it has the "^" at the start elsif genotype_str.scan(/^pathogenic\smutation\sdetected/).size.positive? gene = get_gene(record) genocolorectal.add_status(2) From 55c76e31865037c6e6babd52634b18bfcc04dc22 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Thu, 19 Jun 2025 10:37:37 +0100 Subject: [PATCH 13/16] removed comments --- .../providers/sheffield/sheffield_handler_colorectal.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index 198abc8d..cc48c18f 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -246,7 +246,7 @@ def process_targeted_no_scope_records(genocolorectal, record, genocolorectals) process_variant_targeted(genocolorectal, record, genocolorectals) elsif only_protein_impact?(genotype_str) process_only_protein_rec(genocolorectal, record, genocolorectals) - #TODO Laura: this will give it a test status of 2 even if it says "No pathogenic mutation detected!!" + #TODO LM: this will give it a test status of 2 even if it says "No pathogenic mutation detected!!" #NI: will it?? it has the "^" at the start elsif genotype_str.scan(/^pathogenic\smutation\sdetected/).size.positive? gene = get_gene(record) From b634c6be3229b686b4a54e8670143a5891ab0562 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 23 Jun 2025 11:03:50 +0100 Subject: [PATCH 14/16] fixing issue with no gene and not creating a duplicate object --- .../sheffield/sheffield_handler_colorectal.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index cc48c18f..e9fbc7c1 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -275,7 +275,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 @@ -289,12 +295,7 @@ def add_other_genes_with_status(other_genes, genocolorectal, genocolorectals, st genotype_othr.add_gene_location(nil) genocolorectals.append(genotype_othr) end - - if other_genes.empty? - genocolorectals.append(genocolorectal) - end - genocolorectals - end + end def positive_cdna?(genotype_string) genotype_string.scan(CDNA_REGEX).size.positive? From c1d683d1f657c4e6ad011f08c77cc72ae074b222 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 30 Jun 2025 12:45:30 +0100 Subject: [PATCH 15/16] removed commented out line --- lib/import/helpers/colorectal/providers/rcu/constants.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/import/helpers/colorectal/providers/rcu/constants.rb b/lib/import/helpers/colorectal/providers/rcu/constants.rb index ad63a999..5ecf003c 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -76,7 +76,6 @@ module Constants 'Extended CRC panel - analysis only' => %w[MLH1 MSH2 MSH6 PMS2 EPCAM APC MUTYH BMPR1A PTEN POLD1 POLE SMAD4 STK11], - #'Full panel' => %w[ATM BRCA1 BRCA2 BRIP1 CDH1 CHEK2 EPCAM MLH1 MSH2 MSH6 PALB2 PTEN RAD51C RAD51D STK11 TP53 PMS2], '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], From 8232801eddf7242f27be7083b63ce34f147b4604 Mon Sep 17 00:00:00 2001 From: Nichola Imeson Date: Mon, 7 Jul 2025 16:06:46 +0100 Subject: [PATCH 16/16] few code review changes, added tests --- .../sheffield/sheffield_handler_colorectal.rb | 9 +-- .../colorectal/providers/rcu/constants.rb | 2 +- .../sheffield_handler_colorectal_test.rb | 62 +++++++++++++++++++ 3 files changed, 66 insertions(+), 7 deletions(-) diff --git a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb index e9fbc7c1..dc1ab824 100644 --- a/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb +++ b/lib/import/colorectal/providers/sheffield/sheffield_handler_colorectal.rb @@ -17,7 +17,6 @@ def process_fields(record) genocolorectal.add_passthrough_fields(record.mapped_fields, record.raw_fields, PASS_THROUGH_FIELDS_COLO) - add_test_scope_from_geno_karyo(genocolorectal, record) add_organisationcode_testresult(genocolorectal) add_test_type(genocolorectal, record) @@ -94,7 +93,7 @@ def process_scope_r210(karyo, genocolorectal, moleculartestingtype) end def process_scope_r211(karyo, genocolorectal, moleculartestingtype) - if karyo.match(/R211.1\s::\sSmall\spanel\sin\sLeeds.*send\sDNA\ssample/) + 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 @@ -236,18 +235,16 @@ def process_fullscreen_records(genocolorectal, record, genocolorectals) def process_targeted_no_scope_records(genocolorectal, record, genocolorectals) genotype_str = record.raw_fields['genotype'] - if genotype_str.scan(/fail/).size.positive? + if genotype_str.scan(/fail/i).size.positive? gene=get_gene(record) genocolorectal.add_status(9) genocolorectals.append(genocolorectal) - elsif normal?(genotype_str) + 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) - #TODO LM: this will give it a test status of 2 even if it says "No pathogenic mutation detected!!" - #NI: will it?? it has the "^" at the start elsif genotype_str.scan(/^pathogenic\smutation\sdetected/).size.positive? gene = get_gene(record) genocolorectal.add_status(2) diff --git a/lib/import/helpers/colorectal/providers/rcu/constants.rb b/lib/import/helpers/colorectal/providers/rcu/constants.rb index 5ecf003c..d08f9194 100644 --- a/lib/import/helpers/colorectal/providers/rcu/constants.rb +++ b/lib/import/helpers/colorectal/providers/rcu/constants.rb @@ -258,4 +258,4 @@ module Constants end end end -end \ No newline at end of file +end 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