Class: PcrBatcher
- Inherits:
-
Object
- Object
- PcrBatcher
- Defined in:
- lib/pcr_batching.rb
Overview
Pcrbatcher uses a nearest neighbor chain algorithm to batch pcr operations with their nearest neighbors by extension time until cycler_count groups remain. These groups are marked by the maximum extension they contain. Then, for each thermocycler group, the operations within that group are clustered again with a nearest neighbor chain algorithm by temperature, that refuses to make temp groups of larger than @column_count until @row_count temp groups remain. each row-grouping is marked with its average temperature. range of temp gradient is determined by the highest and lowest temp groups. Groups are placed into the rows that have nearest temperature to their average, rounding up always.
Instance Method Summary collapse
-
#add_pcr_operation(opts = {}) ⇒ Object
Make a brand new pcr operation representation and add it to the list of pcr operations to be batched.
-
#batch(use_checkrep = false) ⇒ Hash<ExtensionCluster, Set<TannealCluster>>
Batches pcr_operations into cycler_count reaction groups, and within each reaction group, batches operations into @row_count temperature groups.
-
#defaults ⇒ Object
Batching settings that work well for the UW BIOFAB PCR workflow which uses 4 X thermocyclers.
-
#initialize(opts = {}) ⇒ PcrBatcher
constructor
Initialize the important fields needed to batch some pcr operations.
Constructor Details
#initialize(opts = {}) ⇒ PcrBatcher
Initialize the important fields needed to batch some pcr operations.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pcr_batching.rb', line 45 def initialize opts = {} opts = defaults.merge opts @cycler_count = opts[:cycler_count] @row_count = opts[:row_count] @column_count = opts[:column_count] @temp_range = opts[:temp_range] @mand_ext_comb_diff = opts[:mand_ext_comb_diff] @mand_tanneal_comb_diff = opts[:mand_tanneal_comb_diff] @max_ext_comb_diff = opts[:max_ext_comb_diff] @max_tanneal_comb_diff = opts[:max_tanneal_comb_diff] @pcr_operations = [] end |
Instance Method Details
#add_pcr_operation(opts = {}) ⇒ Object
Make a brand new pcr operation representation and add it to the list of pcr operations to be batched.
89 90 91 92 93 94 95 |
# File 'lib/pcr_batching.rb', line 89 def add_pcr_operation opts = {} @pcr_operations << PcrOperation.new( extension_time: opts[:extension_time], anneal_temp: opts[:anneal_temp], unique_id: opts[:unique_id], ) end |
#batch(use_checkrep = false) ⇒ Hash<ExtensionCluster, Set<TannealCluster>>
Batches pcr_operations into cycler_count reaction groups, and within each reaction group, batches operations into @row_count temperature groups.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/pcr_batching.rb', line 106 def batch(use_checkrep = false) extension_cluster_to_tanneal_clusters = Hash.new extension_graph = ExtensionClusterGraph.new( pcr_operations: @pcr_operations, thermocycler_quantity: @cycler_count, thermocycler_rows: @row_count, thermocycler_columns: @column_count, thermocycler_temp_range: @temp_range, force_combination_distance: @mand_ext_comb_diff, prevent_combination_distance: @max_ext_comb_diff ) # O(n^2) extension_clusters = extension_graph.perform_clustering use_checkrep # O(n^2) extension_clusters.each do |extension_cluster| # m clusters => O(m) tanneal_graph = TannealClusterGraph.new( # q pcr operations per cluster => O(q^2) pcr_operations: extension_cluster.members, thermocycler_rows: @row_count, thermocycler_columns: @column_count, force_combination_distance: @mand_tanneal_comb_diff, prevent_combination_distance: @max_tanneal_comb_diff ) tanneal_clusters = tanneal_graph.perform_clustering use_checkrep #O(q^2) extension_cluster_to_tanneal_clusters[extension_cluster] = tanneal_clusters end # m * q = n => O(2 * n^2) extension_cluster_to_tanneal_clusters end |
#defaults ⇒ Object
Batching settings that work well for the UW BIOFAB PCR workflow which uses 4 X thermocyclers
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/pcr_batching.rb', line 60 def defaults { cycler_count: 4, row_count: 8, column_count: 12, temp_range: 17, mand_ext_comb_diff: 30.0, mand_tanneal_comb_diff: 0.3, max_ext_comb_diff: 300.0, max_tanneal_comb_diff: 3.0, } end |