changeset 8:2e5223259a56 draft default tip

Uploaded
author dvanzessen
date Tue, 21 Apr 2020 11:38:36 +0000
parents 7d5b46d41ff0
children
files script.py
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/script.py	Tue Apr 21 11:38:25 2020 +0000
+++ b/script.py	Tue Apr 21 11:38:36 2020 +0000
@@ -39,7 +39,27 @@
     input_files = []
     phenotype_counter = Counter()
     for input_file in input_files_raw:
-        if input_file.find(":"):
+        if input_file.count(":") == 1:  # single end
+            forward_file, phenotype = input_file.split(":")
+            phenotype_counter.update(phenotype)
+            phenotype_count = phenotype_counter[phenotype]
+
+            forward_new_name = "{phenotype}_{phenotype_count}.fastq.gz".format(phenotype=phenotype, phenotype_count=phenotype_count)
+            forward_new_file_path = os.path.join(
+                workdir,
+                forward_new_name
+            )
+            os.symlink(forward_file, forward_new_file_path)
+
+            input_files.append(
+                {
+                    "forward": forward_new_file_path, 
+                    "description": "{phenotype}_{phenotype_index}".format(phenotype=phenotype, phenotype_index=phenotype_count),
+                    "phenotype": phenotype
+                }
+            )
+
+        elif input_file.count(":") == 2:  # paired end
             forward_file, reverse_file, phenotype = input_file.split(":")
             phenotype_counter.update(phenotype)
             phenotype_count = phenotype_counter[phenotype]
@@ -77,4 +97,4 @@
 
 
 if __name__ == "__main__":
-    main()
\ No newline at end of file
+    main()