-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia-workflow.aq
1 lines (1 loc) · 26.7 KB
/
media-workflow.aq
1
{"config":{"title":"Liquid/Agar Media Workflow","description":"Protocol and libraries for making media","copyright":"University of Washington, 2019","version":"0.0.1","authors":[{"name":"Benjamin Keller","affiliation":"University of Washington"},{"name":"Abraham Miller","affilation":"","affiliation":"University of Washington"},{"name":"Eriberto Lopez","affilation":"","affiliation":"University of Washington"},{"name":"Ayesha Saleem","affilation":"","affiliation":"University of Washington"},{"name":"Luana Paleologu","affilation":"","affiliation":"University of Washington"},{"name":"Robert Moseley","affilation":"","affiliation":"Duke University"}],"maintainer":{"name":"Benjamin Keller","email":"[email protected]"},"acknowledgements":null,"github":{"user":"bjkeller","repo":"media-workflow","organization":"klavinslab"},"keywords":["media"],"aquadoc_version":"1.0.0","aquarium_version":"\u003c%= Bioturk::Application.config.aquarium_version %\u003e"},"components":[{"sample_types":[{"id":10,"name":"Media","description":"Media for yeast and E. coli","created_at":"2019-07-15T14:51:42.000-07:00","updated_at":"2019-07-15T14:51:42.000-07:00","field_types":[]}],"object_types":[{"id":33,"name":"800 mL Agar","description":"800 mL Agar","min":0,"max":1000,"handler":"sample_container","safety":"No safety information","cleanup":"No cleanup information","data":" { \"samples\": [ \r\n\r\n{ \"name\": \"SDO\", \"materials\": 0.02, \"labor\": 0.112, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 },\r\n{ \"name\": \"LB\", \"materials\": 0.01, \"labor\": 0.065, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 },\r\n{ \"name\": \"YPAD\", \"materials\": 0.02, \"labor\": 0.1, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 }\r\n ] }","vendor":"No vendor information","created_at":"2019-07-15T14:51:42.000-07:00","updated_at":"2019-07-15T14:51:43.000-07:00","unit":"Media","cost":0.01,"release_method":"return","release_description":"","sample_type_id":10,"image":null,"prefix":"","rows":null,"columns":null,"sample_type_name":"Media"},{"id":34,"name":"800 mL Liquid","description":"800 mL Bottle","min":0,"max":10000,"handler":"sample_container","safety":"No safety information","cleanup":"No cleanup information","data":" {\r\n \"samples\": [\r\n { \"name\": \"SC\", \"materials\": 0.0135, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 },\r\n { \"name\": \"SDO\", \"materials\": 0.014, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 },\r\n { \"name\": \"50% Glycerol\", \"materials\": 0.02, \"labor\": 0.02, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 },\r\n { \"name\": \"TB\", \"materials\": 0.01, \"labor\": 0.016, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 },\r\n { \"name\": \"TB + Amp\", \"materials\": 0.03, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 },\r\n { \"name\": \"LB\", \"materials\": 0.01, \"labor\": 0.016, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 }, \r\n { \"name\": \"YPAD\", \"materials\": 0.01, \"labor\": 0.025, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 800 }\r\n ]\r\n }","vendor":"No vendor information","created_at":"2019-07-15T14:51:42.000-07:00","updated_at":"2019-07-15T14:51:43.000-07:00","unit":"Media","cost":0.01,"release_method":"return","release_description":"","sample_type_id":10,"image":null,"prefix":"","rows":null,"columns":null,"sample_type_name":"Media"},{"id":35,"name":"400 mL Agar","description":"400 mL Agar","min":0,"max":1000,"handler":"sample_container","safety":"No safety information","cleanup":"No cleanup information","data":"{ \"samples\": [ \r\n\r\n{ \"name\": \"SDO\", \"materials\": 0.02, \"labor\": 0.112, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 },\r\n{ \"name\": \"LB\", \"materials\": 0.01, \"labor\": 0.065, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 },\r\n{ \"name\": \"YPAD\", \"materials\": 0.02, \"labor\": 0.1, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 }\r\n ] }","vendor":"No vendor information","created_at":"2019-07-15T14:51:42.000-07:00","updated_at":"2019-07-15T14:51:43.000-07:00","unit":"Media","cost":0.01,"release_method":"return","release_description":"","sample_type_id":10,"image":null,"prefix":"","rows":null,"columns":null,"sample_type_name":"Media"},{"id":36,"name":"400 mL Liquid","description":"400 mL Bottle","min":0,"max":1000,"handler":"sample_container","safety":"No safety information","cleanup":"No cleanup information","data":"{\r\n \"samples\": [\r\n { \"name\": \"TB + Kan\", \"materials\": 0.03, \"labor\": 0.03, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 },\r\n { \"name\": \"SC\", \"materials\": 0.01, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 },\r\n { \"name\": \"SDO\", \"materials\": 0.01, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 },\r\n { \"name\": \"50% Glycerol\", \"materials\": 0.01, \"labor\": 0.02, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 },\r\n { \"name\": \"TB\", \"materials\": 0.01, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 },\r\n { \"name\": \"TB + Amp\", \"materials\": 0.023, \"labor\": 0.06, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 },\r\n { \"name\": \"LB\", \"materials\": 0.01, \"labor\": 0.016, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 }, \r\n { \"name\": \"YPAD\", \"materials\": 0.01, \"labor\": 0.025, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 400 }\r\n ]\r\n }","vendor":"No vendor information","created_at":"2019-07-15T14:51:42.000-07:00","updated_at":"2019-07-15T14:51:43.000-07:00","unit":"Media","cost":0.01,"release_method":"return","release_description":"","sample_type_id":10,"image":null,"prefix":"","rows":null,"columns":null,"sample_type_name":"Media"},{"id":37,"name":"200 mL Agar","description":"200 mL Agar","min":0,"max":1000,"handler":"sample_container","safety":"No safety information","cleanup":"No cleanup information","data":" { \"samples\": [ \r\n\r\n{ \"name\": \"SDO\", \"materials\": 0.02, \"labor\": 0.112, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n{ \"name\": \"LB\", \"materials\": 0.01, \"labor\": 0.065, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n{ \"name\": \"YPAD\", \"materials\": 0.02, \"labor\": 0.1, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 }\r\n ] }","vendor":"No vendor information","created_at":"2019-07-15T14:51:42.000-07:00","updated_at":"2019-07-15T14:51:43.000-07:00","unit":"Media","cost":0.01,"release_method":"return","release_description":"","sample_type_id":10,"image":null,"prefix":"","rows":null,"columns":null,"sample_type_name":"Media"},{"id":38,"name":"200 mL Liquid","description":"200 mL Bottle","min":0,"max":1000,"handler":"sample_container","safety":"No safety information","cleanup":"No cleanup information","data":" {\r\n \"samples\": [\r\n { \"name\": \"SC\", \"materials\": 0.01, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"SDO\", \"materials\": 0.01, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"FCC\", \"materials\": 0.08, \"labor\": 0.0705, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"LB\", \"materials\": 0.01, \"labor\": 0.0155, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"YPAD\", \"materials\": 0.01, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"TB\", \"materials\": 0.01, \"labor\": 0.028, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"TB + Amp\", \"materials\": 0.02, \"labor\": 0.04, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"TB + Kan\", \"materials\": 0.02, \"labor\": 0.04,\"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"1 M Lithium Acetate\", \"materials\": 0.112, \"labor\": 0.075, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"0.2% SDS\", \"materials\": 0.01, \"labor\": 0.01, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"50% Glycerol\", \"materials\": 0.01, \"labor\": 0.02, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 },\r\n { \"name\": \"50% PEG\", \"materials\": 0.16, \"labor\": 0.0265, \"delete\": false, \"unit\": \"mL\", \"total_volume\": 200 }\r\n ]\r\n }","vendor":"No vendor information","created_at":"2019-07-15T14:51:43.000-07:00","updated_at":"2019-07-15T14:51:43.000-07:00","unit":"200 mL Bottle","cost":0.01,"release_method":"return","release_description":"purchasable\r\n","sample_type_id":10,"image":null,"prefix":"","rows":null,"columns":null,"sample_type_name":"Media"}],"operation_type":{"name":"Make Liquid/Agar Media","category":"Reagents","deployed":false,"on_the_fly":false,"field_types":[{"ftype":"sample","role":"output","name":"Media","sample_types":["Media","Media","Media","Media","Media","Media"],"object_types":["800 mL Agar","800 mL Liquid","400 mL Agar","400 mL Liquid","200 mL Agar","200 mL Liquid"],"part":false,"array":false,"routing":"A","preferred_operation_type_id":null,"preferred_field_type_id":null,"choices":null}],"protocol":"# frozen_string_literal: true\r\n\r\nneeds 'Reagents/MediaRecipe'\r\n\r\nclass Protocol\r\n\r\n def make_media_steps(bottle:, num_bottles:, multiplier:, ingredients:)\r\n show do\r\n title 'Gather the Following Items'\r\n check \"#{num_bottles} #{bottle}(s)\"\r\n ingredients.each do |reagent|\r\n check reagent.name\r\n end\r\n end\r\n\r\n if bottle.include?('1 L Bottle')\r\n show do\r\n title 'Add Stir Bar'\r\n check 'Retrieve 1 Medium Magnetic Stir Bar(s) from B1.525 or dishwashing station.'\r\n check 'Add the stir bar(s) to the bottle(s).'\r\n end\r\n end\r\n\r\n ingredients.each do |reagent|\r\n show do\r\n title \"Add #{reagent}\"\r\n note \"Using the #{reagent.directions}, add \u003cb\u003e#{reagent.amount * multiplier}\u003c/b\u003e #{reagent.unit} of \u003cb\u003e'#{reagent.name}'\u003c/b\u003e into each bottle.\"\r\n end\r\n end\r\n end\r\n\r\n def label_media_steps(multiplier, label, number, mix_note = 'Shake until most of the powder is dissolved. It is ok if a small amount of powder is not dissolved because the autoclave will dissolve it', water_note = 'DI water carboy', label_note = '')\r\n show do\r\n title 'Measure Water'\r\n note \"use the #{water_note} to add water up to the #{multiplier * 800} mL mark\"\r\n end\r\n\r\n show do\r\n title 'Mix Solution'\r\n note mix_note.to_s\r\n end\r\n\r\n show do\r\n title 'Label Media'\r\n note \"Label the bottle(s) with '#{label}', 'Your initials', 'date', and '#{number}'\"\r\n note label_note.to_s\r\n end\r\n end\r\n\r\n def group_media(operations:)\r\n media_to_make = Hash.new\r\n operations.each do |op|\r\n item = op.output('Media').item\r\n sample_name = item.sample.name\r\n container = item.object_type.name\r\n\r\n key = \"#{container} #{sample_name}\"\r\n if media_to_make[key].nil?\r\n m = container.match(/(\\d+)\\s(\\w+)\\s(\\w+)/)\r\n raise ProtocolError.new(message: 'Expect object type to indicate volume and Agar/Liquid') if m.nil?\r\n\r\n vol_str, unit, state = m.captures\r\n vol = vol_str.to_i\r\n bottle_volume = vol + vol / 4\r\n bottle = \"#{bottle_volume == 1000.0 ? '1 L' : \"#{bottle_volume} mL\"} Bottle\"\r\n media_to_make[key] = Media.new(sample_name: sample_name, volume: vol, unit: unit, type: state.downcase.to_sym, bottle: bottle, count: 0, output: [])\r\n end\r\n media_to_make[key].count += 1\r\n media_to_make[key].output.push(item.id)\r\n end\r\n media_to_make\r\n end\r\n\r\n def main\r\n operations.retrieve(interactive: false)\r\n operations.make\r\n\r\n dry_units = 'gram'\r\n dry_directions = 'gram scale, large weigh boat, and chemical spatula'\r\n wet_units = 'ml'\r\n wet_directions = 'serological pipette'\r\n\r\n media_to_make = group_media(operations: operations)\r\n media_to_make.each_value do |media|\r\n multiplier = media.volume / 800.0\r\n \r\n ingredients = []\r\n label = create_label(media: media)\r\n mix_note = 'Shake until most of the powder is dissolved. It is ok if a small amount of powder is not dissolved because the autoclave will dissolve it'\r\n water_note = 'DI water carboy'\r\n label_note = ''\r\n\r\n if media.sample_name.include?('SOB')\r\n ingredients.push(Ingredient.new(name: \"Hanahan's Broth\", amount: 22.4, unit: dry_units, directions: dry_directions))\r\n # change to bacteria media steps when Hanahan's broth is fixed\r\n elsif media.sample_name.include?('SOC')\r\n label += ' - Dextrose not added yet'\r\n ingredients.push(Ingredient.new(name: \"Hanahan's Broth\", amount: 22.4, unit: dry_units, directions: dry_directions))\r\n # change to bacteria media steps when Hanahan's broth is fixed\r\n\r\n show do\r\n title 'Add Dextrose'\r\n note \"Once the autoclave is done, remove the SOC liquid without Dextrose and add #{7.2 * multiplier} mL of 40% Dextrose to the bottle\"\r\n end\r\n\r\n show do\r\n title 'Relabel'\r\n note \"Cross out the 'Dextrose not added'\"\r\n end\r\n elsif media.sample_name.include?('TB')\r\n ingredients.push(Ingredient.new(name: 'Terrific Broth, modified', amount: 38.08, unit: dry_units, directions: dry_directions))\r\n ingredients.push(Ingredient.new(name: '50% Glycerol', amount: 12.8, unit: wet_units, directions: wet_directions))\r\n elsif media.sample_name.include?('LB')\r\n if media.type == :agar\r\n ingredients.push(Ingredient.new(name: 'LB Agar Miller', amount: 29.6, unit: dry_units, directions: dry_directions))\r\n else\r\n ingredients.push(Ingredient.new(name: 'Difco LB Broth, Miller', amount: 20, unit: dry_units, directions: dry_directions))\r\n end\r\n elsif media.sample_name.include?('10% Glycerol')\r\n ingredients.push(Ingredient.new(name: '50% Glycerol', amount: 160, unit: wet_units, directions: wet_directions))\r\n elsif media.sample_name.include?('YPAD')\r\n ingredients.push(Ingredient.new(name: 'Bacto Tryptone', amount: 16, unit: dry_units, directions: dry_directions))\r\n ingredients.push(Ingredient.new(name: 'Bacto Yeast Extract', amount: 8, unit: dry_units, directions: dry_directions))\r\n ingredients.push(Ingredient.new(name: 'Dextrose', amount: 16, unit: dry_units, directions: dry_directions))\r\n ingredients.push(Ingredient.new(name: 'Adenine (Adenine hemisulfate)', amount: 0.064, unit: dry_units, directions: dry_directions))\r\n ingredients.push(Ingredient.new(name: 'Bacto Agar', amount: 16, unit: dry_units, directions: dry_directions)) if media.type == :agar\r\n\r\n if media.sample_name.include?('Sorbitol')\r\n sorb_sample = Sample.find_by_name('Sorbitol Powder')\r\n sorb_item = sorb_sample.items.select { |i| i.deleted? \u0026\u0026 i.object_type.name == 'Bottle' }.first\r\n ingredients.push(Ingredient.new(name: \"#{sorb_item} #{sorb_sample.name}\", amount: 145.74, unit: dry_units, directions: dry_directions)) # grams of sorb (182.17g/mol) for 1M sorb in 800mL of media\r\n end\r\n elsif media.sample_name.include?('SC') || media.sample_name.include?('SDO')\r\n galactose = media.sample_name.include?('Gal')\r\n his = !media.sample_name.include?('-His')\r\n leu = !media.sample_name.include?('-Leu')\r\n ura = !media.sample_name.include?('-Ura')\r\n trp = !media.sample_name.include?('-Trp')\r\n\r\n ingredients.push(Ingredient.new(name: 'Yeast Nitrogen Base without Amino Acids', amount: 5.36, unit: dry_units, directions: dry_directions))\r\n ingredients.push(Ingredient.new(name: 'Yeast Synthetic Drop-out Medium Supplements', amount: 1.12, unit: dry_units, directions: dry_directions))\r\n ingredients.push(Ingredient.new(name: 'Dextrose', amount: galactose ? 1.6 : 16, directions: dry_directions))\r\n ingredients.push(Ingredient.new(name: 'Galactose, 99%', amount: 16, unit: dry_units, directions: dry_directions)) if galactose\r\n ingredients.push(Ingredient.new(name: 'Adenine (Adenine hemisulfate)', amount: 0.064, unit: dry_units, directions: dry_directions))\r\n\r\n ingredients.push(Ingredient.new(name: 'Histidine Solution', amount: 8, unit: wet_units, directions: wet_directions)) if his\r\n ingredients.push(Ingredient.new(name: 'Leucine Solution', amount: 8, unit: wet_units, directions: wet_directions)) if leu\r\n ingredients.push(Ingredient.new(name: 'Uracil Solution', amount: 8, unit: wet_units, directions: wet_directions)) if ura\r\n ingredients.push(Ingredient.new(name: 'Tryptophan Solution', amount: 8, unit: wet_units, directions: wet_directions)) if trp\r\n ingredients.push(Ingredient.new(name: 'Bacto Agar', amount: 16, unit: dry_units, directions: dry_directions)) if media.type == :agar\r\n\r\n # Yeast Gates Alternative media\r\n elsif media.sample_name.include?('Synthetic Complete + 1M Sorbitol Media') || media.sample_name.include?('Synthetic Complete + 2% glycerol 2% ethanol Media')\r\n if media.sample_name.include?('2% ethanol')\r\n # do not add ethanol before autoclave\r\n label += ' -- no ethanol added'\r\n end\r\n\r\n # common ingredients\r\n dry_list = [['Yeast Nitrogen Base without Amino Acids', 5.36], ['Yeast Synthetic Drop-out Medium Supplements', 1.12], ['Adenine (Adenine hemisulfate)', 0.064]]\r\n liquids_list = [['Histidine Solution', 8], ['Leucine Solution', 8], ['Uracil Solution', 8], ['Tryptophan Solution', 8]]\r\n\r\n # Alternative ingredient compositions\r\n if media.sample_name.include?('Sorbitol')\r\n dry_list.append(['Dextrose', 16])\r\n dry_list.append(['Sorbitol', 145.7])\r\n end\r\n\r\n if media.sample_name.include?('2% glycerol') \r\n liquids_list.append(['50% Glycerol', 32])\r\n end\r\n\r\n dry_list.each { |ing, amt| ingredients.push(Ingredient.new(name: ing, amount: amt, unit: dry_units, directions: dry_directions)) }\r\n liquids_list.each { |ing, amt| ingredients.push(Ingredient.new(name: ing, amount: amt, unit: wet_units, directions: wet_directions)) }\r\n elsif media.sample_name.include?('YPAD + 1M Sorbitol')\r\n\r\n elsif media.sample_name.include?('M9 + Glucose')\r\n ingredients.push(Ingredient.new(name: 'DI Water, Sterile', amount: 500, unit: wet_units, directions: 'autoclaved, large graduated cylinder'))\r\n ingredients.push(Ingredient.new(name: 'CaCl2, 1M', amount: 80, unit: 'uL', directions: 'P100 pipette')) \r\n ingredients.push(Ingredient.new(name: 'MgSO4, 1M', amount: 1.6, unit: wet_units, directions: 'serological or P1000 pipette'))\r\n ingredients.push(Ingredient.new(name: 'Thiamine Hydrochloride solution (34g/L)', amount: 8, unit: wet_units, directions: wet_directions))\r\n ingredients.push(Ingredient.new(name: '10% Casamino Acids', amount: 16, unit: wet_units, directions: wet_directions))\r\n ingredients.push(Ingredient.new(name: '20% D-Glucose', amount: 16, unit: wet_units, directions: wet_directions))\r\n ingredients.push(Ingredient.new(name: '5x M9 salts', amount: 160, unit: wet_units, directions: wet_directions))\r\n\r\n mix_note = 'Shake the bottle(s) to mix the solution.'\r\n water_note = 'sterile DI Water'\r\n label_note = 'M9-glucose is not autoclaved. store it in the Deli Fridge.'\r\n elsif media.sample_name.include?('5x M9 salts')\r\n ingredients.push(Ingredient.new(name: 'DI water', amount: 600, unit: wet_units, directions: 'DI water carboy'))\r\n ingredients.push(Ingredient.new(name: 'Sodium Phosphate, Dibasic', amount: 27.12, unit: dry_units, directions: dry_directions)) # #{\"Sodium Phosphate, Dibasic\"}\r\n ingredients.push(Ingredient.new(name: 'Potassium Phosphate, Monobasic', amount: 12, unit: dry_units, directions: dry_directions)) # {\"Potassium Phosphate, Monobasic\"}\r\n ingredients.push(Ingredient.new(name: 'Sodium Chloride', amount: 2.0, unit: dry_units, directions: dry_directions))\r\n ingredients.push(Ingredient.new(name: 'Ammonium Chloride', amount: 4.0, unit: dry_units, directions: dry_directions))\r\n\r\n mix_note = \"stir with magnetic stirrer until dissolved.\\nThis solution is sterilized by autoclaving.\"\r\n elsif media.sample_name.include?('Casamino Acids 10%')\r\n ingredients.push(Ingredient.new(name: 'Bacto Casamino Acids', amount: 80.0, unit: dry_units, directions: dry_directions))\r\n\r\n mix_note = 'stir with magnetic stirrer until dissolved.'\r\n end\r\n\r\n make_media_steps(bottle: media.bottle, num_bottles: media.count, multiplier: multiplier, ingredients: ingredients) \r\n label_media_steps(multiplier, label, media.output, mix_note, water_note, label_note)\r\n end\r\n end\r\n\r\n def create_label(media:)\r\n if media.sample_name.include?('SOB')\r\n \"SOB #{media.type.to_s.capitalize}\"\r\n elsif media.sample_name.include?('SOC')\r\n \"SOC #{media.type.to_s.capitalize}\"\r\n elsif media.sample_name.include?('TB')\r\n \"TB #{media.type.to_s.capitalize}\"\r\n elsif media.sample_name.include?('LB')\r\n \"LB #{media.type.to_s.capitalize}\"\r\n elsif media.sample_name.include?('YPAD')\r\n if media.sample_name.include?('Sorbitol')\r\n \"YPAD + 1M Sorb #{media.type.to_s.capitalize}\"\r\n else\r\n \"YPAD #{media.type.to_s.capitalize}\"\r\n end\r\n elsif media.sample_name.include?('SC') \r\n \"SC #{media.type.to_s.capitalize}\"\r\n elsif media.sample_name.include?('SDO') \r\n label = 'SDO'\r\n label += ' +Gal' if media.sample_name.include?('Gal')\r\n label += ' -His' unless media.sample_name.include?('-His')\r\n label += ' -Leu' unless media.sample_name.include?('-Leu')\r\n label += ' -Ura' unless media.sample_name.include?('-Ura')\r\n label += ' -Trp' unless media.sample_name.include?('-Trp')\r\n \"#{label} #{media.type.to_s.capitalize}\"\r\n elsif media.sample_name.include?('Synthetic Complete + 1M Sorbitol Media')\r\n \"SC + 1M Sorbitol #{media.type.to_s.capitalize}\"\r\n elsif media.sample_name.include?('Synthetic Complete + 2% glycerol 2% ethanol Media')\r\n \"SC + 2% glycerol 2% EtOH #{media.type.to_s.capitalize}\"\r\n elsif media.sample_name.include?('M9 + Glucose')\r\n 'M9-glucose'\r\n elsif media.sample_name.include?('5x M9 salts')\r\n '5x M9 salts'\r\n elsif media.sample_name.include?('Casamino Acids 10%')\r\n 'Casamino acids 10%'\r\n end\r\n end\r\nend\r\n\r\n","precondition":"def precondition(op)\n true\nend","cost_model":"def cost(op)\n { labor: 0, materials: 0 }\nend","documentation":"Documentation here. Start with a paragraph, not a heading or title, as in most views, the title will be supplied by the view.","test":"# frozen_string_literal: true\n\nclass ProtocolTest \u003c ProtocolTestBase\n def setup\n\n media_list = []\n # TODO: check for liquid vs agar\n media_list.push(media_sample(name: '10% Glycerol', description: '10% Glycerol for making electrocompetent E. coli'))\n log('setup2')\n #media_list.push(media_sample(name: 'SOB', description: 'Recovery media for E. coli transformations, media for comp cell protocols'))\n #media_list.push(media_sample(name: 'SOC', description: 'Recovery media for E. coli transformations'))\n #media_list.push(media_sample(name: 'LB', description: 'LB'))\n #media_list.push(media_sample(name: 'TB', description: 'TB'))\n #media_list.push(media_sample(name: 'YPAD', description: 'YPAD'))\n #media_list.push(media_sample(name: 'YPAD + 1M Sorbitol', description: 'YPAD rich, fast growing media with 1M Sorbitol'))\n\n\n media_list.each do |media|\n add_operation.with_output('Media', media)\n end\n log('setup3')\n end\n\n def analyze\n assert_equal(@backtrace.last[:operation], 'complete')\n #get_plates_display = find_display_by_title('Get fresh agar plates')\n #refute_nil(get_plates_display, 'Missing first screen')\n #assert_equal(get_plates_display[:content][1], {check: 'Please get 1 agar plate'})\n end\n\n private\n\n def media_sample(name:, description:, user: nil)\n sample(\n name: name,\n description: description,\n user: user,\n type_name: 'Media',\n attributes: []\n )\n end\n\n def sample(name:, description:, user: nil, type_name:, attributes:)\n sample_type = sample_type(type_name: type_name)\n return nil if sample_type.nil?\n\n user = User.all.last if user.nil?\n Sample.creator(\n {\n sample_type_id: sample_type.id,\n description: description,\n name: name,\n project: 'Testing',\n field_values: attributes\n },\n user\n )\n end\n\n def sample_type(type_name:, description: 'test type', definition: nil)\n sample_type = SampleType.find_by(name: type_name)\n return sample_type unless sample_type.nil?\n\n SampleType.create_from_raw(\n name: type_name,\n description: description,\n field_types: definition\n )\n end\nend\n","timing":null}},{"library":{"name":"MediaRecipe","category":"Reagents","code_source":"# frozen_string_literal: true\n\nclass Measure\n include Comparable\n\n attr_reader :amount, :unit\n\n def initialize(amount:, unit:)\n @amount = amount\n @unit = unit\n end\n\n def \u003c=\u003e(other)\n if @unit == other.unit\n if @amount \u003c other.amount\n -1\n elsif @amount \u003e other.amount\n 1\n else\n 0\n end\n else \n @unit \u003c=\u003e other.unit\n end\n end\n\n def to_s\n \"#{amount} #{unit}\"\n end\nend\n\nclass Ingredient\n attr_reader :name, :amount, :directions, :unit\n\n def initialize(name:, amount:, unit:, directions:)\n @name = name\n @amount = amount\n @unit = unit\n @directions = directions\n end\nend\n\nclass Media\n attr_reader :sample_name, :bottle, :volume, :unit, :type, :output\n attr_accessor :count\n\n def initialize(sample_name:, bottle:, volume:, unit:, type:, count:, output:)\n @sample_name = sample_name\n @bottle = bottle\n @volume = volume\n @unit = unit\n @type = type\n @count = count\n @output = output\n end\nend\n\nclass Recipe\n attr_reader :ingredients\n\n def initialize\n @ingredients = []\n end\n\n def add(ingredient:)\n @ingredients.push(ingredient)\n end\nend\n"}}]}