diff --git a/lib/import/brca/providers/sheffield/sheffield_handler.rb b/lib/import/brca/providers/sheffield/sheffield_handler.rb index efd47c33..b408f748 100644 --- a/lib/import/brca/providers/sheffield/sheffield_handler.rb +++ b/lib/import/brca/providers/sheffield/sheffield_handler.rb @@ -13,6 +13,7 @@ def process_fields(record) geno = record.raw_fields['genetictestscope'] return if NON_BRCA_SCOPE.include?(geno) + @genes_set = [] genotype = Import::Brca::Core::GenotypeBrca.new(record) genotype.add_passthrough_fields(record.mapped_fields, record.raw_fields, @@ -20,7 +21,6 @@ def process_fields(record) add_test_type(genotype, record) add_organisationcode_testresult(genotype) add_test_scope_from_geno_karyo(genotype, record) - res = process_variants_from_record(genotype, record) res.map { |cur_genotype| @persister.integrate_and_store(cur_genotype) } end @@ -34,37 +34,46 @@ def add_test_scope_from_geno_karyo(genotype, record) karyo = record.raw_fields['karyotypingmethod'].strip process_method = GENETICTESTSCOPE_METHOD_MAPPING[genotype_str] if process_method - send(process_method, karyo, genotype) + send(process_method, karyo, genotype, record) else genotype.add_test_scope(:no_genetictestscope) end end - def process_scope_familial_mutation(karyo, genotype) - if BRCA_FAMILIAL_GENE_MAPPING.keys.include? karyo + def process_scope_familial_mutation(karyo, genotype, record) + if BRCA_FAMILIAL_GENE_MAPPING.include? karyo @logger.debug "ADDED TARGETED TEST for: #{karyo}" genotype.add_test_scope(:targeted_mutation) - @genes_set = BRCA_FAMILIAL_GENE_MAPPING[karyo] + get_genes_set_targeted(record) else genotype.add_test_scope(:no_genetictestscope) end end - def process_scope_gene_analysis(karyo, genotype) + def process_scope_gene_analysis(karyo, genotype, record) if BRCA_ANALYSIS_GENE_MAPPING_FS.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" genotype.add_test_scope(:full_screen) @genes_set = BRCA_ANALYSIS_GENE_MAPPING_FS[karyo] - elsif BRCA_ANALYSIS_GENE_MAPPING_TAR.keys.include? karyo + elsif BRCA_ANALYSIS_GENE_MAPPING_TAR.include? karyo @logger.debug "ADDED TARGETED TEST for: #{karyo}" genotype.add_test_scope(:targeted_mutation) - @genes_set = BRCA_ANALYSIS_GENE_MAPPING_TAR[karyo] + get_genes_set_targeted(record) + else genotype.add_test_scope(:no_genetictestscope) end end - def process_scope_ovarian_panel(karyo, genotype) + def get_genes_set_targeted(record) + karyo_column = record.raw_fields['karyotypingmethod'].strip + genotype_column = record.raw_fields['genotype'].strip + @genes_set = [] + @genes_set.append(karyo_column.scan(BRCA_REGEX)) + @genes_set.append(genotype_column.scan(BRCA_REGEX)) + end + + def process_scope_ovarian_panel(karyo, genotype, _record) if OVRN_CNCR_PNL_GENE_MAPPING.keys.include? karyo @logger.debug "ADDED FULL_SCREEN for: #{karyo}" genotype.add_test_scope(:full_screen) @@ -74,7 +83,7 @@ def process_scope_ovarian_panel(karyo, genotype) end end - def process_scope_colo_ovarian_panel(karyo, genotype) + def process_scope_colo_ovarian_panel(karyo, genotype, _record) if OVRN_COLO_PNL_GENE_MAPPING.keys.include? karyo @logger.debug "ADDED FULL_SCREEN for: #{karyo}" genotype.add_test_scope(:full_screen) @@ -84,21 +93,21 @@ def process_scope_colo_ovarian_panel(karyo, genotype) end end - def process_scope_r205(karyo, genotype) + def process_scope_r205(karyo, genotype, record) if R205_GENE_MAPPING_FS.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" genotype.add_test_scope(:full_screen) @genes_set = R205_GENE_MAPPING_FS[karyo] - elsif R205_GENE_MAPPING_TAR.keys.include? karyo + elsif R205_GENE_MAPPING_TAR.include? karyo @logger.debug "ADDED TARGETED TEST for: #{karyo}" genotype.add_test_scope(:targeted_mutation) - @genes_set = R205_GENE_MAPPING_TAR[karyo] + get_genes_set_targeted(record) else genotype.add_test_scope(:no_genetictestscope) end end - def process_scope_r206(karyo, genotype) + def process_scope_r206(karyo, genotype, record) if R206_GENE_MAPPING.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" genotype.add_test_scope(:full_screen) @@ -106,56 +115,102 @@ def process_scope_r206(karyo, genotype) elsif ['R242.1 :: Predictive testing'].include? karyo @logger.debug "ADDED TARGETED TEST for: #{karyo}" genotype.add_test_scope(:targeted_mutation) - @genes_set = %w[ATM BRCA1 BRCA2 BRIP1 CDH1 CHEK2 EPCAM MLH1 MSH2 MSH6 PALB2 PTEN - RAD51C RAD51D STK11 TP53 PMS2] + get_genes_set_targeted(record) else genotype.add_test_scope(:no_genetictestscope) end end - def process_scope_r207(karyo, genotype) + def process_scope_r207(karyo, genotype, record) if R207_GENE_MAPPING_FS.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" genotype.add_test_scope(:full_screen) @genes_set = R207_GENE_MAPPING_FS[karyo] - elsif R207_GENE_MAPPING_TAR.keys.include? karyo + elsif R207_GENE_MAPPING_TAR.include? karyo @logger.debug "ADDED TARGETED TEST for: #{karyo}" genotype.add_test_scope(:targeted_mutation) - @genes_set = R207_GENE_MAPPING_TAR[karyo] + get_genes_set_targeted(record) else genotype.add_test_scope(:no_genetictestscope) end end - def process_scope_r208(karyo, genotype) + def process_scope_r208(karyo, genotype, record) if R208_GENE_MAPPING_FS.keys.include? karyo @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" genotype.add_test_scope(:full_screen) @genes_set = R208_GENE_MAPPING_FS[karyo] - elsif R208_GENE_MAPPING_TAR.keys.include? karyo + elsif R208_GENE_MAPPING_TAR.include? karyo @logger.debug "ADDED TARGETED TEST for: #{karyo}" genotype.add_test_scope(:targeted_mutation) - @genes_set = R208_GENE_MAPPING_TAR[karyo] + get_genes_set_targeted(record) + else + genotype.add_test_scope(:no_genetictestscope) + end + end + + def process_scope_r208_new(karyo, genotype, record) + genotype_str = record.raw_fields['genotype'].to_s + genotype_genes = genotype_str.scan(BRCA_REGEX).flatten.uniq + if R208_GENE_MAPPING_FS_NEW.keys.include? karyo + @logger.debug "ADDED FULL_SCREEN TEST for: #{karyo}" + genotype.add_test_scope(:full_screen) + @genes_set = R208_GENE_MAPPING_FS_NEW[karyo].dup + # add genes from genotype column + @genes_set.concat(genotype_genes) + if karyo.match(/R208\.1\s::\sNGS\sin\sLeeds/) + date = DateTime.parse(record.raw_fields['authoriseddate']) + @genes_set.concat(%w[RAD51C RAD51D]) if date >= DateTime.parse('01/02/2023') + end + elsif R208_GENE_MAPPING_TAR_NEW.include? karyo + @logger.debug "ADDED TARGETED TEST for: #{karyo}" + genotype.add_test_scope(:targeted_mutation) + get_genes_set_targeted(record) + else + genotype.add_test_scope(:no_genetictestscope) + end + @genes_set = @genes_set.uniq + end + + def process_scope_r430(karyo, genotype, _record) + if R430_GENE_MAPPING_FS.keys.include? karyo + @genes_set = R430_GENE_MAPPING_FS[karyo] + genotype.add_test_scope(:full_screen) else genotype.add_test_scope(:no_genetictestscope) end end - def process_scope_r240(karyo, genotype) - if R240_GENE_MAPPING_TAR.keys.include? karyo + def process_scope_r444(karyo, genotype, _record) + if karyo.match(/R444\.1\s::\sPARPi\sfor\sBreast\scancer.*NGS\sin\sLeeds/) + karyo = 'R444.1 :: PARPi for Breast cancer - NGS in Leeds' + end + if karyo.match(/R444\.2\s::\sPARPi\sfor\sProstate\sCancer.*NGS\sin\sLeeds\ssend\sDNA\sto\sLeeds/) + karyo = 'R444.2 :: PARPi for Prostate Cancer - NGS in Leeds send DNA to Leeds' + end + if R444_GENE_MAPPING.keys.include? karyo + @genes_set = R444_GENE_MAPPING[karyo] + genotype.add_test_scope(:full_screen) + else + genotype.add_test_scope(:no_genetictestscope) + end + end + + def process_scope_r240(karyo, genotype, record) + if R240_GENE_MAPPING_TAR.include? karyo @logger.debug "ADDED TARGETED TEST for: #{karyo}" genotype.add_test_scope(:targeted_mutation) - @genes_set = R240_GENE_MAPPING_TAR[karyo] + get_genes_set_targeted(record) else genotype.add_test_scope(:no_genetictestscope) end end - def process_scope_r242(karyo, genotype) - if R242_GENE_MAPPING_TAR.keys.include? karyo + def process_scope_r242(karyo, genotype, record) + if R242_GENE_MAPPING_TAR.include? karyo @logger.debug "ADDED TARGETED TEST for: #{karyo}" genotype.add_test_scope(:targeted_mutation) - @genes_set = R242_GENE_MAPPING_TAR[karyo] + get_genes_set_targeted(record) else genotype.add_test_scope(:no_genetictestscope) end @@ -294,15 +349,18 @@ def add_other_genes_with_status(other_genes, genotype, genotypes, status) end def process_multi_genes(genotype, record, genotypes) - positive_genes = record.raw_fields['genotype'].scan(BRCA_REGEX).flatten.uniq - raw_genotypes = record.raw_fields['genotype'].split(positive_genes[-1]) - raw_genotypes[1].prepend(positive_genes[-1]) + positive_genes = record.raw_fields['genotype'].scan(BRCA_REGEX).flatten + positive_genes = positive_genes.join('|') + raw_genotypes = record.raw_fields['genotype'].split(/(?=#{positive_genes})/) + process_raw_genotypes(raw_genotypes, genotype, genotypes) end def process_raw_genotypes(raw_genotypes, genotype, genotypes) raw_genotypes.each do |raw_genotype| raw_genotype.scan(BRCA_REGEX) + next if raw_genotype.scan(BRCA_REGEX).empty? + genotype_dup = genotype.dup genotype_dup.add_gene($LAST_MATCH_INFO[:brca]&.upcase) if positive_cdna?(raw_genotype) || positive_exonvariant?(raw_genotype) @@ -339,8 +397,8 @@ def process_fullscreen_records(genotype, record, genotypes) process_failed_full_screen(genotype, record, genotypes) elsif positive_cdna?(genotype_str) || positive_exonvariant?(genotype_str) process_variant_fs_records(genotype, record, genotypes) - elsif only_protein_impact?(record) || - genotype_str.scan(/see\sbelow|comments/ix).size.positive? + else + # else give a test status of 4 (unknown) add_other_genes_with_status(@genes_set, genotype, genotypes, 4) end genotypes @@ -360,7 +418,7 @@ def process_multiple_variant_fs_record(genotype, record, genotypes) if positive_genes.blank? add_other_genes_with_status(@genes_set, genotype, genotypes, 4) elsif positive_genes.size > 1 - process_multi_genes(genotype, record, genotypes) + genotypes = process_multi_genes(genotype, record, genotypes) else process_positive_record(genotype, record, genotypes, positive_genes) end @@ -482,7 +540,7 @@ def get_cdna_mutation(raw_genotype) def get_gene(record) genotype_str = record.raw_fields['genotype'].to_s positive_genes = genotype_str.scan(BRCA_REGEX).flatten.uniq - if positive_genes.size.zero? + if positive_genes.empty? positive_genes = record.raw_fields['karyotypingmethod'].scan(BRCA_REGEX).flatten.uniq end positive_genes @@ -490,8 +548,8 @@ def get_gene(record) def only_protein_impact?(record) variant = record.raw_fields['genotype'] - variant.scan(CDNA_REGEX).size.zero? && - variant.scan(EXON_VARIANT_REGEX).size.zero? && + variant.scan(CDNA_REGEX).empty? && + variant.scan(EXON_VARIANT_REGEX).empty? && variant.scan(PROTEIN_REGEX).size.positive? end diff --git a/lib/import/helpers/brca/providers/rcu/rcu_constants.rb b/lib/import/helpers/brca/providers/rcu/rcu_constants.rb index 1ff2b102..25c69325 100644 --- a/lib/import/helpers/brca/providers/rcu/rcu_constants.rb +++ b/lib/import/helpers/brca/providers/rcu/rcu_constants.rb @@ -24,30 +24,32 @@ module RcuConstants 'and ovarian cancer at high familial risk levels' => :process_scope_r206, 'R207 :: Inherited ovarian cancer (without breast cancer)' => :process_scope_r207, 'R208 :: BRCA1 and BRCA2 testing at high familial risk' => :process_scope_r208, - 'R208 :: Inherited breast cancer and ovarian cancer' => :process_scope_r208, + 'R208 :: Inherited breast cancer and ovarian cancer' => :process_scope_r208_new, 'R240 - Familial Diagnostic testing - Hered Cancers' => :process_scope_r240, - 'R242 - Predictive testing - Hered Cancers' => :process_scope_r242 + 'R242 - Predictive testing - Hered Cancers' => :process_scope_r242, + 'R430 :: Inherited Prostate Cancer' => :process_scope_r430, + 'R444 :: NICE approved PARP inhibitor treatment' => :process_scope_r444 }.freeze - BRCA_FAMILIAL_GENE_MAPPING = { - 'BRCA1 gene MLPA' => %w[BRCA1], - 'BRCA1 gene sequencing' => %w[BRCA1], - 'BRCA2 gene MLPA' => %w[BRCA2], - 'BRCA2 gene sequencing' => %w[BRCA2] - }.freeze + BRCA_FAMILIAL_GENE_MAPPING = [ + 'BRCA1 gene MLPA', + 'BRCA1 gene sequencing', + 'BRCA2 gene MLPA', + 'BRCA2 gene sequencing' + ].freeze BRCA_ANALYSIS_GENE_MAPPING_FS = { 'BRCA1 and 2 gene sequencing' => %w[BRCA1 BRCA2], 'Full Screen' => %w[BRCA1 BRCA2] }.freeze - BRCA_ANALYSIS_GENE_MAPPING_TAR = { - 'BRCA cDNA analysis' => %w[BRCA1 BRCA2], - 'BRCA1 gene MLPA' => %w[BRCA1], - 'BRCA1 gene sequencing' => %w[BRCA1], - 'BRCA2 gene MLPA' => %w[BRCA2], - 'BRCA2 gene sequencing' => %w[BRCA2] - }.freeze + BRCA_ANALYSIS_GENE_MAPPING_TAR = [ + 'BRCA cDNA analysis', + 'BRCA1 gene MLPA', + 'BRCA1 gene sequencing', + 'BRCA2 gene MLPA', + 'BRCA2 gene sequencing' + ].freeze OVRN_CNCR_PNL_GENE_MAPPING = { 'BRCA1 BRCA2 & TP53' => %w[BRCA1 BRCA2 TP53], @@ -85,11 +87,10 @@ module RcuConstants STK11 TP53] }.freeze - R205_GENE_MAPPING_TAR = { - 'R242.1 :: Predictive testing' => %w[ATM BRCA1 BRCA2 CDH1 CHEK2 PALB2 PTEN STK11 - TP53], - 'R242.1 :: Predictive - MLPA' => %w[BRCA1 BRCA2 TP53] - }.freeze + R205_GENE_MAPPING_TAR = [ + 'R242.1 :: Predictive testing', + 'R242.1 :: Predictive - MLPA' + ].freeze R206_GENE_MAPPING = { 'R206.1 :: Unknown mutation(s) by Small panel' => %w[ATM BRCA1 BRCA2 BRIP1 CDH1 @@ -117,38 +118,68 @@ module RcuConstants 'R387.1 :: NGS analysis only' => %w[BRCA1 BRCA2 BRIP1 EPCAM MLH1 MSH2 MSH6 PALB2 RAD51C RAD51D PMS2], 'R207.1 :: NGS in Leeds' => %w[BRCA1 BRCA2 BRIP1 EPCAM MLH1 MSH2 - MSH6 PALB2 RAD51C RAD51D PMS2] + MSH6 PALB2 RAD51C RAD51D PMS2], + 'R207.1 :: NGS in Leeds - Send DNA to Leeds' => %w[BRCA1 BRCA2 BRIP1 EPCAM MLH1 MSH2 + MSH6 PALB2 RAD51C RAD51D PMS2] }.freeze - R207_GENE_MAPPING_TAR = { - 'R240.1 :: Diagnostic familial' => %w[BRCA1 BRCA2 BRIP1 EPCAM MLH1 - MSH2 MSH6 PALB2 RAD51C RAD51D PMS2], - 'R242.1 :: Predictive testing' => %w[BRCA1 BRCA2 BRIP1 EPCAM MLH1 - MSH2 MSH6 PALB2 RAD51C RAD51D PMS2] - }.freeze + R207_GENE_MAPPING_TAR = [ + 'R240.1 :: Diagnostic familial', + 'R242.1 :: Predictive testing', + 'R242.1 :: Predictive testing - Seq in Leeds - Send Blood', + 'R242.1 :: Predictive testing - Seq in Leeds - Send DNA', + 'R242.1 :: Predictive testing - MLPA in Leeds - Send Blood' + ].freeze R208_GENE_MAPPING_FS = { 'R208.1 :: Unknown mutation(s) by Single gene sequencing' => %w[BRCA1 BRCA2 PALB2], 'R208.2 :: Unknown mutation(s) by MLPA or equivalent' => %w[BRCA1 BRCA2], 'R387.1 :: BRCA1 BRCA2 PALB2 analysis only' => %w[BRCA1 BRCA2 PALB2], 'R208.1 :: NGS in Leeds' => %w[BRCA1 BRCA2 PALB2], - 'R208.1 :: PALB2 - NGS in Leeds - Analysis only' => %w[BRCA1 BRCA2 PALB2] + 'R208.1 :: PALB2 - NGS in Leeds - Analysis only' => %w[PALB2] }.freeze - R208_GENE_MAPPING_TAR = { - 'R242.1 :: Predictive testing' => %w[BRCA1 BRCA2 PALB2], - 'R242.1 :: Predictive testing MLPA' => %w[BRCA1 BRCA2], - 'R240.1 :: Diagnostic familial' => %w[BRCA1 BRCA2 PALB2], - 'R240.1 :: Diagnostic Familial BRCA1 MLPA' => %w[BRCA1], - 'R370.1 :: Confirmation of research result' => %w[BRCA1 BRCA2 PALB2] + R208_GENE_MAPPING_TAR = [ + 'R242.1 :: Predictive testing', + 'R242.1 :: Predictive testing MLPA', + 'R240.1 :: Diagnostic familial', + 'R240.1 :: Diagnostic Familial BRCA1 MLPA', + 'R370.1 :: Confirmation of research result' + ].freeze + + R208_GENE_MAPPING_FS_NEW = { + 'R208.1 :: NGS in Leeds' => %w[ATM BRCA1 BRCA2 CHEK2 PALB2], + 'R208.1 :: NGS in Leeds - Send DNA to Leeds' => %w[ATM BRCA1 BRCA2 CHEK2 PALB2], + 'R208.1 :: PALB2 - NGS in Leeds - Analysis only' => %w[PALB2], + 'R387.1 :: BRCA1 BRCA2 PALB2 analysis only' => %w[BRCA1 BRCA2 PALB2] }.freeze - R240_GENE_MAPPING_TAR = { - 'R242.1 :: Familial diagnostic testing - ATM gene' => %w[ATM] + R208_GENE_MAPPING_TAR_NEW = [ + 'R240.1 :: Diagnostic familial - Seq in Leeds - Send Blood', + 'R242.1 :: Predictive testing', + 'R242.1 :: Predictive testing - MLPA in Leeds - Send Blood', + 'R242.1 :: Predictive testing - Seq in Leeds - Analysis only', + 'R242.1 :: Predictive testing - Seq in Leeds - Send Blood', + 'R242.1 :: Predictive testing - Seq in Leeds - Send DNA', + 'R242.1 :: Predictive testing - Seq in Sheffield', + 'R242.1 :: Predictive testing MLPA' + ].freeze + + R240_GENE_MAPPING_TAR = [ + 'R242.1 :: Familial diagnostic testing - ATM gene' + ].freeze + + R242_GENE_MAPPING_TAR = [ + 'R242.1 :: Predictive testing - ATM gene' + ].freeze + + R430_GENE_MAPPING_FS = { + 'R420.1 :: NGS in Leeds - Send Blood' => %w[ATM BRCA1 BRCA2 CHEK2 MLH1 MSH2 MSH6 PALB2] }.freeze - R242_GENE_MAPPING_TAR = { - 'R242.1 :: Predictive testing - ATM gene' => %w[ATM] + R444_GENE_MAPPING = { + 'R444.1 :: PARPi for Breast cancer - NGS in Leeds' => %w[ATM BRCA1 BRCA2 CHEK2 PALB2 RAD51C RAD51D], + 'R444.2 :: PARPi for Prostate Cancer - NGS in Leeds send DNA to Leeds' => %w[BRCA1 BRCA2] }.freeze PASS_THROUGH_FIELDS = %w[consultantcode @@ -173,33 +204,46 @@ module RcuConstants 'R224 :: Inherited renal cancer', 'R365 :: Fumarate hydratase-related tumour syndromes'].freeze + GENES_LIST = %w[ATM BRCA1 BRCA2 BRIP1 CDH1 CHEK2 EPCAM + MLH1 MSH2 MSH6 NBN PALB2 PTEN RAD51C RAD51D + STK11 TP53 PMS2 ].freeze + BRCA_REGEX = /(?BRCA1|BRCA2|PALB2|ATM|CHEK2|TP53|MLH1|CDH1| - MSH2|MSH6|PMS2|STK11|PTEN|BRIP1|NBN|RAD51C|RAD51D)/ix + MSH2|MSH6|PMS2|STK11|PTEN|BRIP1|NBN|RAD51C|RAD51D|EPCAM)/ix # rubocop:disable Lint/MixedRegexpCaptureTypes - 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][+>_-][ACGTdelinsup])| - ([0-9]+[ACGTdelinsup]+[+>_-][ACGTdelinsup])| - ([0-9]+[+>_-][0-9]+[ACGTdelinsup]+)| - ([0-9]+[+>_-][0-9]+[+>_-][0-9]+[0-9]+[ACGTdelinsup]+)| - ([0-9]+[?+>_-]+[0-9]+[?+>_-]+[ACGTdelinsup]+)| - ([0-9]+[ACGTdelinsup]+) - )\]?/ix + 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 MLPA_FAIL_REGEX = /#{BRCA_REGEX}\s(?MLPA?\sfail)+/ix - PROTEIN_REGEX = /p\.(\[\()?(?.([a-z]+[0-9]+[a-z]+([^[:alnum:]][0-9]+)?)| - ([a-z]+[0-9]+[^[:alnum:]]))(\)\])?/ix + PROTEIN_REGEX = /(p(\.|\[)(\[)?(\()?(?([a-z]+[0-9]+[a-z]+([^[:alnum:]][0-9]+)?)| + ([a-z]+[0-9]+[^[:alnum:]]([a-z]+[0-9]+[delinsup]+)?)))/ix 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]+)?))| + (?[0-9]+((to|_|and|&|-|\s)+[0-9]+)?))| ((?het|homo)[a-z ]+)? - (?exon|exons)\s(?[0-9]+((to|and|-|\s)+[0-9]+)?) - ([a-z ]+(?deletion|duplication|duplicated))?/ix + (?exon|exons|ex)\s?(?[0-9]+((to|_|and|&|-|\s)+[0-9]+)?) + ([a-z\s]+(?del(etion)?|duplicati?on|dup(licated)?))?/ix NORMAL_VAR_REGEX = %r{(?no|not)[a-z /]+ (?detect|report|detet|mutation)+}ix diff --git a/test/lib/import/brca/providers/sheffield/sheffield_handler_test.rb b/test/lib/import/brca/providers/sheffield/sheffield_handler_test.rb index 6643ee34..3b554f81 100644 --- a/test/lib/import/brca/providers/sheffield/sheffield_handler_test.rb +++ b/test/lib/import/brca/providers/sheffield/sheffield_handler_test.rb @@ -39,7 +39,7 @@ def setup genotypes = @handler.process_variants_from_record(@genotype, @record) assert_equal 1, genotypes.size assert_equal 2, genotypes[0].attribute_map['teststatus'] - assert_equal 'c.520C>T', genotypes[0].attribute_map['codingdnasequencechange'] + assert_equal 'c.[520C>T]', genotypes[0].attribute_map['codingdnasequencechange'] assert_nil genotypes[0].attribute_map['proteinimpact'] assert_equal 8, genotypes[0].attribute_map['gene'] end @@ -134,7 +134,7 @@ def setup # positive genes assert_equal 2, genotypes[0].attribute_map['teststatus'] assert_nil genotypes[0].attribute_map['proteinimpact'] - assert_equal 'c.4986+4_4986+13del', genotypes[0].attribute_map['codingdnasequencechange'] + assert_equal 'c.[4986+4_4986+13del]', genotypes[0].attribute_map['codingdnasequencechange'] assert_equal 7, genotypes[0].attribute_map['gene'] # negative gene @@ -177,7 +177,7 @@ def setup assert_equal 2, genotypes[1].attribute_map['teststatus'] assert_equal 8, genotypes[1].attribute_map['gene'] - assert_equal 'c.7069_7070del', genotypes[1].attribute_map['codingdnasequencechange'] + assert_equal 'c.[7069_7070del]', genotypes[1].attribute_map['codingdnasequencechange'] assert_equal 'p.Leu2357fs', genotypes[1].attribute_map['proteinimpact'] end @@ -251,13 +251,13 @@ def setup @handler.add_test_scope_from_geno_karyo(@genotype, malformed_mutation_fs_record) genotypes = @handler.process_variants_from_record(@genotype, malformed_mutation_fs_record) assert_equal 2, genotypes.size - assert_equal 4, genotypes[0].attribute_map['teststatus'] - assert_equal 4, genotypes[1].attribute_map['teststatus'] - assert_equal 7, genotypes[0].attribute_map['gene'] - assert_equal 8, genotypes[1].attribute_map['gene'] + assert_equal 2, genotypes[0].attribute_map['teststatus'] + assert_equal 1, genotypes[1].attribute_map['teststatus'] + assert_equal 8, genotypes[0].attribute_map['gene'] + assert_equal 7, genotypes[1].attribute_map['gene'] assert_nil genotypes[0].attribute_map['exonintroncodonnumber'] - assert_nil genotypes[0].attribute_map['proteinimpact'] - assert_nil genotypes[0].attribute_map['codingdnasequencechange'] + assert_equal 'p.Gln2859fs', genotypes[0].attribute_map['proteinimpact'] + assert_equal 'c.[8575del]', genotypes[0].attribute_map['codingdnasequencechange'] assert_equal 'Full screen BRCA1 and BRCA2', genotypes[0].attribute_map['genetictestscope'] assert_equal 'Full screen BRCA1 and BRCA2', genotypes[1].attribute_map['genetictestscope'] end