Skip to content

Commit

Permalink
Merge pull request #4640 from sanger/4409-y24-379--study-setup-fields…
Browse files Browse the repository at this point in the history
…-to-align-to-the-ena-database-fields

Reapply "4409 y24 379  study setup fields to align to the ena databas…
  • Loading branch information
wendyyang authored Feb 5, 2025
2 parents 088dcf7 + 363ff25 commit 8501436
Show file tree
Hide file tree
Showing 20 changed files with 180 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/api/io/study.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Io::Study < Core::Io::Base
study_metadata.commercially_available => commercially_available
study_metadata.data_release_study_type.name => data_release_sort_of_study
study_metadata.data_release_strategy => data_release_strategy
study_metadata.contaminated_human_data_access_group => contaminated_human_data_access_group
study_metadata.contaminated_human_data_access_group => contaminated_human_data_access_group
'
)
end
3 changes: 3 additions & 0 deletions app/models/api/study_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,8 @@ def render_class
map_attribute_to_json_attribute(:data_deletion_period)
map_attribute_to_json_attribute(:contaminated_human_data_access_group)
with_association(:program, lookup_by: :id) { map_attribute_to_json_attribute(:name, 'programme') }
map_attribute_to_json_attribute(:ebi_library_strategy)
map_attribute_to_json_attribute(:ebi_library_source)
map_attribute_to_json_attribute(:ebi_library_selection)
end
end
13 changes: 13 additions & 0 deletions app/models/study.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ class Study < ApplicationRecord # rubocop:todo Metrics/ClassLength

DATA_RELEASE_DELAY_PERIODS = ['3 months', '6 months', '9 months', '12 months', '18 months'].freeze

EBI_LIBRARY_STRATEGY_OPTIONS = Rails.configuration.ena_requirement_fields['EBI_Library_strategy']
EBI_LIBRARY_SOURCE_OPTIONS = Rails.configuration.ena_requirement_fields['EBI_Library_source']
EBI_LIBRARY_SELECTION_OPTIONS = Rails.configuration.ena_requirement_fields['EBI_Library_selection']

# Class variables
self.per_page = 500

Expand Down Expand Up @@ -214,6 +218,11 @@ class Study < ApplicationRecord # rubocop:todo Metrics/ClassLength
custom_attribute(:commercially_available, required: true, in: YES_OR_NO)
custom_attribute(:study_name_abbreviation)

# add ebi library strategy
custom_attribute(:ebi_library_strategy, required: true, in: EBI_LIBRARY_STRATEGY_OPTIONS)
custom_attribute(:ebi_library_source, required: true, in: EBI_LIBRARY_SOURCE_OPTIONS)
custom_attribute(:ebi_library_selection, required: true, in: EBI_LIBRARY_SELECTION_OPTIONS)

custom_attribute(
:data_release_strategy,
required: true,
Expand Down Expand Up @@ -309,6 +318,10 @@ class Study < ApplicationRecord # rubocop:todo Metrics/ClassLength
allow_blank: true
}

validates :ebi_library_strategy, inclusion: { in: EBI_LIBRARY_STRATEGY_OPTIONS }
validates :ebi_library_source, inclusion: { in: EBI_LIBRARY_SOURCE_OPTIONS }
validates :ebi_library_selection, inclusion: { in: EBI_LIBRARY_SELECTION_OPTIONS }

before_validation do |record|
record.reference_genome_id = 1 if record.reference_genome_id.blank?

Expand Down
5 changes: 4 additions & 1 deletion app/uat_actions/uat_actions/generate_sample_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def study
contaminated_human_dna: 'No',
contains_human_dna: 'No',
commercially_available: 'No',
program: UatActions::StaticRecords.program
program: UatActions::StaticRecords.program,
ebi_library_strategy: 'WGS',
ebi_library_source: 'GENOMIC',
ebi_library_selection: 'PCR'
}
).find_or_create_by!(name: study_name)
end
Expand Down
5 changes: 4 additions & 1 deletion app/uat_actions/uat_actions/generate_study.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def create_study
contaminated_human_dna: 'No',
contains_human_dna: 'No',
commercially_available: 'No',
program: UatActions::StaticRecords.program
program: UatActions::StaticRecords.program,
ebi_library_strategy: 'WGS',
ebi_library_source: 'GENOMIC',
ebi_library_selection: 'PCR'
}
).find_or_create_by!(name: study_name)
end
Expand Down
5 changes: 4 additions & 1 deletion app/uat_actions/uat_actions/static_records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def self.study
contaminated_human_dna: 'No',
contains_human_dna: 'No',
commercially_available: 'No',
program: program
program: program,
ebi_library_strategy: 'WGS',
ebi_library_source: 'GENOMIC',
ebi_library_selection: 'PCR'
}
).find_or_create_by!(name: 'UAT Study')
end
Expand Down
7 changes: 5 additions & 2 deletions app/views/shared/metadata/edit/_study.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
<%= metadata_fields.text_field(:prelim_id) %>

<%= metadata_fields.select_by_association(:reference_genome, {}, { class: 'select2' }) %>
<%= metadata_fields.select_by_association(:study_type)%>

<% metadata_fields.with_options(grouping: 'ENA requirement') do |group| %>
<%= group.text_field(:study_study_title) %>
<%= group.select_by_association(:study_type)%>
<%= group.text_area(:study_description) %>
<%= group.text_area(:study_abstract) %>
<%= group.radio_select(:study_sra_hold, Study::STUDY_SRA_HOLDS) %>
<% end %>
<%= metadata_fields.select(:ebi_library_strategy, Study::EBI_LIBRARY_STRATEGY_OPTIONS) %>
<%= metadata_fields.select(:ebi_library_source, Study::EBI_LIBRARY_SOURCE_OPTIONS) %>
<%= metadata_fields.select(:ebi_library_selection, Study::EBI_LIBRARY_SELECTION_OPTIONS) %>
<% end %>

<%= metadata_fields.radio_select(:contains_human_dna, Study::YES_OR_NO) %>
<%= metadata_fields.radio_select(:contaminated_human_dna, Study::YES_OR_NO) %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/shared/metadata/show/_study.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<%= group.plain_value(:study_sra_hold) %>
<% end %>

<%= metadata_fields.plain_value(:ebi_library_strategy) %>
<%= metadata_fields.plain_value(:ebi_library_source) %>
<%= metadata_fields.plain_value(:ebi_library_selection) %>

<%= metadata_fields.plain_value(:contains_human_dna) %>
<%= metadata_fields.plain_value(:contaminated_human_dna) %>
<%= metadata_fields.plain_value(:commercially_available) %>
Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class Application < Rails::Application

config.phi_x = config_for(:phi_x).with_indifferent_access

# add ena requirement fields here
config.ena_requirement_fields = config_for(:ena_requirement_fields)

config.generators do |g|
g.test_framework :rspec,
fixtures: true,
Expand Down
64 changes: 64 additions & 0 deletions config/ena_requirement_fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
default: &DEFAULT
EBI_Library_strategy:
- "RNA-Seq"
- "ChIP-Seq"
- "WGS"
- "WXS"
- "AMPLICON"
- "CLONE"
- "POOLCLONE"
- "CLONEEND"
- "Bisulfite-Seq"
- "MNase-Seq"
- "DNase-Hypersensitivity"
- "FAIRE-seq"
- "SELEX"
- "RIP-Seq"
- "ChIA-PET"
- "OTHER"
EBI_Library_source:
- "GENOMIC"
- "TRANSCRIPTOMIC"
- "METAGENOMIC"
- "METATRANSCRIPTOMIC"
- "SYNTHETIC"
- "VIRAL RNA"
- "OTHER"
EBI_Library_selection:
- "RANDOM"
- "PCR"
- "RANDOM PCR"
- "RT-PCR"
- "HMPR"
- "MF"
- "CF-S"
- "CF-M"
- "CF-T"
- "MDA"
- "MSLL"
- "cDNA"
- "ChIP"
- "MNase"
- "DNAse"
- "Hybrid Selection"
- "Reduced Representation"
- "Restriction Digest"
- "5-methylcytidine antibody"
- "MBD2 protein methyl-CpG binding domain"

development:
<<: *DEFAULT
next_release:
<<: *DEFAULT
test:
<<: *DEFAULT
cucumber:
<<: *DEFAULT
production:
<<: *DEFAULT
staging:
<<: *DEFAULT
staging_2:
<<: *DEFAULT
training:
<<: *DEFAULT
14 changes: 13 additions & 1 deletion config/locales/metadata/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ en:

study_type_id:
label: Study Type
edit_info: "ENA requirement"

study_ebi_accession_number:
label: ENA Study Accession Number
Expand Down Expand Up @@ -522,6 +521,19 @@ en:
contaminated_human_data_access_group:
label: Contaminated Human Data Access Group
help: "Allows specified Unix groups and users access to data segregated from the main data product, which is potentially contaminated with human data. This access is typically rarely used and is primarily for validating the separation process, as we may not have the ethical or legal clearance."

ebi_library_strategy:
label: EBI Library Strategy
edit_info: "ENA requirement"

ebi_library_source:
label: EBI Library Source
edit_info: "ENA requirement"

ebi_library_selection:
label: EBI Library Selection
edit_info: "ENA requirement"

project:
metadata:
project_manager_id:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true
class AddEbiRequirementFieldsToStudyMetadata < ActiveRecord::Migration[6.1]
def change
add_column :study_metadata, :ebi_library_strategy, :string, default: nil
add_column :study_metadata, :ebi_library_source, :string, default: nil
add_column :study_metadata, :ebi_library_selection, :string, default: nil
end
end
3 changes: 3 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,9 @@
t.string "s3_email_list"
t.string "data_deletion_period"
t.string "contaminated_human_data_access_group"
t.string "ebi_library_strategy"
t.string "ebi_library_source"
t.string "ebi_library_selection"
t.string "data_release_prevention_other_comment"
t.index ["faculty_sponsor_id"], name: "index_study_metadata_on_faculty_sponsor_id"
t.index ["study_id"], name: "index_study_metadata_on_study_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@ Feature: The XML for the sequencescape API
<descriptor><name>Policy Url</name></descriptor>
<descriptor><name>Policy title</name></descriptor>
<descriptor><name>ArrayExpress Accession Number</name></descriptor>
<descriptor>
<name>EBI Library Strategy</name>
<value>WGS</value>
</descriptor>
<descriptor>
<name>EBI Library Source</name>
<value>GENOMIC</value>
</descriptor>
<descriptor>
<name>EBI Library Selection</name>
<value>PCR</value>
</descriptor>
</descriptors>
</study>
"""
Expand Down
5 changes: 4 additions & 1 deletion features/support/step_definitions/study_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ def assign_asset_to_study(asset, study_name)
data_release_study_type: DataReleaseStudyType.first,
contaminated_human_dna: 'No',
contains_human_dna: 'Yes',
commercially_available: 'No'
commercially_available: 'No',
ebi_library_strategy: 'WGS',
ebi_library_source: 'GENOMIC',
ebi_library_selection: 'PCR'
}
)
end
Expand Down
5 changes: 4 additions & 1 deletion lib/working_setup/standard_seeder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def create_study(name)
contaminated_human_dna: 'No',
contains_human_dna: 'No',
commercially_available: 'No',
program_id: program.id
program_id: program.id,
ebi_library_strategy: 'WGS',
ebi_library_source: 'GENOMIC',
ebi_library_selection: 'PCR'
}
) do |study|
study.activate!
Expand Down
5 changes: 4 additions & 1 deletion spec/controllers/studies_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
'commercially_available' => 'No',
'data_release_study_type_id' => data_release_study_type,
'data_release_strategy' => 'open',
'study_type_id' => StudyType.find_or_create_by(name: 'Not specified').id
'study_type_id' => StudyType.find_or_create_by(name: 'Not specified').id,
'ebi_library_strategy' => 'WGS',
'ebi_library_source' => 'GENOMIC',
'ebi_library_selection' => 'PCR'
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions spec/factories/study_metadata_factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
s3_email_list { '[email protected];[email protected]' }
data_deletion_period { '3 months' }

ebi_library_strategy { 'WGS' }
ebi_library_source { 'GENOMIC' }
ebi_library_selection { 'PCR' }

transient { contaminated_human_data_access_group { nil } }

after(:build) do |study_metadata, evaluator|
Expand Down
8 changes: 7 additions & 1 deletion spec/models/api/study_io_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
ega_policy_accession_number: 'EGA222',
ega_dac_accession_number: 'DAC333',
program: create(:program, name: 'General'),
contaminated_human_data_access_group: 'contaminated human data access group test'
contaminated_human_data_access_group: 'contaminated human data access group test',
ebi_library_strategy: 'WGS',
ebi_library_source: 'GENOMIC',
ebi_library_selection: 'PCR'
}
)
end
Expand Down Expand Up @@ -57,6 +60,9 @@
'data_deletion_period' => '3 months',
'contaminated_human_data_access_group' => 'contaminated human data access group test',
'programme' => 'General',
'ebi_library_strategy' => 'WGS',
'ebi_library_source' => 'GENOMIC',
'ebi_library_selection' => 'PCR',
'manager' => [
{ login: manager.login, email: manager.email, name: manager.name },
{ login: manager2.login, email: manager2.email, name: manager2.name }
Expand Down
17 changes: 16 additions & 1 deletion spec/models/study_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,10 @@
number_of_gigabases_per_sample: 6,
hmdmc_approval_number: 'HDMC123456',
s3_email_list: '[email protected];[email protected]',
data_deletion_period: '3 months'
data_deletion_period: '3 months',
ebi_library_strategy: 'WGS',
ebi_library_source: 'GENOMIC',
ebi_library_selection: 'PCR'
}
end

Expand Down Expand Up @@ -645,6 +648,18 @@
expect(study.study_metadata.faculty_sponsor).not_to be_nil
end

it 'must have a ebi library strategy' do
expect(study.study_metadata.ebi_library_strategy).not_to be_nil
end

it 'must have a ebi library source' do
expect(study.study_metadata.ebi_library_source).not_to be_nil
end

it 'must have a ebi library selection' do
expect(study.study_metadata.ebi_library_selection).not_to be_nil
end

context 'contaminated human data access group' do
it 'defaults to null when not specified' do
expect(study.study_metadata.contaminated_human_data_access_group).to be_nil
Expand Down

0 comments on commit 8501436

Please sign in to comment.