Skip to content

Commit db7db56

Browse files
authored
Merge pull request #1184 from fls-bioinformatics-core/qc-pipeline-update-organism-name-normalisation
Update organism name normalisation function and apply more consistently
2 parents dda19c1 + 9d8b981 commit db7db56

3 files changed

Lines changed: 6 additions & 16 deletions

File tree

auto_process_ngs/qc/pipeline.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@
3636
import tempfile
3737
import shutil
3838
import random
39-
from bcftbx.JobRunner import SimpleJobRunner
4039
from bcftbx.FASTQFile import FastqIterator
41-
from bcftbx.TabFile import TabFile
4240
from bcftbx.utils import mkdir
43-
from bcftbx.utils import mkdirs
44-
from bcftbx.utils import find_program
4541
from bcftbx.ngsutils import getreads
4642
from bcftbx.ngsutils import getreads_subset
4743
from ..analysis import AnalysisFastq
@@ -57,10 +53,8 @@
5753
from ..pipeliner import PipelineParam as Param
5854
from ..pipeliner import ListParam
5955
from ..pipeliner import PipelineFailure
60-
from ..tenx.cellplex import CellrangerMultiConfigCsv
6156
from ..tenx.multiome import MultiomeLibraries
62-
from ..tenx.utils import add_cellranger_args
63-
from ..utils import get_organism_list
57+
from ..utils import normalise_organism_name
6458
from .modules.cellranger_atac_count import CellrangerAtacCount
6559
from .modules.cellranger_arc_count import CellrangerArcCount
6660
from .modules.cellranger_count import CellrangerCount
@@ -74,8 +68,6 @@
7468
from .modules.rseqc_infer_experiment import RseqcInferExperiment
7569
from .modules.sequence_lengths import SequenceLengths
7670
from .modules.strandedness import Strandedness
77-
from .protocols import determine_qc_protocol
78-
from .protocols import fetch_protocol_definition
7971
from .protocols import parse_qc_module_spec
8072
from .reporting import report as reportqc
8173
from .utils import get_bam_basename
@@ -286,10 +278,7 @@ def add_project(self,project,protocol,qc_dir=None,organism=None,
286278
organism = project.info.organism
287279

288280
# Sanitised organism name
289-
organism_name = str(organism).\
290-
strip().\
291-
lower().\
292-
replace(' ','_')
281+
organism_name = normalise_organism_name(organism)
293282

294283
# Report details
295284
self.report("-- Protocol : %s" % protocol.name)

auto_process_ngs/test/test_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ def test_normalise_organism_name(self):
13861386
"mus_musculus")
13871387
self.assertEqual(normalise_organism_name(" Mus musculus "),
13881388
"mus_musculus")
1389+
self.assertEqual(normalise_organism_name("C. elegans"), "c_elegans")
13891390

13901391
class TestSplitUserHostDir(unittest.TestCase):
13911392
"""Tests for the split_user_host_dir function

auto_process_ngs/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,9 +1100,9 @@ def normalise_organism_name(name):
11001100
String: normalised organism name
11011101
"""
11021102
# Make lowercase, split on commas and replace whitespace
1103-
# with single underscore, then strip leading/trailing
1104-
# underscores
1105-
return re.sub(r'\s+','_',str(name).lower()).strip('_')
1103+
# and other non-alphanumeric characters with single underscore,
1104+
# finally strip leading/trailing underscores
1105+
return re.sub(r'\W+','_',str(name).lower()).strip('_')
11061106

11071107
def split_user_host_dir(location):
11081108
# Split a location of the form [[user@]host:]dir into its

0 commit comments

Comments
 (0)