|
1 | 1 | # Project, Institution, Workgroup |
2 | 2 | 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.') |
3 | | -project = Project.where(title: 'Default Project').first_or_create(:programme_id => program.id) # TODO this link is not working |
| 3 | +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 |
4 | 4 | institution = Institution.where(title: 'Default Institution').first_or_create(country: 'United Kingdom') |
5 | 5 | workgroup = WorkGroup.where(project_id: project.id, institution_id: institution.id).first_or_create |
6 | 6 |
|
| 7 | + |
| 8 | +# Create a strain |
| 9 | +strain = Strain.where(title: 'Sulfolobus solfataricus strain 98/2').first_or_create() |
| 10 | +strain.projects = [project] |
| 11 | +strain.policy = Policy.create(name: 'default policy', access_type: 1) |
| 12 | +strain.organism = Organism.where(title: 'Sulfolobus solfataricus').first_or_create() |
| 13 | +strain.provider_name = 'BacDive' |
| 14 | +strain.provider_id = '123456789' |
| 15 | +strain.synonym = '98/2' |
| 16 | +strain.comment = 'This is a test strain.' |
| 17 | +strain.save! |
| 18 | +puts 'Seeded 1 strain.' |
| 19 | + |
| 20 | +# Create an organism |
| 21 | +organism = Organism.where(title: 'Sulfolobus solfataricus').first_or_create() |
| 22 | +organism.projects = [project] |
| 23 | +organism.strains = [strain] |
| 24 | +organism.save! |
| 25 | +puts 'Seeded 1 organism.' |
| 26 | + |
7 | 27 | ## Create an admin and a guest user |
8 | 28 |
|
9 | 29 | # Admin |
|
35 | 55 | guest_person.save |
36 | 56 | puts 'Seeded 1 guest.' |
37 | 57 |
|
| 58 | +# Update project |
| 59 | +disable_authorization_checks do |
| 60 | + project.description = 'This is a test project for the SEEK sandbox.' |
| 61 | + project.web_page = 'http://www.seek4science.org' |
| 62 | + project.pals = [guest_person] |
| 63 | + project.save! |
| 64 | + puts 'Seeded 1 project.' |
| 65 | +end |
| 66 | + |
| 67 | +# Update institution |
| 68 | +disable_authorization_checks do |
| 69 | + institution.country = 'United Kingdom' |
| 70 | + institution.city = 'Manchester' # Overridden by ROR |
| 71 | + institution.web_page = 'http://www.seek4science.org' # Overridden by ROR |
| 72 | + institution.ror_id = '027m9bs27' |
| 73 | + institution.address = '10 Downing Street' # Stays the same |
| 74 | + institution.department = 'Department of SEEK for Science' |
| 75 | + # Logo? |
| 76 | + institution.save! |
| 77 | + puts 'Seeded 1 institution.' |
| 78 | +end |
| 79 | + |
38 | 80 | # ISA |
39 | 81 | investigation = Investigation.new(title: 'Central Carbon Metabolism of Sulfolobus solfataricus', |
40 | 82 | 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.') |
41 | 83 | investigation.projects = [project] |
42 | 84 | investigation.contributor = guest_person |
43 | 85 | investigation.policy = Policy.create(name: 'default policy', access_type: 1) |
| 86 | +investigation.annotate_with(['metabolism', 'thermophile'], 'tag', guest_person) |
44 | 87 | investigation.save |
45 | 88 | puts 'Seeded 1 investigation.' |
46 | 89 |
|
47 | 90 | study = Study.new(title: 'Carbon loss at high T') |
48 | 91 | study.contributor = guest_person |
49 | 92 | study.policy = Policy.create(name: 'default policy', access_type: 1) |
50 | 93 | study.investigation = investigation |
| 94 | +study.annotate_with(['thermophile', 'high temperature'], 'tag', guest_person) |
51 | 95 | study.save |
52 | 96 | puts 'Seeded 1 study.' |
53 | 97 |
|
54 | 98 | ## Observation unit |
55 | 99 | observation_unit = ObservationUnit.new(title: 'Large scale bioreactor') |
| 100 | +observation_unit.description = 'A large scale bioreactor with a 1000 mL reservoir.' |
| 101 | +observation_unit.other_creators = [admin_person.name, 'Jane Doe'] |
56 | 102 | observation_unit.contributor = guest_person |
57 | 103 | observation_unit.policy = Policy.create(name: 'default policy', access_type: 1) |
| 104 | +observation_unit.annotate_with(['bioreactor'], 'tag', guest_person) |
58 | 105 | observation_unit.study = study |
59 | 106 | disable_authorization_checks { observation_unit.save } |
60 | 107 | puts 'Seeded 1 observation unit' |
|
67 | 114 | exp_assay.contributor = guest_person |
68 | 115 | exp_assay.policy = Policy.create(name: 'default policy', access_type: 1) |
69 | 116 | exp_assay.study = study |
| 117 | +# 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) |
70 | 118 | exp_assay.assay_class = AssayClass.experimental |
| 119 | +exp_assay.organisms = [organism] |
71 | 120 | exp_assay.save |
72 | 121 | puts "exp_assay: Seeded 1 #{exp_assay.assay_class.long_key.downcase}." |
73 | 122 |
|
|
90 | 139 | assay_stream.assay_class = AssayClass.assay_stream |
91 | 140 | assay_stream.save |
92 | 141 | puts "Seeded 1 assay stream #{model_assay.assay_class.long_key.downcase}." |
93 | | -# |
| 142 | + |
94 | 143 | ####### |
95 | 144 | # Assets |
96 | 145 | # TODO check filesize |
|
166 | 215 | end |
167 | 216 | puts 'Seeded 1 model.' |
168 | 217 |
|
169 | | -# sop |
170 | | -=begin |
171 | | -sop = Sop.new(title: "Default title", |
172 | | - description: "Default description" |
173 | | -) |
| 218 | +# Sop creation |
| 219 | +sop = Sop.new(title: 'Reconstituted Enzyme System Protocol', |
| 220 | + description: 'Standard operating procedure for reconstituting the gluconeogenic enzyme system from Sulfolobus solfataricus to study metabolic pathway efficiency at high temperatures.') |
174 | 221 | sop.contributor = guest_person |
175 | 222 | sop.projects = [project] |
176 | | -sop.assays = [exp_assay] |
| 223 | +sop.assays = [exp_assay, model_assay] |
177 | 224 | sop.policy = Policy.create(name: 'default policy', access_type: 1) |
178 | 225 | sop.content_blob = ContentBlob.new(original_filename: 'test_sop.txt', |
179 | | - content_type: 'text' |
180 | | -) |
181 | | -disable_authorization_checks {sop.save} |
| 226 | + content_type: 'text') |
182 | 227 | AssetsCreator.create(asset_id: sop.id, creator_id: guest_person.id, asset_type: sop.class.name) |
183 | | -#copy file |
184 | 228 | FileUtils.cp File.dirname(__FILE__) + '/' + sop.content_blob.original_filename, sop.content_blob.filepath |
185 | | -puts "Seeded 1 sop." |
186 | | -=end |
| 229 | + |
| 230 | +disable_authorization_checks {sop.save!} |
| 231 | +sop.annotate_with(['protocol', 'enzymology', 'thermophile'], 'tag', guest_person) |
| 232 | +puts 'Seeded 1 SOP.' |
| 233 | + |
187 | 234 |
|
188 | 235 | # publication |
189 | 236 | publication = Publication.new( |
|
205 | 252 |
|
206 | 253 | # Build policy through the association |
207 | 254 | publication.build_policy(name: 'default policy', access_type: 1) |
208 | | - |
| 255 | +# Publication date |
| 256 | +publication.published_date = Date.today.to_s |
209 | 257 | # Build publication authors |
210 | 258 | authors = [ |
211 | 259 | { first_name: 'T.', last_name: 'Kouril', author_index: 1 }, |
|
215 | 263 | { first_name: 'B.', last_name: 'Siebers', author_index: 5 }, |
216 | 264 | { first_name: 'J.', last_name: 'Snoep', author_index: 6 } |
217 | 265 | ] |
| 266 | +# Citation |
| 267 | +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." |
218 | 268 |
|
219 | 269 | authors.each do |author_attrs| |
220 | 270 | publication.publication_authors.build(author_attrs) |
|
0 commit comments