most of our test submission rule files use bz2 regexes, so lets make those files
[htsworkflow.git] / htsworkflow / submission / test / submission_test_common.py
index 1770b87f9b1737675c50f7c03c1c0fb38d7913ff..e1e5eb0a80866faadcbb022e8b9ab1222776bc83 100644 (file)
@@ -1,21 +1,31 @@
 """Code shared between test cases.
 """
 import RDF
+import logging
 import os
 import tempfile
 import htsworkflow.util.rdfhelp
 
 S1_NAME = '1000-sample'
 S2_NAME = '2000-sample'
+SCOMBINED_NAME = 'directory'
 
 S1_FILES = [
-    os.path.join(S1_NAME, 'file1_l8_r1.fastq'),
-    os.path.join(S1_NAME, 'file1_l8_r2.fastq'),
+    os.path.join(S1_NAME, 'file1_l8_r1.fastq.bz2'),
+    os.path.join(S1_NAME, 'file1_l8_r2.fastq.bz2'),
 ]
 
 S2_FILES = [
     os.path.join(S2_NAME, 'file1.bam'),
-    os.path.join(S2_NAME, 'file1_l5.fastq'),
+    os.path.join(S2_NAME, 'file1_l5.fastq.bz2'),
+]
+
+SCOMBINED_FILES = [
+    os.path.join(SCOMBINED_NAME, 's1_file1.bam'),
+    os.path.join(SCOMBINED_NAME, 's1_l5.fastq.bz2'),
+    os.path.join(SCOMBINED_NAME, 's2_file1.bam'),
+    os.path.join(SCOMBINED_NAME, 's2_l4.read1.fastq.bz2'),
+    os.path.join(SCOMBINED_NAME, 's2_l4.read2.fastq.bz2'),
 ]
 
 TURTLE_PREFIX = htsworkflow.util.rdfhelp.get_turtle_header()
@@ -39,7 +49,7 @@ S2_TURTLE = TURTLE_PREFIX + """
 <http://localhost/library/2000/>
   htswlib:cell_line "Cell2000" ;
   htswlib:library_id "2000" ;
-  htswlib:library_type "Paired" ;
+  htswlib:library_type "Paired End (non-multiplexed)" ;
   htswlib:replicate "2" ;
   htswlib:has_lane <http://localhost/lane/2> ;
   a htswlib:Library .
@@ -68,3 +78,26 @@ class MockAddDetails(object):
             break
         assert found
 
+def generate_sample_results_tree(obj, prefix):
+    obj.tempdir = tempfile.mkdtemp(prefix=prefix)
+    obj.sourcedir = os.path.join(obj.tempdir, 'source')
+    os.mkdir(obj.sourcedir)
+    obj.resultdir = os.path.join(obj.tempdir, 'results')
+    os.mkdir(obj.resultdir)
+
+    for d in [os.path.join(obj.sourcedir, S1_NAME),
+              os.path.join(obj.sourcedir, S2_NAME),
+              ]:
+        logging.debug("Creating: %s", d)
+        os.mkdir(d)
+
+    tomake = []
+    tomake.extend(S1_FILES)
+    tomake.extend(S2_FILES)
+    for f in tomake:
+        target = os.path.join(obj.sourcedir, f)
+        logging.debug("Creating: %s", target)
+        stream = open(target, 'w')
+        stream.write(f)
+        stream.close()
+