Skip to content

Commit 1dfb0a3

Browse files
authored
Merge pull request #15 from PennChopMicrobiomeProgram/codex/add-return-path-to-archive-directory
Return archive path from main
2 parents af21ab9 + f73d98b commit 1dfb0a3

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

seqBackupLib/backup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ def backup_fastq(
111111
with open(md5_out_fp, "w") as md5_out:
112112
[md5_out.write("\t".join(md5) + "\n") for md5 in md5s]
113113

114+
return write_dir
115+
114116

115117
def main(argv=None):
116118
parser = argparse.ArgumentParser(description="Backs up fastq files")
@@ -143,8 +145,7 @@ def main(argv=None):
143145
help="Minimum file size to register in bytes",
144146
)
145147
args = parser.parse_args(argv)
146-
147-
backup_fastq(
148+
return backup_fastq(
148149
args.forward_reads,
149150
args.destination_dir,
150151
args.sample_sheet,

test/test_backup.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import pytest
22
from pathlib import Path
3-
from seqBackupLib.backup import backup_fastq, build_fp_to_archive, return_md5
3+
from seqBackupLib.backup import (
4+
backup_fastq,
5+
build_fp_to_archive,
6+
return_md5,
7+
main,
8+
)
49

510

611
def test_build_fp_to_archive():
@@ -104,3 +109,26 @@ def test_backup_fastq_without_lane(tmp_path, full_miseq_dir):
104109
out_dir = raw / "250407_M03543_0443_000000000-DTHBL_L001"
105110
assert (out_dir / "Undetermined_S0_L001_R1_001.fastq.gz").is_file()
106111
assert (out_dir / "Undetermined_S0_L001_R2_001.fastq.gz").is_file()
112+
113+
114+
def test_main_returns_archive_path(tmp_path, full_miseq_dir):
115+
raw = tmp_path / "raw_reads"
116+
raw.mkdir(parents=True, exist_ok=True)
117+
sample_sheet_fp = full_miseq_dir / "sample_sheet.csv"
118+
119+
out_dir = main(
120+
[
121+
"--forward-reads",
122+
str(full_miseq_dir / "Undetermined_S0_L001_R1_001.fastq.gz"),
123+
"--destination-dir",
124+
str(raw),
125+
"--sample-sheet",
126+
str(sample_sheet_fp),
127+
"--min-file-size",
128+
"100",
129+
]
130+
)
131+
132+
expected_dir = raw / "250407_M03543_0443_000000000-DTHBL_L001"
133+
assert out_dir == expected_dir
134+
assert expected_dir.is_dir()

0 commit comments

Comments
 (0)