Add module to convert multiple fastq files into a single file.
[htsworkflow.git] / htsworkflow / util / conversion.py
index 18cabef485aaedeafc7f0f1d16761c7c5937b6ea..d3eb4f6cc5dad43f619ca8db662ed6abbcc402a2 100644 (file)
@@ -14,7 +14,7 @@ def unicode_or_none(value):
 def parse_flowcell_id(flowcell_id):
     """
     Return flowcell id and any status encoded in the id
-  
+
     We stored the status information in the flowcell id name.
     this was dumb, but database schemas are hard to update.
     """
@@ -26,4 +26,19 @@ def parse_flowcell_id(flowcell_id):
     if len(fields) > 1:
         status = fields[1]
     return fcid, status
-    
+
+def parse_slice(slice_text):
+    if slice_text is None or len(slice_text) == 0:
+        return slice(None)
+
+    slice_data = []
+    for element in slice_text.split(':'):
+        if len(element) == 0:
+            element = None
+        else:
+            element = int(element)
+        slice_data.append(element)
+
+    return slice(*slice_data)
+
+