Skip to content

Commit a76df3d

Browse files
committed
utils: update 'normalise_organism_name'.
Update the 'normalise_organism_name' to convert all non-alphanumeric characters to underscores.
1 parent dda19c1 commit a76df3d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

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)