Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 8625dd6

Browse files
All tests are working
1 parent a032b68 commit 8625dd6

File tree

3 files changed

+36
-11
lines changed

3 files changed

+36
-11
lines changed

sequence_processing_pipeline/GenPrepFileJob.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from sequence_processing_pipeline.Job import Job
22
from sequence_processing_pipeline.PipelineError import PipelineError
33
from os import makedirs, symlink
4-
from os.path import join, exists, basename
5-
from shutil import copy
4+
from os.path import isdir, join, exists, basename
5+
from shutil import copy, copytree
66
from functools import partial
77
from collections import defaultdict
88
from metapool import (demux_sample_sheet, parse_prep,
@@ -54,8 +54,32 @@ def __init__(self, run_dir, convert_job_path, qc_job_path, output_path,
5454
else:
5555
self.is_restart = False
5656

57-
makedirs(reports_dir)
58-
copy(self.reports_path, reports_dir)
57+
"""
58+
With copytree(src, dst), src must be an existing directory and dst
59+
must be a path that doesn't already exist.
60+
src cannot be a file. it must be a directory.
61+
62+
when using copytree to copy a directory, dst must be the path to
63+
the directory where you want the copy PLUS the name of the copied
64+
directory. To give dst the same directory name as src you would
65+
then need to split() the folder name off the end of src and append
66+
it to dst to get a proper value. copytree() DOES NOT put a copy
67+
of src in dst. More like it copies the entire contents of src
68+
recursively into dst, however dst cannot already exist so you
69+
can't use it to copy the contents of a directory into an existing
70+
directory.
71+
72+
This means that if src is a file and not a directory, you will
73+
need to use copy() to copy the file instead. It also means that
74+
you will need to make reports_dir manually.
75+
"""
76+
77+
if isdir(self.reports_path):
78+
copytree(self.reports_path, reports_dir)
79+
else:
80+
# assume self.reports_path is a file.
81+
makedirs(reports_dir)
82+
copy(self.reports_path, reports_dir)
5983

6084
# extracting from either convert_job_path or qc_job_path should
6185
# produce equal results.

sequence_processing_pipeline/NuQCJob.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __init__(self, fastq_root_dir, output_path, sample_sheet_path,
118118

119119
self._validate_project_data()
120120

121-
def hack_helper(self):
121+
def contains_bx_metadata(self):
122122
# get list of raw compressed fastq files. only consider R1 and R2
123123
# reads.
124124

@@ -458,7 +458,7 @@ def _generate_mmi_filter_cmds(self, working_dir):
458458
# read the first line of the compressed fastq file and see if it
459459
# contains optional BX metadata. If not it will return False, other
460460
# wise True.
461-
apply_bx = self.hack_helper()
461+
apply_bx = self.contains_bx_metadata()
462462

463463
# the default setting.
464464
tags = ""

sequence_processing_pipeline/tests/test_NuQCJob.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from os import makedirs, remove
1111
from metapool import load_sample_sheet
1212
from os import walk
13+
import gzip
1314

1415

1516
class TestNuQCJob(unittest.TestCase):
@@ -73,10 +74,11 @@ def setUp(self):
7374
for id in ids:
7475
fr_fp = join(sample_path, f"{id}_R1_001.fastq.gz")
7576
rr_fp = join(sample_path, f"{id}_R2_001.fastq.gz")
76-
with open(fr_fp, "w") as f:
77-
f.write("This is a forward-read file.")
78-
with open(rr_fp, "w") as f:
79-
f.write("This is a reverse-read file.")
77+
78+
with gzip.open(fr_fp, "wb") as f:
79+
f.write(b"@my_seq_id BX:1:1101:10000:10000\n")
80+
with gzip.open(rr_fp, "wb") as f:
81+
f.write(b"@my_seq_id BX:1:1101:10000:10000\n")
8082

8183
self.feist_ids = [
8284
"JM-MEC__Staphylococcus_aureusstrain_BERTI-R08624",
@@ -868,7 +870,6 @@ def tearDown(self):
868870
if exists(self.tmp_file_path):
869871
remove(self.tmp_file_path)
870872

871-
# for test_move_trimmed_files()
872873
if exists(self.path("NuQCJob")):
873874
shutil.rmtree(self.path("NuQCJob"))
874875

0 commit comments

Comments
 (0)