Repository: AroneyS/binchicken (language: python)

Issue:
Fix split sra downloads



Discussion / hints:

Fix patch:
diff --git a/ibis/ibis.py b/ibis/ibis.py
index cb84ceae..7e5bbf5b 100755
--- a/ibis/ibis.py
+++ b/ibis/ibis.py
@@ -270,7 +270,7 @@ def download_sra(args):
     # Using Jan 1 2000 as pre-date
     sra_dir = args.output + "/coassemble/sra/"
     os.makedirs(sra_dir, exist_ok=True)
-    for sra in [f + s for f in args.forward for s in ["_1", "_2"]]:
+    for sra in [f + s for f in args.forward for s in ["_1", "_2"] if f not in single_ended]:
         subprocess.check_call(f"touch -t 200001011200 {sra_dir + sra + SRA_SUFFIX}", shell=True)
 
     forward = sorted([sra_dir + f for f in os.listdir(sra_dir) if f.endswith("_1" + SRA_SUFFIX)])
diff --git a/ibis/workflow/coassemble.smk b/ibis/workflow/coassemble.smk
index 94137f5b..95217a4b 100644
--- a/ibis/workflow/coassemble.smk
+++ b/ibis/workflow/coassemble.smk
@@ -366,8 +366,7 @@ checkpoint cluster_graph:
 #######################
 rule download_read:
     output:
-        read_1 = output_dir + "/sra/{read}_1.fastq.gz",
-        read_2 = output_dir + "/sra/{read}_2.fastq.gz",
+        done = output_dir + "/sra/{read}.done",
     params:
         dir = output_dir + "/sra",
         name = "{read}",
@@ -388,13 +387,13 @@ rule download_read:
         "-m ena-ftp prefetch ena-ascp aws-http aws-cp "
         "-t {threads} "
         "&> {log} "
+        "&& touch {output.done}"
 
 rule download_sra:
     input:
-        expand(output_dir + "/sra/{read}_1.fastq.gz", read=config["sra"]) if config["sra"] else [],
-        expand(output_dir + "/sra/{read}_2.fastq.gz", read=config["sra"]) if config["sra"] else [],
+        expand(output_dir + "/sra/{read}.done", read=config["sra"]) if config["sra"] else [],
     output:
-        output_dir + "/sra/done"
+        output_dir + "/sra/all_done"
     shell:
         "touch {output}"
 


Test patch:
diff --git a/test/test_manual.py b/test/test_manual.py
index c6fa3f81..625b677b 100644
--- a/test/test_manual.py
+++ b/test/test_manual.py
@@ -48,7 +48,7 @@ def test_update_sra_download_real(self):
         cmd = (
             f"ibis update "
             f"--assemble-unmapped "
-            f"--forward SRR8334323 SRR8334324 "
+            f"--forward SRR8334323 SRR8334324 SRR7039260 "
             f"--sra "
             f"--genomes {GENOMES} "
             f"--coassemble-unbinned {os.path.join(MOCK_COASSEMBLE, 'appraise', 'unbinned_sra.otu_table.tsv')} "