diff --git a/db/seeds/example_data/example_config_seeds.rb b/db/seeds/example_data/example_config_seeds.rb new file mode 100644 index 0000000000..852baf6d93 --- /dev/null +++ b/db/seeds/example_data/example_config_seeds.rb @@ -0,0 +1,43 @@ +# Activity Logging and Configuration + +# Log activity +[$project, $investigation, $study, $exp_assay, $model_assay, $data_file1, $data_file2, $model, $publication].each do |item| + ActivityLog.create(action: 'create', + culprit: $guest_user, + controller_name: item.class.name.underscore.pluralize, + activity_loggable: item, + data: item.title) +end + +# Updating programme +disable_authorization_checks do + $program.programme_administrators = [$guest_person, $admin_person] + $program.projects = [$project] + # $program.funding_codes_as_text = ['123456789'] # TODO cannot set funding codes + # Discussion links... + $program.save! +end + +# Configuration +Seek::Config.home_description = '

Welcome to the SEEK Sandbox

+

You can log in with the username: guest and password: guest

+

For more information about SEEK and to see a video, please visit our Website.

' + +Seek::Config.solr_enabled = true +Seek::Config.isa_enabled = true +Seek::Config.observation_units_enabled = true +Seek::Config.programmes_enabled = true +Seek::Config.programme_user_creation_enabled = true +Seek::Config.noreply_sender = 'no-reply@fair-dom.org' +Seek::Config.instance_name = 'SEEK SANDBOX' +Seek::Config.application_name = 'FAIRDOM-SEEK' +Seek::Config.exception_notification_enabled = true +Seek::Config.exception_notification_recipients = ['errors@fair-dom.org'] +Seek::Config.datacite_url = 'https://mds.test.datacite.org/' +Seek::Config.doi_prefix = '10.5072' +Seek::Config.doi_suffix = 'seek.5' +Seek::Config.tag_threshold = 0 # TODO set to 0 or 1 so the tags created in this example_data seeds will be visiblw on the front page. +puts 'Finish configuration' +puts 'Please visit admin site for further configuration, e.g. site_base_host, pubmed_api_email, crossref_api_email, bioportal_api_key, email, doi, admin email' +puts 'Admin account: username admin, password adminadmin. You might want to change admin password.' +puts 'Then make sure solr, workers are running' \ No newline at end of file diff --git a/db/seeds/example_data/example_data.seeds.rb b/db/seeds/example_data/example_data.seeds.rb index 1e4f3a6f77..ff19138158 100644 --- a/db/seeds/example_data/example_data.seeds.rb +++ b/db/seeds/example_data/example_data.seeds.rb @@ -1,238 +1,8 @@ -# Project, Institution, Workgroup -project = Project.where(title: 'Default Project').first_or_create -institution = Institution.where(title: 'Default Institution').first_or_create(country: 'United Kingdom') -workgroup = WorkGroup.where(project_id: project.id, institution_id: institution.id).first_or_create - -admin_user = User.where(login: 'admin').first_or_create( - login: 'admin', - email: 'admin@test1000.com', - password: 'adminadmin', password_confirmation: 'adminadmin' -) - -# Admin and guest -admin_user.activate -admin_user.build_person(first_name: 'Admin', last_name: 'User', email: 'admin@test1000.com') unless admin_user.person -admin_user.save! -admin_user.person.work_groups << workgroup -admin_person = admin_user.person -admin_person.save -puts 'Seeded 1 admin.' - -guest_user = User.where(login: 'guest').first_or_create( - login: 'guest', - email: 'guest@test1000.com', - password: 'guestguest', password_confirmation: 'guestguest' -) -guest_user.activate -guest_user.build_person(first_name: 'Guest', last_name: 'User', email: 'guest@example.com') unless guest_user.person -guest_user.save! -guest_user.person.work_groups << workgroup -guest_person = guest_user.person -guest_person.save -puts 'Seeded 1 guest.' - -# ISA -investigation = Investigation.new(title: 'Central Carbon Metabolism of Sulfolobus solfataricus', - description: 'An investigation in the CCM of S. solfataricus with a focus on the unique temperature adaptations and regulation; using a combined modelling and experimental approach.') -investigation.projects = [project] -investigation.contributor = guest_person -investigation.policy = Policy.create(name: 'default policy', access_type: 1) -investigation.save -puts 'Seeded 1 investigation.' - -study = Study.new(title: 'Carbon loss at high T') -study.contributor = guest_person -study.policy = Policy.create(name: 'default policy', access_type: 1) -study.investigation = investigation -study.save -puts 'Seeded 1 study.' - -exp_assay = Assay.new(title: 'Reconstituted system reference state', - description: 'The four purified enzymes were incubated in assay buffer and consumption of 3PG and production of F6P were measured in time, together with GAP and DHAP concentrations.') -exp_assay.contributor = guest_person -exp_assay.policy = Policy.create(name: 'default policy', access_type: 1) -exp_assay.study = study -exp_assay.assay_class = AssayClass.first -exp_assay.save -puts 'Seeded 1 experimental assay.' - -model_assay = Assay.new(title: 'Model reconstituted system', - description: 'Mathematical model for the reconstituted system with PGK, GAPDH, TPI and FBPAase.') -model_assay.contributor = guest_person -model_assay.policy = Policy.create(name: 'default policy', access_type: 1) -model_assay.study = study -model_assay.assay_class = AssayClass.last -model_assay.save -puts 'Seeded 1 modelling analysis.' - -# Assets -# TODO check filesize -data_file1 = DataFile.new(title: 'Metabolite concentrations during reconstituted enzyme incubation', - description: 'The purified enzymes, PGK, GAPDH, TPI and FBPAase were incubated at 70 C en conversion of 3PG to F6P was followed.') -data_file1.contributor = guest_person -data_file1.projects = [project] -relationship = RelationshipType.where(title: 'Validation data').first -data_file1.policy = Policy.create(name: 'default policy', access_type: 1) -data_file1.content_blob = ContentBlob.new(original_filename: 'ValidationReference.xlsx', - content_type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') -disable_authorization_checks do - data_file1.save - exp_assay.associate(data_file1) - model_assay.associate(data_file1, relationship: relationship) -end -AssetsCreator.create(asset_id: data_file1.id, creator_id: guest_user.id, asset_type: data_file1.class.name) -# copy file -FileUtils.cp File.dirname(__FILE__) + '/' + data_file1.content_blob.original_filename, data_file1.content_blob.filepath -disable_authorization_checks { data_file1.content_blob.save } -puts 'Seeded data file 1.' - -data_file2 = DataFile.new(title: 'Model simulation and Exp data for reconstituted system', - description: 'Experimental data for the reconstituted system are plotted together with the model prediction.') -data_file2.contributor = guest_person -data_file2.projects = [project] -data_file2.policy = Policy.create(name: 'default policy', access_type: 1) -data_file2.content_blob = ContentBlob.new(original_filename: 'combinedPlot.jpg', - content_type: 'image/jpeg') -disable_authorization_checks do - data_file2.save - exp_assay.associate(data_file2) - model_assay.associate(data_file2, relationship: relationship) -end - -AssetsCreator.create(asset_id: data_file2.id, creator_id: guest_user.id, asset_type: data_file2.class.name) -# copy file -FileUtils.cp File.dirname(__FILE__) + '/' + data_file2.content_blob.original_filename, data_file2.content_blob.filepath -disable_authorization_checks { data_file2.content_blob.save } -puts 'Seeded data file 2.' - -# model -model = Model.new(title: 'Mathematical model for the combined four enzyme system', - description: 'The PGK, GAPDH, TPI and FBPAase were modelled together using the individual rate equations. Closed system.') -model.model_format = ModelFormat.find_by_title('SBML') -model.contributor = guest_person -model.projects = [project] -model.assays = [model_assay] -model.policy = Policy.create(name: 'default policy', access_type: 1) -model.model_type = ModelType.where(title: 'Ordinary differential equations (ODE)').first -model.model_format = ModelFormat.where(title: 'SBML').first -model.recommended_environment = RecommendedModelEnvironment.where(title: 'JWS Online').first -model.organism = Organism.where(title: 'Sulfolobus solfataricus').first -cb1 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisOpenAnn.dat', - content_type: 'text/x-uuencode') -cb2 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisOpenAnn.xml', - content_type: 'text/xml') -cb3 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisOpenAnn.xml', - content_type: 'text/xml') -cb4 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisAnn.xml', - content_type: 'text/xml') -cb5 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisClosed.xml', - content_type: 'text/xml') -cb6 = ContentBlob.new(original_filename: 'ssolfGluconeogenesis.xml', - content_type: 'text/xml') -model.content_blobs = [cb1, cb2, cb3, cb4, cb5, cb6] -disable_authorization_checks { model.save } -AssetsCreator.create(asset_id: model.id, creator_id: guest_person.id, asset_type: model.class.name) -# copy file -model.content_blobs.each do |blob| - FileUtils.cp File.dirname(__FILE__) + '/' + blob.original_filename, blob.filepath - blob.save -end -puts 'Seeded 1 model.' - -# sop -=begin -sop = Sop.new(title: "Default title", - description: "Default description" -) -sop.contributor = guest_person -sop.projects = [project] -sop.assays = [exp_assay] -sop.policy = Policy.create(name: 'default policy', access_type: 1) -sop.content_blob = ContentBlob.new(original_filename: 'test_sop.txt', - content_type: 'text' -) -disable_authorization_checks {sop.save} -AssetsCreator.create(asset_id: sop.id, creator_id: guest_person.id, asset_type: sop.class.name) -#copy file -FileUtils.cp File.dirname(__FILE__) + '/' + sop.content_blob.original_filename, sop.content_blob.filepath -puts "Seeded 1 sop." -=end - -# publication -publication = Publication.new( - publication_type_id: PublicationType.where(title:"Journal").first.id, - pubmed_id: '23865479', - title: 'Intermediate instability at high temperature leads to low pathway efficiency for an in vitro reconstituted system of gluconeogenesis in Sulfolobus solfataricus', - abstract: "Four enzymes of the gluconeogenic pathway in Sulfolobus solfataricus were purified and kinetically characterized. The enzymes were reconstituted in vitro to quantify the contribution of temperature instability of the pathway intermediates to carbon loss from the system. - The reconstituted system, consisting of phosphoglycerate kinase, glyceraldehyde 3-phosphate dehydrogenase, triose phosphate isomerase and the fructose 1,6-bisphosphate aldolase/phosphatase, maintained a constant consumption rate of 3-phosphoglycerate and production of - fructose 6-phosphate over a 1-h period. Cofactors ATP and NADPH were regenerated via pyruvate kinase and glucose dehydrogenase. A mathematical model was constructed on the basis of the kinetics of the purified enzymes and the measured half-life times of the pathway intermediates. - The model quantitatively predicted the system fluxes and metabolite concentrations. Relative enzyme concentrations were chosen such that half the carbon in the system was lost due to degradation of the thermolabile intermediates dihydroxyacetone phosphate, glyceraldehyde 3-phosphate - and 1,3-bisphosphoglycerate, indicating that intermediate instability at high temperature can significantly affect pathway efficiency.", - published_date: '2015', - journal: 'FEBS J' -) - -# Set contributor and projects -publication.contributor = guest_person -publication.projects << project - -# Build policy through the association -publication.build_policy(name: 'default policy', access_type: 1) - -# Build publication authors -authors = [ - { first_name: 'T.', last_name: 'Kouril', author_index: 1 }, - { first_name: 'D.', last_name: 'Esser', author_index: 2 }, - { first_name: 'J.', last_name: 'Kort', author_index: 3 }, - { first_name: 'H. V.', last_name: 'Westerhoff', author_index: 4 }, - { first_name: 'B.', last_name: 'Siebers', author_index: 5 }, - { first_name: 'J.', last_name: 'Snoep', author_index: 6 } -] - -authors.each do |author_attrs| - publication.publication_authors.build(author_attrs) -end - -# Save publication with all associations -disable_authorization_checks do - publication.save! # raises an error if something is invalid - publication.associate(exp_assay) - publication.associate(model_assay) -end - -# Create asset -AssetsCreator.create(asset_id: publication.id, creator_id: guest_person.id, asset_type: publication.class.name) - -puts 'Seeded 1 publication.' - -# Log activity -[project, investigation, study, exp_assay, model_assay, data_file1, data_file2, model, publication].each do |item| - ActivityLog.create( - action: 'create', - culprit: guest_user, - controller_name: item.class.name.underscore.pluralize, - activity_loggable: item, - data: item.title - ) -end - - -Seek::Config.home_description = '

Welcome to the SEEK Sandbox

-

You can log in with the username: guest and password: guest

-

For more information about SEEK and to see a video, please visit our Website.

' - -Seek::Config.solr_enabled = true -Seek::Config.programmes_enabled = true -Seek::Config.programme_user_creation_enabled = true -Seek::Config.noreply_sender = 'no-reply@fair-dom.org' -Seek::Config.instance_name = 'SEEK SANDBOX' -Seek::Config.application_name = 'FAIRDOM-SEEK' -Seek::Config.exception_notification_enabled = true -Seek::Config.exception_notification_recipients = ['errors@fair-dom.org'] -Seek::Config.datacite_url = 'https://mds.test.datacite.org/' -Seek::Config.doi_prefix = '10.5072' -Seek::Config.doi_suffix = 'seek.5' -puts 'Finish configuration' -puts 'Please visit admin site for further configuration, e.g. site_base_host, pubmed_api_email, crossref_api_email, bioportal_api_key, email, doi, admin email' -puts 'Admin account: username admin, password adminadmin. You might want to change admin password.' -puts 'Then make sure solr, workers are running' +# Load modular seed files in order +require_relative 'example_projects_and_basic_setup_seeds' +require_relative 'example_users_seeds' +require_relative 'example_isa_structure_seeds' +require_relative 'example_samples_seeds' +require_relative 'example_data_files_and_models_seeds' +require_relative 'example_publications_and_presentations_seeds' +require_relative 'example_config_seeds' \ No newline at end of file diff --git a/db/seeds/example_data/example_data_files_and_models_seeds.rb b/db/seeds/example_data/example_data_files_and_models_seeds.rb new file mode 100644 index 0000000000..28d123ebba --- /dev/null +++ b/db/seeds/example_data/example_data_files_and_models_seeds.rb @@ -0,0 +1,95 @@ +# Assets - Data files, Models, SOPs +# TODO check filesize +data_file1 = DataFile.new(title: 'Metabolite concentrations during reconstituted enzyme incubation', + description: 'The purified enzymes, PGK, GAPDH, TPI and FBPAase were incubated at 70 C en conversion of 3PG to F6P was followed.') +data_file1.contributor = $guest_person +data_file1.projects = [$project] +relationship = RelationshipType.where(title: 'Validation data').first +data_file1.policy = Policy.create(name: 'default policy', access_type: 1) +data_file1.content_blob = ContentBlob.new(original_filename: 'ValidationReference.xlsx', + content_type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') +disable_authorization_checks do + data_file1.save + $exp_assay.associate(data_file1) + $model_assay.associate(data_file1, relationship: relationship) +end +AssetsCreator.create(asset_id: data_file1.id, creator_id: $guest_user.id, asset_type: data_file1.class.name) +# copy file +FileUtils.cp File.dirname(__FILE__) + '/' + data_file1.content_blob.original_filename, data_file1.content_blob.filepath +disable_authorization_checks { data_file1.content_blob.save } +puts 'Seeded data file 1.' + +data_file2 = DataFile.new(title: 'Model simulation and Exp data for reconstituted system', + description: 'Experimental data for the reconstituted system are plotted together with the model prediction.') +data_file2.contributor = $guest_person +data_file2.projects = [$project] +data_file2.policy = Policy.create(name: 'default policy', access_type: 1) +data_file2.content_blob = ContentBlob.new(original_filename: 'combinedPlot.jpg', + content_type: 'image/jpeg') +disable_authorization_checks do + data_file2.save + $exp_assay.associate(data_file2) + $model_assay.associate(data_file2, relationship: relationship) +end + +AssetsCreator.create(asset_id: data_file2.id, creator_id: $guest_user.id, asset_type: data_file2.class.name) +# copy file +FileUtils.cp File.dirname(__FILE__) + '/' + data_file2.content_blob.original_filename, data_file2.content_blob.filepath +disable_authorization_checks { data_file2.content_blob.save } +puts 'Seeded data file 2.' + +# model +model = Model.new(title: 'Mathematical model for the combined four enzyme system', + description: 'The PGK, GAPDH, TPI and FBPAase were modelled together using the individual rate equations. Closed system.') +model.model_format = ModelFormat.find_by_title('SBML') +model.contributor = $guest_person +model.projects = [$project] +model.assays = [$model_assay] +model.policy = Policy.create(name: 'default policy', access_type: 1) +model.model_type = ModelType.where(title: 'Ordinary differential equations (ODE)').first +model.model_format = ModelFormat.where(title: 'SBML').first +model.recommended_environment = RecommendedModelEnvironment.where(title: 'JWS Online').first +model.organism = Organism.where(title: 'Sulfolobus solfataricus').first +cb1 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisOpenAnn.dat', + content_type: 'text/x-uuencode') +cb2 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisOpenAnn.xml', + content_type: 'text/xml') +cb3 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisOpenAnn.xml', + content_type: 'text/xml') +cb4 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisAnn.xml', + content_type: 'text/xml') +cb5 = ContentBlob.new(original_filename: 'ssolfGluconeogenesisClosed.xml', + content_type: 'text/xml') +cb6 = ContentBlob.new(original_filename: 'ssolfGluconeogenesis.xml', + content_type: 'text/xml') +model.content_blobs = [cb1, cb2, cb3, cb4, cb5, cb6] +disable_authorization_checks { model.save } +AssetsCreator.create(asset_id: model.id, creator_id: $guest_person.id, asset_type: model.class.name) +# copy file +model.content_blobs.each do |blob| + FileUtils.cp File.dirname(__FILE__) + '/' + blob.original_filename, blob.filepath + blob.save +end +puts 'Seeded 1 model.' + +# Sop creation +sop = Sop.new(title: 'Reconstituted Enzyme System Protocol', + description: 'Standard operating procedure for reconstituting the gluconeogenic enzyme system from Sulfolobus solfataricus to study metabolic pathway efficiency at high temperatures.') +sop.contributor = $guest_person +sop.projects = [$project] +sop.assays = [$exp_assay, $model_assay] +sop.policy = Policy.create(name: 'default policy', access_type: 1) +sop.content_blob = ContentBlob.new(original_filename: 'test_sop.txt', + content_type: 'text') +AssetsCreator.create(asset_id: sop.id, creator_id: $guest_person.id, asset_type: sop.class.name) +FileUtils.cp File.dirname(__FILE__) + '/' + sop.content_blob.original_filename, sop.content_blob.filepath + +disable_authorization_checks {sop.save!} +sop.annotate_with(['protocol', 'enzymology', 'thermophile'], 'tag', $guest_person) +puts 'Seeded 1 SOP.' + +# Store references for other seed files +$data_file1 = data_file1 +$data_file2 = data_file2 +$model = model +$sop = sop \ No newline at end of file diff --git a/db/seeds/example_data/example_isa_structure_seeds.rb b/db/seeds/example_data/example_isa_structure_seeds.rb new file mode 100644 index 0000000000..e54625809a --- /dev/null +++ b/db/seeds/example_data/example_isa_structure_seeds.rb @@ -0,0 +1,70 @@ +# ISA - Investigation, Study, Assays, Observation Units +investigation = Investigation.new(title: 'Central Carbon Metabolism of Sulfolobus solfataricus', + description: 'An investigation in the CCM of S. solfataricus with a focus on the unique temperature adaptations and regulation; using a combined modelling and experimental approach.') +investigation.projects = [$project] +investigation.contributor = $guest_person +investigation.policy = Policy.create(name: 'default policy', access_type: 1) +investigation.annotate_with(['metabolism', 'thermophile'], 'tag', $guest_person) +investigation.save +puts 'Seeded 1 investigation.' + +study = Study.new(title: 'Carbon loss at high T') +study.contributor = $guest_person +study.policy = Policy.create(name: 'default policy', access_type: 1) +study.investigation = investigation +study.annotate_with(['thermophile', 'high temperature'], 'tag', $guest_person) +study.save +puts 'Seeded 1 study.' + +## Observation unit +observation_unit = ObservationUnit.new(title: 'Large scale bioreactor') +observation_unit.description = 'A large scale bioreactor with a 1000 mL reservoir.' +observation_unit.other_creators = [$admin_person.name, 'Jane Doe'] +observation_unit.contributor = $guest_person +observation_unit.policy = Policy.create(name: 'default policy', access_type: 1) +observation_unit.annotate_with(['bioreactor'], 'tag', $guest_person) +observation_unit.study = study +disable_authorization_checks { observation_unit.save } +puts 'Seeded 1 observation unit' + +## Assays ## + +## Experimental assay? +exp_assay = Assay.new(title: 'Reconstituted system reference state', + description: 'The four purified enzymes were incubated in assay buffer and consumption of 3PG and production of F6P were measured in time, together with GAP and DHAP concentrations.') +exp_assay.contributor = $guest_person +exp_assay.policy = Policy.create(name: 'default policy', access_type: 1) +exp_assay.study = study +# exp_assay.observation_units = [observation_unit] # TODO ActiveRecord::HasManyThroughNestedAssociationsAreReadonly: Cannot modify association 'Assay#observation_units' because it goes through more than one other association. (ActiveRecord::HasManyThroughNestedAssociationsAreReadonly) +exp_assay.assay_class = AssayClass.experimental +exp_assay.organisms = [$organism] +exp_assay.save +puts "exp_assay: Seeded 1 #{exp_assay.assay_class.long_key.downcase}." + +# Modeling assay? +model_assay = Assay.new(title: 'Model reconstituted system', + description: 'Mathematical model for the reconstituted system with PGK, GAPDH, TPI and FBPAase.') +model_assay.contributor = $guest_person +model_assay.policy = Policy.create(name: 'default policy', access_type: 1) +model_assay.study = study +model_assay.assay_class = AssayClass.modelling +model_assay.save +puts "Seeded 1 #{model_assay.assay_class.long_key.downcase}." + +# Assay stream +assay_stream = Assay.new(title: 'Assay stream', + description: 'A stream of assays? This is a test assay stream for the example data.',) +assay_stream.contributor = $guest_person +assay_stream.policy = Policy.create(name: 'default policy', access_type: 1) +assay_stream.study = study +assay_stream.assay_class = AssayClass.assay_stream +assay_stream.save +puts "Seeded 1 assay stream #{model_assay.assay_class.long_key.downcase}." + +# Store references for other seed files +$investigation = investigation +$study = study +$observation_unit = observation_unit +$exp_assay = exp_assay +$model_assay = model_assay +$assay_stream = assay_stream \ No newline at end of file diff --git a/db/seeds/example_data/example_projects_and_basic_setup_seeds.rb b/db/seeds/example_data/example_projects_and_basic_setup_seeds.rb new file mode 100644 index 0000000000..d851f1174c --- /dev/null +++ b/db/seeds/example_data/example_projects_and_basic_setup_seeds.rb @@ -0,0 +1,32 @@ +# Project, Institution, Workgroup, Program, Strains, Organisms +program = Programme.where(title: 'Default Programme').first_or_create(web_page: 'http://www.seek4science.org', funding_details: 'Funding H2020X01Y001', description: 'This is a test programme for the SEEK sandbox.') +project = Project.where(title: 'Default Project').first_or_create(:programme_id => program.id, description: 'A description for the default project') # TODO this link is not working +institution = Institution.where(title: 'Default Institution').first_or_create(country: 'United Kingdom') +workgroup = WorkGroup.where(project_id: project.id, institution_id: institution.id).first_or_create + +# Create a strain +strain = Strain.where(title: 'Sulfolobus solfataricus strain 98/2').first_or_create +strain.projects = [project] +strain.policy = Policy.create(name: 'default policy', access_type: 1) +strain.organism = Organism.where(title: 'Sulfolobus solfataricus').first_or_create +strain.provider_name = 'BacDive' +strain.provider_id = '123456789' +strain.synonym = '98/2' +strain.comment = 'This is a test strain.' +strain.save! +puts 'Seeded 1 strain.' + +# Create an organism +organism = Organism.where(title: 'Sulfolobus solfataricus').first_or_create +organism.projects = [project] +organism.strains = [strain] +organism.save! +puts 'Seeded 1 organism.' + +# Store references for other seed files +$program = program +$project = project +$institution = institution +$workgroup = workgroup +$strain = strain +$organism = organism \ No newline at end of file diff --git a/db/seeds/example_data/example_publications_and_presentations_seeds.rb b/db/seeds/example_data/example_publications_and_presentations_seeds.rb new file mode 100644 index 0000000000..9f2feb119c --- /dev/null +++ b/db/seeds/example_data/example_publications_and_presentations_seeds.rb @@ -0,0 +1,85 @@ +# Publications, Presentations and Events + +# publication +publication = Publication.new( + publication_type_id: PublicationType.where(title:"Journal").first.id, + pubmed_id: '23865479', + title: 'Intermediate instability at high temperature leads to low pathway efficiency for an in vitro reconstituted system of gluconeogenesis in Sulfolobus solfataricus', + abstract: "Four enzymes of the gluconeogenic pathway in Sulfolobus solfataricus were purified and kinetically characterized. The enzymes were reconstituted in vitro to quantify the contribution of temperature instability of the pathway intermediates to carbon loss from the system. + The reconstituted system, consisting of phosphoglycerate kinase, glyceraldehyde 3-phosphate dehydrogenase, triose phosphate isomerase and the fructose 1,6-bisphosphate aldolase/phosphatase, maintained a constant consumption rate of 3-phosphoglycerate and production of + fructose 6-phosphate over a 1-h period. Cofactors ATP and NADPH were regenerated via pyruvate kinase and glucose dehydrogenase. A mathematical model was constructed on the basis of the kinetics of the purified enzymes and the measured half-life times of the pathway intermediates. + The model quantitatively predicted the system fluxes and metabolite concentrations. Relative enzyme concentrations were chosen such that half the carbon in the system was lost due to degradation of the thermolabile intermediates dihydroxyacetone phosphate, glyceraldehyde 3-phosphate + and 1,3-bisphosphoglycerate, indicating that intermediate instability at high temperature can significantly affect pathway efficiency.", + published_date: '2015', + journal: 'FEBS J' +) + +# Set contributor and projects +publication.contributor = $guest_person +publication.projects << $project + +# Build policy through the association +publication.build_policy(name: 'default policy', access_type: 1) +# Publication date +publication.published_date = Date.today.to_s +# Build publication authors +authors = [ + { first_name: 'T.', last_name: 'Kouril', author_index: 1 }, + { first_name: 'D.', last_name: 'Esser', author_index: 2 }, + { first_name: 'J.', last_name: 'Kort', author_index: 3 }, + { first_name: 'H. V.', last_name: 'Westerhoff', author_index: 4 }, + { first_name: 'B.', last_name: 'Siebers', author_index: 5 }, + { first_name: 'J.', last_name: 'Snoep', author_index: 6 } +] +# Citation +publication.citation = "Kouril, T. et al. Intermediate instability at high temperature leads to low pathway efficiency for an in vitro reconstituted system of gluconeogenesis in Sulfolobus solfataricus. FEBS J. 2015;687:100-108." + +authors.each do |author_attrs| + publication.publication_authors.build(author_attrs) +end + +# Save publication with all associations +disable_authorization_checks do + publication.save! # raises an error if something is invalid + publication.associate($exp_assay) + publication.associate($model_assay) +end + +# Create asset +AssetsCreator.create(asset_id: publication.id, creator_id: $guest_person.id, asset_type: publication.class.name) +puts 'Seeded 1 publication.' + +# Presentation +presentation = Presentation.new( + title: 'Intermediate instability at high temperature leads to low pathway efficiency for an in vitro reconstituted system of gluconeogenesis in Sulfolobus solfataricus', + description: "Four enzymes of the gluconeogenic pathway in Sulfolobus solfataricus were purified and kinetically characterized. The enzymes were reconstituted in vitro to quantify the contribution of temperature instability of the pathway intermediates to carbon loss from the system. + The reconstituted system, consisting of phosphoglycerate kinase, glyceraldehyde 3-phosphate dehydrogenase, triose phosphate isomerase and the fructose 1,6-bisphosphate aldolase/phosphatase, maintained a constant consumption rate of 3-phosphoglycerate and production of + ", +) +presentation.projects = [$project] +presentation.contributor = $guest_person +presentation.policy = Policy.create(name: 'default policy', access_type: 1) +presentation.content_blob = ContentBlob.new(original_filename: 'presentation.pptx', content_type: 'application/vnd.openxmlformats-officedocument.presentationml.presentation') +AssetsCreator.create(asset_id: presentation.id, creator_id: $guest_person.id, asset_type: presentation.class.name) +FileUtils.cp File.dirname(__FILE__) + '/' + presentation.content_blob.original_filename, presentation.content_blob.filepath # TODO results in "This version is not available" +presentation.version = 1 +presentation.save! +puts 'Seeded 1 presentation.' + +# Create an event +event = Event.new(title: 'Event for publication', description: 'Event for publication', start_date: Date.today, end_date: Date.today + 1.day) +event.projects = [$project] +event.contributor = $guest_person +event.policy = Policy.create(name: 'default policy', access_type: 1) +# event.website = 'http://www.seek4science.org' +event.city = 'London' +event.country = 'United Kingdom' +event.address = 'Dunmore Terrace 123' + +event.save! +puts 'Seeded 1 event.' + +# Store references for other seed files +$publication = publication +$presentation = presentation +$event = event \ No newline at end of file diff --git a/db/seeds/example_data/example_samples_seeds.rb b/db/seeds/example_data/example_samples_seeds.rb new file mode 100644 index 0000000000..49fe8f8f9d --- /dev/null +++ b/db/seeds/example_data/example_samples_seeds.rb @@ -0,0 +1,237 @@ +# Sample Types and Samples + +# First, we need to create sample attribute types +string_attr_type = SampleAttributeType.where(title: 'String').first_or_create(base_type: 'String') +float_attr_type = SampleAttributeType.where(title: 'Real number').first_or_create(base_type: 'Float') +integer_attr_type = SampleAttributeType.where(title: 'Integer').first_or_create(base_type: 'Integer') +boolean_attr_type = SampleAttributeType.where(title: 'Boolean').first_or_create(base_type: 'Boolean') + +# Create a sample type for bacterial culture samples +culture_sample_type = SampleType.new( + title: 'Bacterial Culture', + description: 'Sample type for bacterial culture experiments related to thermophile studies' +) +culture_sample_type.projects = [$project] +culture_sample_type.contributor = $guest_person +culture_sample_type.policy = Policy.create(name: 'default policy', access_type: 1) + +# Add attributes to the sample type +culture_sample_type.sample_attributes.build( + title: 'Culture Name', + sample_attribute_type: string_attr_type, + required: true, + is_title: true, + description: 'A unique name for the bacterial culture' +) + +culture_sample_type.sample_attributes.build( + title: 'Strain Used', + sample_attribute_type: string_attr_type, + required: true, + description: 'The bacterial strain used for this culture' +) + +culture_sample_type.sample_attributes.build( + title: 'Growth Temperature', + sample_attribute_type: float_attr_type, + unit: Unit.find_by_symbol('°C'), + required: true, + description: 'Temperature at which the culture was grown' +) + +culture_sample_type.sample_attributes.build( + title: 'Culture Volume', + sample_attribute_type: float_attr_type, + unit: Unit.find_by_symbol('mL'), + required: false, + description: 'Volume of the bacterial culture' +) + +culture_sample_type.sample_attributes.build( + title: 'pH', + sample_attribute_type: float_attr_type, + required: false, + description: 'pH of the culture medium' +) + +culture_sample_type.sample_attributes.build( + title: 'Growth Phase Complete', + sample_attribute_type: boolean_attr_type, + required: false, + description: 'Whether the culture has reached stationary phase' +) + +disable_authorization_checks { culture_sample_type.save! } +culture_sample_type.annotate_with(['bacterial culture', 'thermophile', 'microbiology'], 'tag', $guest_person) +puts 'Seeded bacterial culture sample type.' + +# Create a sample type for enzyme preparations +enzyme_sample_type = SampleType.new( + title: 'Enzyme Preparation', + description: 'Sample type for purified enzyme preparations used in reconstituted systems' +) +enzyme_sample_type.projects = [$project] +enzyme_sample_type.contributor = $guest_person +enzyme_sample_type.policy = Policy.create(name: 'default policy', access_type: 1) + +enzyme_sample_type.sample_attributes.build( + title: 'Enzyme Name', + sample_attribute_type: string_attr_type, + required: true, + is_title: true +) + +enzyme_sample_type.sample_attributes.build( + title: 'EC Number', + sample_attribute_type: string_attr_type, + required: false, + description: 'Enzyme Commission number', + pid: 'http://purl.uniprot.org/core/enzyme' +) + +enzyme_sample_type.sample_attributes.build( + title: 'Concentration', + sample_attribute_type: float_attr_type, + unit: Unit.find_by_symbol('mg/mL'), + required: true, + description: 'Protein concentration of the enzyme preparation' +) + +enzyme_sample_type.sample_attributes.build( + title: 'Specific Activity', + sample_attribute_type: float_attr_type, + unit: Unit.find_by_symbol('U/mg'), + required: false, + description: 'Specific enzymatic activity' +) + +enzyme_sample_type.sample_attributes.build( + title: 'Storage Temperature', + sample_attribute_type: integer_attr_type, + unit: Unit.find_by_symbol('°C'), + required: false, + description: 'Temperature for enzyme storage' +) + +enzyme_sample_type.sample_attributes.build( + title: 'Purification Steps', + sample_attribute_type: integer_attr_type, + required: false, + description: 'Number of purification steps performed' +) + +disable_authorization_checks { enzyme_sample_type.save! } +enzyme_sample_type.annotate_with(['enzyme', 'protein', 'purification'], 'tag', $guest_person) +puts 'Seeded enzyme preparation sample type.' + +# Now create actual samples + +# Bacterial culture samples +culture1 = Sample.new(title: 'S. solfataricus Culture #1') +culture1.sample_type = culture_sample_type +culture1.projects = [$project] +culture1.contributor = $guest_person +culture1.policy = Policy.create(name: 'default policy', access_type: 1) +culture1.set_attribute_value('Culture Name', 'S. solfataricus Culture #1') +culture1.set_attribute_value('Strain Used', 'Sulfolobus solfataricus strain 98/2') +culture1.set_attribute_value('Growth Temperature', 80.0) +culture1.set_attribute_value('Culture Volume', 500.0) +culture1.set_attribute_value('pH', 2.5) +culture1.set_attribute_value('Growth Phase Complete', true) +disable_authorization_checks { culture1.save! } +puts 'Seeded bacterial culture sample 1.' + +culture2 = Sample.new(title: 'S. solfataricus Culture #2') +culture2.sample_type = culture_sample_type +culture2.projects = [$project] +culture2.contributor = $guest_person +culture2.policy = Policy.create(name: 'default policy', access_type: 1) +culture2.set_attribute_value('Culture Name', 'S. solfataricus Culture #2') +culture2.set_attribute_value('Strain Used', 'Sulfolobus solfataricus strain 98/2') +culture2.set_attribute_value('Growth Temperature', 75.0) +culture2.set_attribute_value('Culture Volume', 1000.0) +culture2.set_attribute_value('pH', 2.8) +culture2.set_attribute_value('Growth Phase Complete', false) +disable_authorization_checks { culture2.save! } +puts 'Seeded bacterial culture sample 2.' + +# Enzyme samples +enzyme1 = Sample.new(title: 'Phosphoglycerate Kinase') +enzyme1.sample_type = enzyme_sample_type +enzyme1.projects = [$project] +enzyme1.contributor = $guest_person +enzyme1.policy = Policy.create(name: 'default policy', access_type: 1) +enzyme1.set_attribute_value('Enzyme Name', 'Phosphoglycerate Kinase') +enzyme1.set_attribute_value('EC Number', 'EC 2.7.2.3') +enzyme1.set_attribute_value('Concentration', 2.5) +enzyme1.set_attribute_value('Specific Activity', 125.0) +enzyme1.set_attribute_value('Storage Temperature', -20) +enzyme1.set_attribute_value('Purification Steps', 4) +disable_authorization_checks { enzyme1.save! } +puts 'Seeded enzyme sample 1.' + +enzyme2 = Sample.new(title: 'Glyceraldehyde-3-phosphate Dehydrogenase') +enzyme2.sample_type = enzyme_sample_type +enzyme2.projects = [$project] +enzyme2.contributor = $guest_person +enzyme2.policy = Policy.create(name: 'default policy', access_type: 1) +enzyme2.set_attribute_value('Enzyme Name', 'Glyceraldehyde-3-phosphate Dehydrogenase') +enzyme2.set_attribute_value('EC Number', 'EC 1.2.1.12') +enzyme2.set_attribute_value('Concentration', 1.8) +enzyme2.set_attribute_value('Specific Activity', 89.3) +enzyme2.set_attribute_value('Storage Temperature', -20) +enzyme2.set_attribute_value('Purification Steps', 3) +disable_authorization_checks { enzyme2.save! } +puts 'Seeded enzyme sample 2.' + +enzyme3 = Sample.new(title: 'Triose Phosphate Isomerase') +enzyme3.sample_type = enzyme_sample_type +enzyme3.projects = [$project] +enzyme3.contributor = $guest_person +enzyme3.policy = Policy.create(name: 'default policy', access_type: 1) +enzyme3.set_attribute_value('Enzyme Name', 'Triose Phosphate Isomerase') +enzyme3.set_attribute_value('EC Number', 'EC 5.3.1.1') +enzyme3.set_attribute_value('Concentration', 3.2) +enzyme3.set_attribute_value('Specific Activity', 210.5) +enzyme3.set_attribute_value('Storage Temperature', -20) +enzyme3.set_attribute_value('Purification Steps', 2) +disable_authorization_checks { enzyme3.save! } +puts 'Seeded enzyme sample 3.' + +enzyme4 = Sample.new(title: 'Fructose-1,6-bisphosphate Aldolase/Phosphatase') +enzyme4.sample_type = enzyme_sample_type +enzyme4.projects = [$project] +enzyme4.contributor = $guest_person +enzyme4.policy = Policy.create(name: 'default policy', access_type: 1) +enzyme4.set_attribute_value('Enzyme Name', 'Fructose-1,6-bisphosphate Aldolase/Phosphatase') +enzyme4.set_attribute_value('EC Number', 'EC 4.1.2.13') +enzyme4.set_attribute_value('Concentration', 1.5) +enzyme4.set_attribute_value('Specific Activity', 67.8) +enzyme4.set_attribute_value('Storage Temperature', -20) +enzyme4.set_attribute_value('Purification Steps', 5) +disable_authorization_checks { enzyme4.save! } +puts 'Seeded enzyme sample 4.' + +# Associate samples with the experimental assay +disable_authorization_checks do + $exp_assay.samples = [culture1, culture2, enzyme1, enzyme2, enzyme3, enzyme4] + $exp_assay.save! +end + +# Associate sample types with the study +disable_authorization_checks do + $study.sample_types = [culture_sample_type, enzyme_sample_type] + $study.save! +end + +# Store references for other seed files +$culture_sample_type = culture_sample_type +$enzyme_sample_type = enzyme_sample_type +$culture1 = culture1 +$culture2 = culture2 +$enzyme1 = enzyme1 +$enzyme2 = enzyme2 +$enzyme3 = enzyme3 +$enzyme4 = enzyme4 + +puts 'Seeded sample types and samples - 2 sample types with 6 total samples.' diff --git a/db/seeds/example_data/example_users_seeds.rb b/db/seeds/example_data/example_users_seeds.rb new file mode 100644 index 0000000000..806d107f34 --- /dev/null +++ b/db/seeds/example_data/example_users_seeds.rb @@ -0,0 +1,59 @@ +# Create an admin and a guest user + +# Admin +admin_user = User.where(login: 'admin').first_or_create( + login: 'admin', + email: 'admin@test1000.com', + password: 'adminadmin', password_confirmation: 'adminadmin' +) + +admin_user.activate +# TODO, check if admin really has access to the admin environment +admin_user.build_person(first_name: 'Admin', last_name: 'User', email: 'admin@test1000.com') unless admin_user.person +admin_user.save! +admin_user.person.work_groups << $workgroup +admin_person = admin_user.person +admin_person.save +puts 'Seeded 1 admin.' + +## Guest +guest_user = User.where(login: 'guest').first_or_create( + login: 'guest', + email: 'guest@test1000.com', + password: 'guestguest', password_confirmation: 'guestguest' +) +guest_user.activate +guest_user.build_person(first_name: 'Guest', last_name: 'User', email: 'guest@example.com') unless guest_user.person +guest_user.save! +guest_user.person.work_groups << $workgroup +guest_person = guest_user.person +guest_person.save +puts 'Seeded 1 guest.' + +# Update project +disable_authorization_checks do + $project.description = 'This is a test project for the SEEK sandbox.' + $project.web_page = 'http://www.seek4science.org' + $project.pals = [guest_person] + $project.save! + puts 'Seeded 1 project.' +end + +# Update institution +disable_authorization_checks do + $institution.country = 'United Kingdom' + $institution.city = 'Manchester' # Overridden by ROR + $institution.web_page = 'http://www.seek4science.org' # Overridden by ROR + # $institution.ror_id = '027m9bs27' # Only works with active internet connection + $institution.address = '10 Downing Street' # Stays the same + $institution.department = 'Department of SEEK for Science' + # Logo? + $institution.save! + puts 'Seeded 1 institution.' +end + +# Store references for other seed files +$admin_user = admin_user +$admin_person = admin_person +$guest_user = guest_user +$guest_person = guest_person \ No newline at end of file diff --git a/db/seeds/example_data/presentation.pptx b/db/seeds/example_data/presentation.pptx new file mode 100644 index 0000000000..108dd474af Binary files /dev/null and b/db/seeds/example_data/presentation.pptx differ diff --git a/db/seeds/example_data/test_sop.txt b/db/seeds/example_data/test_sop.txt new file mode 100644 index 0000000000..09caeb5d75 --- /dev/null +++ b/db/seeds/example_data/test_sop.txt @@ -0,0 +1,79 @@ +Standard Operating Procedure: Reconstituted Enzyme System for Gluconeogenesis Studies +Version 1.0 +Date: 2024 + +1. OBJECTIVE +This SOP describes the standardized protocol for reconstituting the gluconeogenic enzyme system from Sulfolobus solfataricus to study carbon metabolism efficiency at high temperatures. + +2. SAFETY CONSIDERATIONS +- Handle all enzymes and chemicals in appropriate laboratory conditions +- Use heat-resistant equipment for high-temperature incubations +- Follow institutional safety guidelines for biochemical assays +- Ensure proper ventilation when working with volatile compounds + +3. MATERIALS AND EQUIPMENT +3.1 Purified Enzymes: +- Phosphoglycerate kinase (PGK) +- Glyceraldehyde 3-phosphate dehydrogenase (GAPDH) +- Triose phosphate isomerase (TPI) +- Fructose 1,6-bisphosphate aldolase/phosphatase (FBPAase) + +3.2 Substrates and Cofactors: +- 3-Phosphoglycerate (3PG) - starting substrate +- ATP and NADPH for cofactor regeneration +- Pyruvate kinase and glucose dehydrogenase for regeneration system +- Assay buffer (pH optimized for thermostable enzymes) + +3.3 Equipment: +- High-temperature water bath or incubator (70C) +- Spectrophotometer for kinetic measurements +- Temperature-controlled cuvettes +- Precision pipettes and tips + +4. PROCEDURE +4.1 Enzyme Preparation: +1. Thaw purified enzymes on ice +2. Determine protein concentrations using Bradford assay +3. Prepare enzyme stock solutions in assay buffer +4. Adjust enzyme ratios for optimal pathway flux + +4.2 Assay Setup: +1. Pre-warm assay buffer to 70C +2. Add cofactors (ATP, NADPH) to reaction mixture +3. Include cofactor regeneration system (pyruvate kinase, glucose dehydrogenase) +4. Add substrate (3PG) to initiate reaction + +4.3 Kinetic Measurements: +1. Monitor 3PG consumption over time +2. Measure F6P (fructose 6-phosphate) production +3. Track intermediate concentrations (GAP, DHAP) +4. Record temperature stability throughout 1-hour incubation period +5. Document any intermediate degradation due to thermolability + +5. DATA COLLECTION +- Record initial substrate and product concentrations +- Monitor reaction progress at 5-minute intervals +- Calculate conversion efficiency and carbon loss +- Document pathway flux rates under different enzyme ratios + +6. QUALITY CONTROL +- Verify enzyme activity before each experiment +- Include negative controls (no enzyme, no substrate) +- Monitor reaction pH throughout incubation +- Check for non-specific product formation + +7. EXPECTED RESULTS +- Constant consumption rate of 3PG over 1-hour period +- Steady production of F6P as final product +- Measurable concentrations of GAP and DHAP intermediates +- Approximately 50% carbon loss due to intermediate instability at high temperature + +8. DATA ANALYSIS +- Plot substrate consumption and product formation over time +- Calculate pathway efficiency and intermediate stability +- Compare experimental results with mathematical model predictions +- Analyze the impact of temperature on pathway performance + +9. REFERENCES +- Kouril, T. et al. Intermediate instability at high temperature leads to low pathway efficiency for an in vitro reconstituted system of gluconeogenesis in Sulfolobus solfataricus. FEBS J. 2015;687:100-108. +- Standard protocols for thermostable enzyme kinetics \ No newline at end of file