From b43a6b4b7b9649ec6cc433b9c38433e86fea096d Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Tue, 8 Jan 2013 16:11:13 -0800 Subject: [PATCH] A better resolution to a possible circular dependency. The runfolder subdirectory processing tools (firecrest, bustard, gerald, etc.) were importing runfolder for some common constants, however runfolder imported them to actually build the runfolder structure. My previous solution was to only include the imports for the sub-directory processing in the function that used them. However that lead to needing nested functions which seemed confusing. What I did was move the common constants into pipelines.__init__ and just imported them from there. --- htsworkflow/pipelines/__init__.py | 9 ++++++++ htsworkflow/pipelines/bustard.py | 2 +- htsworkflow/pipelines/eland.py | 2 +- htsworkflow/pipelines/firecrest.py | 2 +- htsworkflow/pipelines/genomemap.py | 2 +- htsworkflow/pipelines/gerald.py | 2 +- htsworkflow/pipelines/ipar.py | 2 +- htsworkflow/pipelines/retrieve_config.py | 2 +- htsworkflow/pipelines/runfolder.py | 21 +++++++------------ htsworkflow/pipelines/summary.py | 1 - .../pipelines/test/test_extract_results.py | 2 +- htsworkflow/pipelines/test/test_genomemap.py | 2 +- .../pipelines/test/test_runfolder026.py | 2 +- .../pipelines/test/test_runfolder030.py | 2 +- .../pipelines/test/test_runfolder110.py | 2 +- .../test/test_runfolder_casava_1_7.py | 2 +- .../pipelines/test/test_runfolder_ipar100.py | 2 +- .../pipelines/test/test_runfolder_ipar130.py | 2 +- .../pipelines/test/test_runfolder_pair.py | 2 +- .../pipelines/test/test_runfolder_rta.py | 2 +- .../pipelines/test/test_runfolder_rta160.py | 2 +- .../pipelines/test/test_runfolder_rta180.py | 2 +- .../pipelines/test/test_runfolder_rta1_12.py | 2 +- 23 files changed, 37 insertions(+), 34 deletions(-) diff --git a/htsworkflow/pipelines/__init__.py b/htsworkflow/pipelines/__init__.py index beabfd1..8b4b191 100644 --- a/htsworkflow/pipelines/__init__.py +++ b/htsworkflow/pipelines/__init__.py @@ -4,3 +4,12 @@ Provide code to interact with the vendor tools to produce useable "raw" data. the illumina sub-package contains components to interact with the Illumina provided GAPipeline """ +import lxml.etree as ElementTree + +EUROPEAN_STRPTIME = "%d-%m-%Y" +EUROPEAN_DATE_RE = "([0-9]{1,2}-[0-9]{1,2}-[0-9]{4,4})" +VERSION_RE = "([0-9\.]+)" +USER_RE = "([a-zA-Z0-9]+)" +LANES_PER_FLOWCELL = 8 +LANE_LIST = range(1, LANES_PER_FLOWCELL + 1) + diff --git a/htsworkflow/pipelines/bustard.py b/htsworkflow/pipelines/bustard.py index 2993d06..b5bf7e1 100644 --- a/htsworkflow/pipelines/bustard.py +++ b/htsworkflow/pipelines/bustard.py @@ -13,7 +13,7 @@ import re import sys import time -from htsworkflow.pipelines.runfolder import \ +from htsworkflow.pipelines import \ ElementTree, \ VERSION_RE, \ EUROPEAN_STRPTIME diff --git a/htsworkflow/pipelines/eland.py b/htsworkflow/pipelines/eland.py index 84eb397..a508a49 100644 --- a/htsworkflow/pipelines/eland.py +++ b/htsworkflow/pipelines/eland.py @@ -10,7 +10,7 @@ import stat import sys import types -from htsworkflow.pipelines.runfolder import ElementTree, LANE_LIST +from htsworkflow.pipelines import ElementTree, LANE_LIST from htsworkflow.pipelines.samplekey import SampleKey from htsworkflow.pipelines.genomemap import GenomeMap from htsworkflow.util.ethelp import indent, flatten diff --git a/htsworkflow/pipelines/firecrest.py b/htsworkflow/pipelines/firecrest.py index de6b042..85b9d39 100644 --- a/htsworkflow/pipelines/firecrest.py +++ b/htsworkflow/pipelines/firecrest.py @@ -17,7 +17,7 @@ import os import re import time -from htsworkflow.pipelines.runfolder import \ +from htsworkflow.pipelines import \ ElementTree, \ VERSION_RE, \ EUROPEAN_STRPTIME diff --git a/htsworkflow/pipelines/genomemap.py b/htsworkflow/pipelines/genomemap.py index fe6254e..1dd95df 100644 --- a/htsworkflow/pipelines/genomemap.py +++ b/htsworkflow/pipelines/genomemap.py @@ -3,7 +3,7 @@ from glob import glob import os import collections -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree vldInfo = collections.namedtuple('vldInfo', 'name is_link') diff --git a/htsworkflow/pipelines/gerald.py b/htsworkflow/pipelines/gerald.py index db687ea..2eaff67 100644 --- a/htsworkflow/pipelines/gerald.py +++ b/htsworkflow/pipelines/gerald.py @@ -12,7 +12,7 @@ from htsworkflow.pipelines.summary import Summary, SummaryGA, SummaryHiSeq from htsworkflow.pipelines.eland import eland, ELAND from htsworkflow.pipelines.samplekey import SampleKey -from htsworkflow.pipelines.runfolder import \ +from htsworkflow.pipelines import \ ElementTree, \ EUROPEAN_STRPTIME, \ LANES_PER_FLOWCELL, \ diff --git a/htsworkflow/pipelines/ipar.py b/htsworkflow/pipelines/ipar.py index 28f523d..f818b34 100644 --- a/htsworkflow/pipelines/ipar.py +++ b/htsworkflow/pipelines/ipar.py @@ -19,7 +19,7 @@ import re import stat import time -from htsworkflow.pipelines.runfolder import \ +from htsworkflow.pipelines import \ ElementTree, \ VERSION_RE, \ EUROPEAN_STRPTIME diff --git a/htsworkflow/pipelines/retrieve_config.py b/htsworkflow/pipelines/retrieve_config.py index bd220a0..a189f09 100644 --- a/htsworkflow/pipelines/retrieve_config.py +++ b/htsworkflow/pipelines/retrieve_config.py @@ -22,7 +22,7 @@ from htsworkflow.util.url import normalize_url from htsworkflow.pipelines.genome_mapper import \ getAvailableGenomes, \ constructMapperDict -from htsworkflow.pipelines.runfolder import LANE_LIST +from htsworkflow.pipelines import LANE_LIST # JSON dictionaries use strings LANE_LIST_JSON = [ str(l) for l in LANE_LIST ] diff --git a/htsworkflow/pipelines/runfolder.py b/htsworkflow/pipelines/runfolder.py index a3b7457..f23b255 100644 --- a/htsworkflow/pipelines/runfolder.py +++ b/htsworkflow/pipelines/runfolder.py @@ -12,17 +12,16 @@ import sys import tarfile import time -import lxml.etree as ElementTree - LOGGER = logging.getLogger(__name__) -EUROPEAN_STRPTIME = "%d-%m-%Y" -EUROPEAN_DATE_RE = "([0-9]{1,2}-[0-9]{1,2}-[0-9]{4,4})" -VERSION_RE = "([0-9\.]+)" -USER_RE = "([a-zA-Z0-9]+)" -LANES_PER_FLOWCELL = 8 -LANE_LIST = range(1, LANES_PER_FLOWCELL + 1) - +from htsworkflow.pipelines import firecrest +from htsworkflow.pipelines import ipar +from htsworkflow.pipelines import bustard +from htsworkflow.pipelines import gerald +from htsworkflow.pipelines import ElementTree, \ + EUROPEAN_STRPTIME, EUROPEAN_DATE_RE, \ + VERSION_RE, USER_RE, \ + LANES_PER_FLOWCELL, LANE_LIST from htsworkflow.util.alphanum import alphanum from htsworkflow.util.ethelp import indent, flatten from htsworkflow.util.queuecommands import QueueCommands @@ -121,10 +120,6 @@ class PipelineRun(object): def set_elements(self, tree): # this file gets imported by all the others, # so we need to hide the imports to avoid a cyclic imports - from htsworkflow.pipelines import firecrest - from htsworkflow.pipelines import ipar - from htsworkflow.pipelines import bustard - from htsworkflow.pipelines import gerald tag = tree.tag.lower() if tag != PipelineRun.PIPELINE_RUN.lower(): diff --git a/htsworkflow/pipelines/summary.py b/htsworkflow/pipelines/summary.py index 6fdda43..8f47670 100644 --- a/htsworkflow/pipelines/summary.py +++ b/htsworkflow/pipelines/summary.py @@ -7,7 +7,6 @@ import re import types from pprint import pprint -#from htsworkflow.pipelines.runfolder import ElementTree from lxml import html from lxml import etree from htsworkflow.util.ethelp import indent, flatten diff --git a/htsworkflow/pipelines/test/test_extract_results.py b/htsworkflow/pipelines/test/test_extract_results.py index 6f2b423..7381d8c 100644 --- a/htsworkflow/pipelines/test/test_extract_results.py +++ b/htsworkflow/pipelines/test/test_extract_results.py @@ -13,7 +13,7 @@ from htsworkflow.pipelines import ipar from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_genomemap.py b/htsworkflow/pipelines/test/test_genomemap.py index aa2f618..7195d0f 100644 --- a/htsworkflow/pipelines/test/test_genomemap.py +++ b/htsworkflow/pipelines/test/test_genomemap.py @@ -7,7 +7,7 @@ import shutil import tempfile from unittest2 import TestCase -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines import genomemap MINI_GENOME_XML = ''' diff --git a/htsworkflow/pipelines/test/test_runfolder026.py b/htsworkflow/pipelines/test/test_runfolder026.py index 8eef130..970dbc2 100644 --- a/htsworkflow/pipelines/test/test_runfolder026.py +++ b/htsworkflow/pipelines/test/test_runfolder026.py @@ -10,7 +10,7 @@ from htsworkflow.pipelines import firecrest from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder030.py b/htsworkflow/pipelines/test/test_runfolder030.py index a571944..cb2bf95 100644 --- a/htsworkflow/pipelines/test/test_runfolder030.py +++ b/htsworkflow/pipelines/test/test_runfolder030.py @@ -10,7 +10,7 @@ from htsworkflow.pipelines import firecrest from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder110.py b/htsworkflow/pipelines/test/test_runfolder110.py index 2397c2a..c215f55 100644 --- a/htsworkflow/pipelines/test/test_runfolder110.py +++ b/htsworkflow/pipelines/test/test_runfolder110.py @@ -10,7 +10,7 @@ from htsworkflow.pipelines import firecrest from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder_casava_1_7.py b/htsworkflow/pipelines/test/test_runfolder_casava_1_7.py index c0b12b4..ae8899e 100644 --- a/htsworkflow/pipelines/test/test_runfolder_casava_1_7.py +++ b/htsworkflow/pipelines/test/test_runfolder_casava_1_7.py @@ -13,7 +13,7 @@ from htsworkflow.pipelines import gerald from htsworkflow.pipelines import ipar from htsworkflow.pipelines import runfolder from htsworkflow.pipelines import srf -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder_ipar100.py b/htsworkflow/pipelines/test/test_runfolder_ipar100.py index 1e95632..04e8026 100644 --- a/htsworkflow/pipelines/test/test_runfolder_ipar100.py +++ b/htsworkflow/pipelines/test/test_runfolder_ipar100.py @@ -10,7 +10,7 @@ from htsworkflow.pipelines import ipar from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder_ipar130.py b/htsworkflow/pipelines/test/test_runfolder_ipar130.py index 07c8778..617b917 100644 --- a/htsworkflow/pipelines/test/test_runfolder_ipar130.py +++ b/htsworkflow/pipelines/test/test_runfolder_ipar130.py @@ -11,7 +11,7 @@ from htsworkflow.pipelines import ipar from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder_pair.py b/htsworkflow/pipelines/test/test_runfolder_pair.py index b159c5f..3ed091d 100644 --- a/htsworkflow/pipelines/test/test_runfolder_pair.py +++ b/htsworkflow/pipelines/test/test_runfolder_pair.py @@ -11,7 +11,7 @@ from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines.eland import SampleKey from htsworkflow.pipelines import runfolder -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder_rta.py b/htsworkflow/pipelines/test/test_runfolder_rta.py index 2c82041..0503ea5 100644 --- a/htsworkflow/pipelines/test/test_runfolder_rta.py +++ b/htsworkflow/pipelines/test/test_runfolder_rta.py @@ -12,7 +12,7 @@ from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder from htsworkflow.pipelines.samplekey import SampleKey -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder_rta160.py b/htsworkflow/pipelines/test/test_runfolder_rta160.py index 9d4879a..25ab00f 100644 --- a/htsworkflow/pipelines/test/test_runfolder_rta160.py +++ b/htsworkflow/pipelines/test/test_runfolder_rta160.py @@ -12,7 +12,7 @@ from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder from htsworkflow.pipelines.samplekey import SampleKey -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder_rta180.py b/htsworkflow/pipelines/test/test_runfolder_rta180.py index be83c3f..a4039e7 100644 --- a/htsworkflow/pipelines/test/test_runfolder_rta180.py +++ b/htsworkflow/pipelines/test/test_runfolder_rta180.py @@ -12,7 +12,7 @@ from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder from htsworkflow.pipelines.samplekey import SampleKey -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * diff --git a/htsworkflow/pipelines/test/test_runfolder_rta1_12.py b/htsworkflow/pipelines/test/test_runfolder_rta1_12.py index 2a64b4f..b04dfe6 100644 --- a/htsworkflow/pipelines/test/test_runfolder_rta1_12.py +++ b/htsworkflow/pipelines/test/test_runfolder_rta1_12.py @@ -13,7 +13,7 @@ from htsworkflow.pipelines import ipar from htsworkflow.pipelines import bustard from htsworkflow.pipelines import gerald from htsworkflow.pipelines import runfolder -from htsworkflow.pipelines.runfolder import ElementTree +from htsworkflow.pipelines import ElementTree from htsworkflow.pipelines.test.simulate_runfolder import * -- 2.30.2