Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def extract_genes_from_raw_fields
exon = raw_record['exon']
genotype2 = raw_record['genotype2']
next if MSH6_DOSAGE_MTYPE.include?(moltesttype) && !exon.scan(/MLPA/i).size.positive?
next if moltesttype.match?(/dosage/i) && !exon.match?(/MLPA|P003/i)
next if moltesttype&.match?(/dosage/i) && !exon.match?(/MLPA|P003/i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, if nil values are allowed, you can write these comparisons as:

 next if /dosage/i.match?(moltesttype) && !/MLPA|P003/i.match?(exon)

without needing to think about safe navigation.

However, in this case, I can see that having nil inputs for comparison might be a logical error, so maybe it's better to do what's happened here, fail with an exception, and then explicitly flag the exceptions with safe navigation.

irb> /el/.match?('hello')
=> true
irb> /el/.match?('world')
=> false
irb> /el/.match?(nil)
=> false

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Brian, yes nil values are acceptable in this case, i've amended the code to you suggested first option in a new PR #171


genes_found << find_genes_genotype(exon, moltesttype, genotype, genotype2)
end
Expand All @@ -152,7 +152,7 @@ def find_genes_genotype(exon, moltesttype, genotype, genotype2)
genotype2_genes = genotype2&.scan(COLORECTAL_GENES_REGEX).to_a
if exon.match?('NGS')
genotype == 'No pathogenic variant identified' ? exon_genes : genotype_genes
elsif exon.match?(/P003/i) && moltesttype.match?(/dosage/i)
elsif exon.match?(/P003/i) && moltesttype&.match?(/dosage/i)
%w[MLH1 MSH2] + [genotype_genes + genotype2_genes]
elsif exon == 'MLH1_MSH2_MSH6_NGS-POOL' &&
genotype == 'No pathogenic variant identified'
Expand Down
Loading