Use flowcell model information to estimate how long it will take to run the flowcell.
authorDiane Trout <diane@ghic.org>
Wed, 22 Jan 2014 00:38:42 +0000 (16:38 -0800)
committerDiane Trout <diane@ghic.org>
Tue, 10 Jun 2014 23:40:48 +0000 (16:40 -0700)
htsworkflow/frontend/experiments/experiments.py
htsworkflow/frontend/experiments/fixtures/test_flowcells.json
htsworkflow/frontend/experiments/test_experiments.py

index 9493765dcb02cf31528c295be5dd5bd5389165cf..fef68ed130526e33400302db57de772d82b81ade 100644 (file)
@@ -308,16 +308,11 @@ def estimateFlowcellDuration(flowcell):
     Attempt to estimate how long it will take to run a flowcell
 
     """
-    # (3600 seconds * 1.5 hours per cycle )
-    sequencing_seconds_per_cycle= 3600 * 1.5
-    # 800 is a rough guess
-    pipeline_seconds_per_cycle = 800
-
     cycles = flowcell.read_length
     if flowcell.paired_end:
         cycles *= 2
-    sequencing_time = timedelta(0, cycles * sequencing_seconds_per_cycle)
-    analysis_time = timedelta(0, cycles * pipeline_seconds_per_cycle)
+    sequencing_time = timedelta(0, cycles * flowcell.flowcell_model.per_cycle_time)
+    analysis_time = timedelta(0, flowcell.flowcell_model.fixed_time)
     estimate_mid = sequencing_time + analysis_time
 
     return estimate_mid
index de6baec4db01e22cda5e7ed518e15f05a97874bb..44231bdf3d0e878f4c4303b56d5d937ca3fc3d02 100644 (file)
        "lane_number": 8,
        "pM": "7"
        }
-   }
+   },
+    {"pk": 300, "model": "experiments.flowcell",
+     "fields": {
+      "paired_end": true,
+      "run_date": "2014-01-01T01:23:45-0800",
+      "read_length": 50,
+      "notes": "",
+      "advanced_run": false,
+      "control_lane": 2,
+      "cluster_station": 3,
+      "sequencer": 2,
+      "flowcell_id": "12345ACXX",
+      "flowcell_model": 2
+      }
+  }
 ]
index 9cafb03d992004ec97b5f3cde31745cb4e7f73b0..4a665e1222e5ab1e625cbee44b3e2f5f88985d97 100644 (file)
@@ -4,6 +4,7 @@ try:
     import json
 except ImportError, e:
     import simplejson as json
+from datetime import timedelta
 import os
 import shutil
 import sys
@@ -481,6 +482,25 @@ class ExperimentsTestCases(TestCase):
             self.assertTrue(library_id in expected[lane_id])
         self.assertEqual(count, 10)
 
+    def test_flowcell_estimates(self):
+        classic_flowcell = models.FlowCell.objects.get(pk=153)
+        classic_mid = experiments.estimateFlowcellDuration(classic_flowcell)
+
+        self.assertEqual(classic_mid, timedelta(4, 44000))
+
+        rapid_flowcell = models.FlowCell.objects.get(pk=300)
+        rapid_mid = experiments.estimateFlowcellDuration(rapid_flowcell)
+        self.assertEqual(rapid_mid, timedelta(seconds=60800))
+
+    def test_round_to_days(self):
+        data = [
+            [timedelta(2, 12345), (timedelta(days=2), timedelta(days=3))],
+            [timedelta(0, 345), (timedelta(days=0), timedelta(days=1))],
+        ]
+
+        for estimate, expected in data:
+            rounded = experiments.roundToDays(estimate)
+            self.assertEqual(rounded, expected)
 
 class TestFileType(TestCase):
     fixtures = ['initial_data.json',