Skip to content

Commit

Permalink
New pipeline update
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kasprzyk committed Feb 20, 2024
1 parent a113688 commit 5b3f154
Show file tree
Hide file tree
Showing 21 changed files with 11,367 additions and 81 deletions.
25 changes: 25 additions & 0 deletions OT2-setup/data/labware.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
protocol,location,labware,well_name,reactant,volume
transformation,1,armadillo_96_wellplate_200ul_pcr_full_skirt,A1,pUC19,20
transformation,1,armadillo_96_wellplate_200ul_pcr_full_skirt,B1,pUC19,20
transformation,1,armadillo_96_wellplate_200ul_pcr_full_skirt,C1,pUC19,20
transformation,1,armadillo_96_wellplate_200ul_pcr_full_skirt,D1,pUC19,20
transformation,1,armadillo_96_wellplate_200ul_pcr_full_skirt,E1,pJKR,20
transformation,1,armadillo_96_wellplate_200ul_pcr_full_skirt,F1,pJKR,20
transformation,1,armadillo_96_wellplate_200ul_pcr_full_skirt,G1,pJKR,20
transformation,1,armadillo_96_wellplate_200ul_pcr_full_skirt,H1,pJKR,20
transformation,4,usascientific_96_wellplate_2.4ml_deep,A1,cells,300
transformation,4,usascientific_96_wellplate_2.4ml_deep,B1,cells,300
transformation,4,usascientific_96_wellplate_2.4ml_deep,C1,cells,300
transformation,4,usascientific_96_wellplate_2.4ml_deep,D1,cells,300
transformation,4,usascientific_96_wellplate_2.4ml_deep,E1,cells,300
transformation,4,usascientific_96_wellplate_2.4ml_deep,F1,cells,300
transformation,4,usascientific_96_wellplate_2.4ml_deep,G1,cells,300
transformation,4,usascientific_96_wellplate_2.4ml_deep,H1,cells,300
transformation,5,usascientific_96_wellplate_2.4ml_deep,A1,SOC,1500
transformation,5,usascientific_96_wellplate_2.4ml_deep,B1,SOC,1500
transformation,5,usascientific_96_wellplate_2.4ml_deep,C1,SOC,1500
transformation,5,usascientific_96_wellplate_2.4ml_deep,D1,SOC,1500
transformation,5,usascientific_96_wellplate_2.4ml_deep,E1,SOC,1500
transformation,5,usascientific_96_wellplate_2.4ml_deep,F1,SOC,1500
transformation,5,usascientific_96_wellplate_2.4ml_deep,G1,SOC,1500
transformation,5,usascientific_96_wellplate_2.4ml_deep,H1,SOC,1500
97 changes: 97 additions & 0 deletions OT2-setup/data/spotting-data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
plate_location,source_well,destination_well,spotting_volume,agar_plate_weight
1,A1,A1,5,33
1,B1,B1,5,33
1,C1,C1,5,33
1,D1,D1,5,33
1,E1,E1,5,33
1,F1,F1,5,33
1,G1,G1,5,33
1,H1,H1,5,33
1,A2,A2,5,33
1,B2,B2,5,33
1,C2,C2,5,33
1,D2,D2,5,33
1,E2,E2,5,33
1,F2,F2,5,33
1,G2,G2,5,33
1,H2,H2,5,33
1,A3,A3,5,33
1,B3,B3,5,33
1,C3,C3,5,33
1,D3,D3,5,33
1,E3,E3,5,33
1,F3,F3,5,33
1,G3,G3,5,33
1,H3,H3,5,33
1,A4,A4,5,33
1,B4,B4,5,33
1,C4,C4,5,33
1,D4,D4,5,33
1,E4,E4,5,33
1,F4,F4,5,33
1,G4,G4,5,33
1,H4,H4,5,33
1,A5,A5,5,33
1,B5,B5,5,33
1,C5,C5,5,33
1,D5,D5,5,33
1,E5,E5,5,33
1,F5,F5,5,33
1,G5,G5,5,33
1,H5,H5,5,33
1,A6,A6,5,33
1,B6,B6,5,33
1,C6,C6,5,33
1,D6,D6,5,33
1,E6,E6,5,33
1,F6,F6,5,33
1,G6,G6,5,33
1,H6,H6,5,33
1,A7,A7,5,33
1,B7,B7,5,33
1,C7,C7,5,33
1,D7,D7,5,33
1,E7,E7,5,33
1,F7,F7,5,33
1,G7,G7,5,33
1,H7,H7,5,33
1,A8,A8,5,33
1,B8,B8,5,33
1,C8,C8,5,33
1,D8,D8,5,33
1,E8,E8,5,33
1,F8,F8,5,33
1,G8,G8,5,33
1,H8,H8,5,33
1,A9,A9,5,33
1,B9,B9,5,33
1,C9,C9,5,33
1,D9,D9,5,33
1,E9,E9,5,33
1,F9,F9,5,33
1,G9,G9,5,33
1,H9,H9,5,33
1,A10,A10,5,33
1,B10,B10,5,33
1,C10,C10,5,33
1,D10,D10,5,33
1,E10,E10,5,33
1,F10,F10,5,33
1,G10,G10,5,33
1,H10,H10,5,33
1,A11,A11,5,33
1,B11,B11,5,33
1,C11,C11,5,33
1,D11,D11,5,33
1,E11,E11,5,33
1,F11,F11,5,33
1,G11,G11,5,33
1,H11,H11,5,33
1,A12,A12,5,33
1,B12,B12,5,33
1,C12,C12,5,33
1,D12,D12,5,33
1,E12,E12,5,33
1,F12,F12,5,33
1,G12,G12,5,33
1,H12,H12,5,33
16 changes: 16 additions & 0 deletions OT2-setup/data/spotting-parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"transformation_plate_name":"armadillo_96_wellplate_200ul_pcr_full_skirt",
"agar_plate_name":"armadillo_96_wellplate_200ul_pcr_full_skirt",
"pipette_tiprack_name":"opentrons_96_tiprack_20ul",
"pipette_tiprack_slots":[6,5],
"pipette_name":"p20_multi_gen2",
"pipette_mount":"left",
"aspirate_rate":30,
"dispense_rate":60,
"aspirate_height":0.1,
"dispense_height":0.1,
"dead_volume": 1,
"plate_weight":14.11,
"agar_density":0.00095,
"spotting_height":0.5
}
33 changes: 33 additions & 0 deletions OT2-setup/data/transformation-data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
dna_well,dna_volume,cells_well,cells_volume,soc_well,soc_volume,transformation_well
A1,3,A2,30,A1,150,A1
B1,3,B2,30,B1,150,B1
C1,3,C2,30,C1,150,C1
D1,3,D2,30,D1,150,D1
E1,3,E2,30,E1,150,E1
F1,3,F2,30,F1,150,F1
G1,3,G2,30,G1,150,G1
H1,3,H2,30,H1,150,H1
A1,2,A2,20,A1,100,A2
B1,2,B2,20,B1,100,B2
C1,2,C2,20,C1,100,C2
D1,2,D2,20,D1,100,D2
E1,2,E2,20,E1,100,E2
F1,2,F2,20,F1,100,F2
G1,2,G2,20,G1,100,G2
H1,2,H2,20,H1,100,H2
A1,1,A2,10,A1,50,A3
B1,1,B2,10,B1,50,B3
C1,1,C2,10,C1,50,C3
D1,1,D2,10,D1,50,D3
E1,1,E2,10,E1,50,E3
F1,1,F2,10,F1,50,F3
G1,1,G2,10,G1,50,G3
H1,1,H2,10,H1,50,H3
A1,0,A2,30,A1,150,A4
B1,0,B2,30,B1,150,B4
C1,0,C2,30,C1,150,C4
D1,0,D2,30,D1,150,D4
E1,0,E2,30,E1,150,E4
F1,0,F2,30,F1,150,F4
G1,0,G2,30,G1,150,G4
H1,0,H2,30,H1,150,H4
25 changes: 25 additions & 0 deletions OT2-setup/data/transformation-parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"init_temp":4,
"init_time":20,
"heat_temp":42,
"heat_time":30,
"cool_temp":4,
"cool_time":2,
"inc_temp":37,
"inc_time":60,
"dna_plate_name":"armadillo_96_wellplate_200ul_pcr_full_skirt",
"dna_plate_slot":1,
"cells_plate_name": "usascientific_96_wellplate_2.4ml_deep",
"cells_plate_slot":4,
"soc_plate_name": "usascientific_96_wellplate_2.4ml_deep",
"soc_plate_slot": 5,
"transformation_plate_name":"armadillo_96_wellplate_200ul_pcr_full_skirt",
"right_pipette_tiprack_name":"opentrons_96_tiprack_20ul",
"right_pipette_tiprack_slots":[2,3],
"right_pipette_name":"p20_multi_gen2",
"right_pipette_mount":"right",
"left_pipette_tiprack_name":"opentrons_96_tiprack_300ul",
"left_pipette_tiprack_slots":[6,9],
"left_pipette_name":"p300_multi_gen2",
"left_pipette_mount":"left"
}
134 changes: 134 additions & 0 deletions OT2-setup/generate-protocol.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/bash

# Function to display usage information
usage() {
echo "Usage: $0 experiment=experiment1,experiment2,... [csv_file=csv1,csv2,...] [json_file=json1,json2,...]"
exit 1
}

# Check if the correct number of arguments is provided
if [ "$#" -lt 1 ]; then
usage
fi

# Set default values
csv_files=""
json_files=""

# Parse command-line arguments
for arg in "$@"; do
case $arg in
experiment=*)
experiment_types="${arg#*=}"
;;
csv_file=*)
csv_files="${arg#*=}"
;;
json_file=*)
json_files="${arg#*=}"
;;
*)
echo "Error: Invalid argument: $arg"
usage
;;
esac
done

# Function to check if a file exists
check_file_exists() {
if [ ! -f "$1" ]; then
echo "Error: $1 file not found."
exit 1
fi
}

# Function to extract variable from JSON
extract_variable_from_json() {
local json_file="$1"
local variable_name="$2"
local variable_line=$(grep "$variable_name" "$json_file")

# Extract the value part
local variable_value=$(echo "$variable_line" | cut -d '"' -f 4)
echo "$variable_value"
}

# Function to process each experiment type
process_experiment_type() {
local experiment_type="$1"
local input_csv="$2"
local input_json="$3"

local template_py=""

case "$experiment_type" in
transformation)
template_py="./setup/protocol-templates/transformation-template.py"
;;
spotting)
template_py="./setup/protocol-templates/spotting-template.py"
;;
*)
echo "Error: Unsupported experiment type: $experiment_type"
exit 1
;;
esac

# Check if the template Python file exists
check_file_exists "$template_py"

# If CSV file not specified, use default in "data" folder
if [ -z "$input_csv" ]; then
input_csv="data/${experiment_type}-data.csv"
fi
# If JSON file not specified, use default in "data" folder
if [ -z "$input_json" ]; then
input_json="data/${experiment_type}-parameters.json"
fi

# Check if the input CSV file exists
check_file_exists "$input_csv"
# Check if the input JSON file exists
check_file_exists "$input_json"

# Read contents of input CSV into a variable
csv_content=$(<"$input_csv")

# Define the content for protocol.py
new_content="csv_file = \"\"\"\n$csv_content\n\"\"\"\n\n"
# Read contents of input JSON into a variable and remove newlines
json_content="parameters_json = \"\"\"$(<"$input_json" tr -d '\n' | tr -d '[:space:]'| tr -d '[:space:]')\"\"\"\n"

# Extract the name from the template file
template_name=$(basename "$template_py" | sed 's/.*\([a-zA-Z]\)-template\.py/\1/')
# Generate the output file name in the "protocols" folder
output_folder="results"
output_file="${output_folder}/${experiment_type}-protocol.py"

# Create the protocols folder if it doesn't exist
mkdir -p "$output_folder"

# If the file exists, append the new content at the top
old_content=$(<"$template_py")
echo -e "$new_content$json_content$old_content" > "$output_file"
echo "Protocol for $experiment_type has been generated. Output file: $output_file"

# Get the transformation_plate_name and dna_plate_name from the parameters JSON
transformation_plate_name=$(extract_variable_from_json "$input_json" "transformation_plate_name")
dna_plate_name=$(extract_variable_from_json "$input_json" "dna_plate_name")

# Call the R scripts
Rscript ./setup/create-labware/visualise-labware.R ./data/labware.csv "${output_folder}"
Rscript ./setup/create-labware/visualise-labware-2.R ./data/transformation-data.csv "${output_folder}"
Rscript ./setup/instruction-templates/transformation-instruction.R "./data/transformation-parameters.json" "${output_folder}/Instructions.pdf"
}

# Split comma-separated values into arrays
IFS=',' read -ra experiment_type_array <<< "$experiment_types"
IFS=',' read -ra csv_file_array <<< "$csv_files"
IFS=',' read -ra json_file_array <<< "$json_files"

# Process each experiment type
for ((i=0; i<"${#experiment_type_array[@]}"; i++)); do
process_experiment_type "${experiment_type_array[i]}" "${csv_file_array[i]}" "${json_file_array[i]}"
done
Loading

0 comments on commit 5b3f154

Please sign in to comment.