From b15ba98c27dd2c34cedbe2b1f861899b859b6355 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Tue, 21 Jan 2014 16:38:42 -0800 Subject: [PATCH] Use flowcell model information to estimate how long it will take to run the flowcell. --- .../frontend/experiments/experiments.py | 9 ++------- .../experiments/fixtures/test_flowcells.json | 16 ++++++++++++++- .../frontend/experiments/test_experiments.py | 20 +++++++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/htsworkflow/frontend/experiments/experiments.py b/htsworkflow/frontend/experiments/experiments.py index 9493765..fef68ed 100644 --- a/htsworkflow/frontend/experiments/experiments.py +++ b/htsworkflow/frontend/experiments/experiments.py @@ -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 diff --git a/htsworkflow/frontend/experiments/fixtures/test_flowcells.json b/htsworkflow/frontend/experiments/fixtures/test_flowcells.json index de6baec..44231bd 100644 --- a/htsworkflow/frontend/experiments/fixtures/test_flowcells.json +++ b/htsworkflow/frontend/experiments/fixtures/test_flowcells.json @@ -1273,5 +1273,19 @@ "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 + } + } ] diff --git a/htsworkflow/frontend/experiments/test_experiments.py b/htsworkflow/frontend/experiments/test_experiments.py index 9cafb03..4a665e1 100644 --- a/htsworkflow/frontend/experiments/test_experiments.py +++ b/htsworkflow/frontend/experiments/test_experiments.py @@ -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', -- 2.30.2