Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dms-2024-i4-r4 #117

Merged
merged 8 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
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
38 changes: 1 addition & 37 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,14 @@ gem 'pg', '~> 1.4.6' # All client instance have postgres version >= 9.3
gem 'puma', '~> 6.0'
gem 'puma-daemon', require: false

# We have built our own CentOS 7 binaries for various gems
# (with separate gem files for different ruby versions)
# Copy these into place if needed
def add_custom_centos_7_binaries(gem_dir_basename, gem_fnames)
gem_dir = if RUBY_PLATFORM == 'x86_64-linux' && File.exist?('/etc/os-release') &&
File.readlines('/etc/os-release').grep(/^(ID="centos"|VERSION_ID="7")$/).count == 2
"vendor/#{gem_dir_basename}-x86_64-linux-ruby#{RUBY_VERSION.split('.')[0..1].join}"
end
require 'fileutils'
gem_fnames.each do |gem_fname|
if gem_dir && Dir.exist?(gem_dir)
begin
FileUtils.cp "#{gem_dir}/#{gem_fname}", 'vendor/cache/'
rescue Errno::EACCES
# Deployer account may not have write access to vendor/cache/
# (in which case the file in vendor/cache/ is probably already correct)
end
else
FileUtils.rm_f "vendor/cache/#{gem_fname}"
end
end
end

# Use SCSS for stylesheets
gem 'sass-rails'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# gem 'mini_racer'
# Allow mini_racer version to be overridden in a custom Gemfile
# We need this for mini_racer on Mac OS Monterey, where the old libv8 no longer compiles
unless defined?(BUNDLER_OVERRIDE_MINI_RACER) && BUNDLER_OVERRIDE_MINI_RACER
# We have built our own CentOS 7 binaries for mini_racer
# (with separate gem files for Ruby 3.0 and Ruby 3.1)
# Copy these into place if needed
mini_racer_version = '0.12.0'
add_custom_centos_7_binaries('mini_racer',
["mini_racer-#{mini_racer_version}-x86_64-linux.gem"])
gem 'libv8-node', '~> 21.7.2.0'
# gem 'mini_racer', '~> 0.12.0'
# Lock the gem version: if this changes, we need to rebuild our binaries
gem 'mini_racer', mini_racer_version
end
gem 'mini_racer', '~> 0.14'

gem 'parser'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
Expand Down
29 changes: 15 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ GEM
execjs (~> 2)
avro (1.11.2)
multi_json (~> 1.0)
base64 (0.2.0)
bcrypt (3.1.19)
bindex (0.8.1)
bio-vcf (0.9.5)
Expand Down Expand Up @@ -208,13 +209,14 @@ GEM
json (2.6.3)
launchy (2.5.2)
addressable (~> 2.8)
libv8-node (21.7.2.0)
libv8-node (21.7.2.0-arm64-darwin)
libv8-node (21.7.2.0-x86_64-darwin)
libv8-node (21.7.2.0-x86_64-linux)
libv8-node (18.19.0.0)
libv8-node (18.19.0.0-arm64-darwin)
libv8-node (18.19.0.0-x86_64-darwin)
libv8-node (18.19.0.0-x86_64-linux)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.1)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -226,10 +228,8 @@ GEM
method_source (1.0.0)
mini_mime (1.1.5)
mini_portile2 (2.8.4)
mini_racer (0.12.0)
libv8-node (~> 21.7.2.0)
mini_racer (0.12.0-x86_64-linux)
libv8-node (~> 21.7.2.0)
mini_racer (0.14.1)
libv8-node (~> 18.19.0.0)
minitest (5.19.0)
mocha (2.1.0)
ruby2_keywords (>= 0.0.5)
Expand Down Expand Up @@ -367,7 +367,7 @@ GEM
pry (>= 0.10.4)
psych (3.3.2)
public_suffix (5.0.3)
puma (6.4.2)
puma (6.4.3)
nio4r (~> 2.0)
puma-daemon (0.3.2)
puma (>= 5.0)
Expand Down Expand Up @@ -451,8 +451,8 @@ GEM
ruby-ole (1.2.12.2)
ruby-progressbar (1.13.0)
ruby-rc4 (0.1.5)
ruby-saml (1.14.0)
nokogiri (>= 1.10.5)
ruby-saml (1.17.0)
nokogiri (>= 1.13.10)
rexml
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
Expand All @@ -467,7 +467,9 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (4.12.0)
selenium-webdriver (4.24.0)
base64 (~> 0.2)
logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -560,10 +562,9 @@ DEPENDENCIES
highline
jquery-rails
jquery-ui-rails!
libv8-node (~> 21.7.2.0)
loofah (>= 2.3.1)
mail (>= 2.1.1, < 2.8.0)
mini_racer (= 0.12.0)
mini_racer (~> 0.14)
minitest
mocha
ndr_authenticate (~> 0.3, >= 0.3.3)
Expand Down
6 changes: 5 additions & 1 deletion app/models/pseudo/death.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ def multiple_cause_code(i)
# and cod10rf_... / cod10r_... fields, to exclusively cod10rf_... / cod10r_... fields.
def matched_cause_codes(i)
raise 'Invalid index' unless (1..6).include?(i)

# lineno values are always 1-6
causes = (1..20).collect do |j|
cod10r = death_data.send("cod10rf_#{j}") || death_data.send("cod10r_#{j}")
line = death_data.send("lineno9f_#{j}") || death_data.send("lineno9_#{j}")
# More recent deaths have inconsistently back-ported lineno values from cod10r values
line = nil if cod10r && line && death_data.dor.to_i >= 20180206 # diffs
# Prefer old lineno9 value, for continuity, and because it's more finegrained
raise 'New death cause 1d not yet supported' if cod10r == 'f'

next unless (line || DeathData::COD10R_TO_LINENO9[cod10r]) == i

multiple_cause_code(j)
end
causes.compact
Expand All @@ -60,7 +64,7 @@ def codt_codfft_extra(i, chunk_size = 75, merge_extra = false)
codfft = death_data.codfft_1
return codfft[(i - 1) * chunk_size..(i * chunk_size) - 1] if codfft && codfft.size > 75

result = death_data["codfft_#{i}"] || (death_data["codt_#{i}"] if i <= 5)
result = death_data["codfft_#{i}"] || (death_data["codt_#{i}"] if i <= 6)
return result unless merge_extra

([result] + (i + 1..65).collect { |j| death_data["codfft_#{j}"] }).
Expand Down
8 changes: 6 additions & 2 deletions app/models/pseudo/death_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DeathData < ActiveRecord::Base
# Numerics from M204
# lower case letters from LEDR
# (-- 0 01 02 03 1` Y 5 6 7 9 41 92 are very rare, and only in older M204 data),
COD10R_VALUES = %w[-- 0 01 02 03 1` Y 1 2 3 4 5 6 7 9 10 11 12 41 92 a b c d e].freeze
COD10R_VALUES = %w[-- 0 01 02 03 1` Y 1 2 3 4 5 6 7 9 10 11 12 41 92 a b c d e f].freeze
RETIND_VALUES = %w[1 Y N].freeze # Numeric values from M204, strings from LEDR

# PLOACC10 is supposed to be 1 numerical character (or blank)
Expand All @@ -32,7 +32,11 @@ class DeathData < ActiveRecord::Base
# cod10r c = c = line 10
# cod10r d = d = line 11
# cod10r e = e = line 12
COD10R_TO_LINENO9 = { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 4,
#
# From 2024-09-09, an extra cause of death 1d field has been added.
# For now, we're mapping this back to cause 1c in LINENO9 terms, to ensure it does not
# get lost, but COD10R_TO_LINENO9 should be deprecated, or used the other way around.
COD10R_TO_LINENO9 = { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 4, 'f' => 3,
'1' => 1, '2' => 2, '3' => 3, '4' => 4, '10' => 4,
'11' => 6, '12' => 6 }.freeze

Expand Down
19 changes: 6 additions & 13 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@
ruby -e "require 'yaml'; puts YAML.dump('production' => { 'secret_key_base' => 'compile_me' })" > config/secrets.yml
touch config/special_users.production.yml config/admin_users.yml config/odr_users.yml \
config/user_yubikeys.yml
# Remove mini_racer CentOS 7 shim from Gemfile.lock unless needed
if [ -e /etc/os-release ] && \
[ 2 -ne $(grep -Ec '^(ID="centos"|VERSION_ID="7")$' /etc/os-release) ]; then
sed -i.bak -e '/mini_racer ([0-9.]*-x86_64-linux)/,+1d' Gemfile.lock
fi
printf 'disable-self-update-check true\\nyarn-offline-mirror "./vendor/npm-packages-offline-cache"\\nyarn-offline-mirror-pruning false\\n' > .yarnrc
RAILS_ENV=production bundle exec rake assets:clobber assets:precompile
rm config/secrets.yml config/database.yml
Expand Down Expand Up @@ -179,14 +174,12 @@

desc 'ensure additional configuration for CentOS deployments'
task :centos_deployment_specifics do
if /\A(3[.]0[.][567]|3[.][123][.])/.match?(fetch(:ruby))
# On CentOS 7, we need a newer GCC installation to build gems for new ruby versions
# We'd like to do the following, but scl incorrectly handles double quotes in passed commands:
# set :default_shell, 'scl enable devtoolset-9 -- sh'
set :default_shell, <<~CMD.chomp
sh -c 'scl_run() { echo "$@" | scl enable devtoolset-9 -; }; scl_run "$@"'
CMD
end
# On CentOS 7, we need a newer GCC installation to build gems for new ruby versions
# We'd like to do the following, but scl incorrectly handles double quotes in passed commands:
# set :default_shell, 'scl enable devtoolset-9 -- sh'
set :default_shell, <<~CMD.chomp
sh -c 'scl_run() { echo "$@" | scl enable devtoolset-9 -; }; scl_run "$@"'
CMD
end

# ==========================================[ DEPLOY ]==========================================
Expand Down
4 changes: 4 additions & 0 deletions config/mappings/deaths_mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1222,3 +1222,7 @@ columns:
- column: ward9r
mappings:
- field: ward9r
- column: codt_6
mappings:
- field: codt_6
clean: :itself
29 changes: 29 additions & 0 deletions db/migrate/20240923153521_add_codt_6_to_pseudo_deathdata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Add column codt_6 to deathdata table
# New field for cause of death line 1(d)
# Previously we had:
# CODT_1 = 1a/a
# CODT_2 = 1b/b
# CODT_3 = 1c/c
# CODT_4 = II/d
# CODT_5 = II/e
# now we have:
# CODT_1 = 1a/a
# CODT_2 = 1b/b
# CODT_3 = 1c/c
# CODT_6 = 1d/d
# CODT_4 = II/d
# CODT_5 = II/e
# Change from 2024-09-09: New field for cause of death line 1(d) on non-neonatal deaths
# CODT_6 = 1d/f
# In the registration it is positioned between CODT_3 and CODT_4
#
# "From April 2024 a new MCCD [Medical certificate of cause of death] will
# replace the existing one to reflect the introduction of medical examiners and
# bring the new MCCD in line with international standards. These changes will
# impact how certifying doctors, medical examiners and coroners capture cause
# of death information on MCCDs/Coroner forms."
class AddCodt6ToPseudoDeathdata < ActiveRecord::Migration[6.1]
def change
add_column :death_data, :codt_6, :string
end
end
3 changes: 2 additions & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8332,6 +8332,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220428152502'),
('20220816095442'),
('20230525133522'),
('20240620121939');
('20240620121939'),
('20240923153521');


1 change: 1 addition & 0 deletions lib/import/brca/providers/newcastle/newcastle_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def process_fields(record)
add_organisationcode_testresult(genotype)
process_test_scope(genotype, record)
process_test_status(genotype, record)
process_test_type(genotype, record)
final_results = process_variant_records(genotype, record)
final_results.each { |cur_genotype| @persister.integrate_and_store(cur_genotype) }
end
Expand Down
6 changes: 6 additions & 0 deletions lib/import/colorectal/core/genocolorectal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class Genocolorectal < Import::Germline::Genotype
'TP53' => 79,
'PALB2' => 3186,
'RNF43' => 5019,
'CHEK2' => 865,
'RAD51C' => 3615,
'RAD51D' => 3616,
'VHL' => 83,
'ATM' => 451 }.freeze

Expand All @@ -62,6 +65,9 @@ class Genocolorectal < Import::Germline::Genotype
(?<tp53>TP53)|
(?<palb2>PALB2)|
(?<rnf43>RNF43)|
(?<chek2>CHEK2)|
(?<rad51c>RAD51C)|
(?<rad51d>RAD51D)|
(?<vhl>VHL) |
(?<atm>ATM)/ix # Added by Francesco

Expand Down
29 changes: 27 additions & 2 deletions lib/import/colorectal/providers/leeds/leeds_handler_colorectal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,17 @@ def process_fullscreen_records(genocolorectal, record, genotypes)
end

def process_normal_fs(genocolorectal, _record, genotypes)
@genes_panel&.each do |gene|
if @genes_panel.blank?
genocolorectal_new = genocolorectal.dup_colo
genocolorectal_new.add_gene_colorectal(gene)
genocolorectal_new.add_status(@teststatus)
genotypes << genocolorectal_new
else
@genes_panel&.each do |gene|
genocolorectal_new = genocolorectal.dup_colo
genocolorectal_new.add_gene_colorectal(gene)
genocolorectal_new.add_status(@teststatus)
genotypes << genocolorectal_new
end
end
genotypes
end
Expand Down Expand Up @@ -306,6 +312,10 @@ def allocate_genes
GENES_PANEL.each do |panel, genes|
@genes_panel = genes if @genes_hash[panel].include?(@geno)
end

return if @genes_panel.present?

@genes_panel = genes_from_mtype
end

# Get test status for record based on genotype
Expand Down Expand Up @@ -349,6 +359,21 @@ def get_genes_from_report(report)
genes || []
end

def genes_from_mtype
case @moleculartestingtype
when /r209|diagnostic; lynch/
%w[MLH1 MSH2 MSH6 PMS2]
when /diagnostic/
@indicationcategory == 'fap1&2' ? %w[APC MUTYH] : []
when /r210/
%w[MLH1 MSH2 MSH6 PMS2 EPCAM]
when /r211/
%w[APC BMPR1A EPCAM GREM1 MLH1 MSH2 MSH6 MUTYH NTHL1 PMS2 POLD1 POLE PTEN SMAD4 STK11]
else
[]
end
end

def add_organisationcode_testresult(genocolorectal)
genocolorectal.attribute_map['organisationcode_testresult'] = '699C0'
end
Expand Down
2 changes: 1 addition & 1 deletion lib/import/delimited_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DelimitedFile
(1..20).collect { |i| "cod10r_#{i}" } +
(1..20).collect { |i| "cod10rf_#{i}" } +
(1..65).collect { |i| "codfft_#{i}" } +
(1..5).collect { |i| "codt_#{i}" } +
(1..6).collect { |i| "codt_#{i}" } +
%w[corareat corcertt ctrypob ctryr ctydpod ctydr ctypod ctyr dester doddy dodmt dodyr doinqt
dor emprssdm emprsshf empsecdm empsechf empstdm empsthf esttyped gor9r gorr hautpod hautr
hropod hror] +
Expand Down
2 changes: 2 additions & 0 deletions lib/import/helpers/brca/providers/rq3/rq3_constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module Rq3Constants
[0-9]+[ACGTdelinsup]+)/x

NO_EVIDENCE_REGEX = /no evidence.*?[^cp]\.|no further.*?[^cp]\./i
NO_EVIDENCE_EXCEPTION_REGEX = /however\sthe\spreviously\sreported\sheterozygous\svariant\sc.*\sin\sthe\s\S+
\sgene\sis\snow\sconsidered\sa\svariant\sof\sunknown\ssignificance/ix
PROTEIN_REGEX = /p\.\(?(?<impact>.[a-z]+[0-9]+[a-z]+([^[:alnum:]][0-9]+)?|
[a-z]+[0-9]+[^[:alnum:]])/ix

Expand Down
26 changes: 20 additions & 6 deletions lib/import/helpers/brca/providers/rq3/rq3_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,28 @@ def process_noevidence_records
true_variant = @testresult.gsub(NO_EVIDENCE_REGEX, '')
negativegenes = no_evidence.scan(BRCA_REGEX).flatten - true_variant.
scan(BRCA_REGEX).flatten
process_negative_genes(negativegenes)
@genotype.add_gene(unique_brca_genes_from(true_variant).join)
process_cdna(true_variant, @genotype)
process_protein_impact(true_variant, @genotype)
process_exon(true_variant, @genotype)
no_evidence_exception= @testresult.scan(NO_EVIDENCE_EXCEPTION_REGEX).join
if no_evidence_exception.size.positive?
process_no_evidence_exception(no_evidence_exception)
else
process_negative_genes(negativegenes)
@genotype.add_gene(unique_brca_genes_from(true_variant).join)
process_cdna(true_variant, @genotype)
process_protein_impact(true_variant, @genotype)
process_exon(true_variant, @genotype)
add_variantpathclass_uv_records(@genotype)
@genotypes.append(@genotype)
end
end

def process_no_evidence_exception(testcolumn)
@genotype.add_gene(unique_brca_genes_from(testcolumn).join)
process_cdna(testcolumn, @genotype)
process_protein_impact(testcolumn, @genotype)
process_exon(testcolumn, @genotype)
add_variantpathclass_uv_records(@genotype)
@genotypes.append(@genotype)
end
end

def process_testresult_cdna_variants
if (@testresult.scan(CDNA_REGEX).size > 1) ||
Expand Down
Loading
Loading