Skip to content

Commit

Permalink
Merge branch 'aviti' of https://github.com/ssjunnebo/TACA into aviti
Browse files Browse the repository at this point in the history
  • Loading branch information
ssjunnebo committed Sep 26, 2024
2 parents 48ec343 + 41dd477 commit 4939939
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
4 changes: 2 additions & 2 deletions taca/element/Element_Runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def make_demux_manifests(

def generate_demux_command(self, run_manifest, demux_dir):
command = (
f"{self.CONFIG.get("element_analysis").get('bases2fastq')}" # TODO: add path to bases2fastq executable to config
f"{self.CONFIG.get('element_analysis').get('bases2fastq')}" # TODO: add path to bases2fastq executable to config
+ f" {self.run_dir}"
+ f" {demux_dir}"
+ " -p 8"
Expand Down Expand Up @@ -790,7 +790,7 @@ def transfer(self):
+ " --exclude Alignment"
+ f" {self.run_dir}"
+ f" {transfer_details.get('user')}@{transfer_details.get('host')}:/aviti"
+ f"; echo $? > {os.path.join(self.run_dir, ".rsync_exit_status")}"
+ f"; echo $? > {os.path.join(self.run_dir, '.rsync_exit_status')}"
) # TODO: any other options?
try:
p_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/element/test_Aviti_Runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from taca.element import Aviti_Runs as to_test
from tests.element.test_Element_Runs import create_element_run_dir
from tests.element.test_Element_Runs import CONFIG, create_element_run_dir


class TestAviti_Run:
Expand All @@ -16,6 +16,6 @@ def test_init(self, create_dirs: pytest.fixture):
mock_db = patch("taca.element.Element_Runs.ElementRunsConnection")
mock_db.start()

run = to_test.Aviti_Run(run_dir, {})
run = to_test.Aviti_Run(run_dir, CONFIG)
assert run.run_dir == run_dir
assert run.sequencer_type == "Aviti"
47 changes: 35 additions & 12 deletions tests/element/test_Element_Runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@

from taca.element import Element_Runs as to_test

CONFIG = {
"element_analysis": {
"Element": {
"GenericElement": {
"demux_dir": "mock_demux_dir_path",
"transfer_log": "mock_transfer_log_file.log",
},
},
},
}


def create_element_run_dir(
tmp: tempfile.TemporaryDirectory,
Expand All @@ -15,6 +26,7 @@ def create_element_run_dir(
run_finished: bool = True,
sync_finished: bool = True,
demux_dir: bool = True,
n_demux_subdirs: int = 1,
demux_done: bool = True,
outcome_completed: bool = True,
) -> str:
Expand All @@ -27,8 +39,12 @@ def create_element_run_dir(
├── RunParameters.json
├── RunUploaded.json
├── .sync_finished
└── Demultiplexing
└── RunStats.json
├── Demultiplexing
├── Demultiplexing_0
| └── RunStats.json
├── Demultiplexing_1
| └── RunStats.json
└── ...
"""

Expand All @@ -53,9 +69,18 @@ def create_element_run_dir(

if demux_dir:
os.mkdir(os.path.join(run_path, "Demultiplexing"))

if demux_done:
open(os.path.join(run_path, "Demultiplexing", "RunStats.json"), "w").close()
for i in range(n_demux_subdirs):
os.mkdir(os.path.join(run_path, "Demultiplexing", f"Demultiplexing_{i}"))
if demux_done:
open(
os.path.join(
run_path,
"Demultiplexing",
f"Demultiplexing_{i}",
"RunStats.json",
),
"w",
).close()

return run_path

Expand All @@ -66,7 +91,7 @@ def test_init(self, mock_db: mock.Mock, create_dirs: pytest.fixture):
tmp: tempfile.TemporaryDirectory = create_dirs
run_dir = create_element_run_dir(tmp)

run = to_test.Run(run_dir, {})
run = to_test.Run(run_dir, CONFIG)
assert run.run_dir == run_dir

@pytest.mark.parametrize(
Expand All @@ -92,7 +117,7 @@ def test_check_sequencing_status(
run_finished=p["run_finished"],
outcome_completed=p["outcome_completed"],
),
{},
CONFIG,
)
assert run.check_sequencing_status() is p["expected"]

Expand All @@ -110,15 +135,13 @@ def test_get_demultiplexing_status(
):
tmp: tempfile.TemporaryDirectory = create_dirs

if p["demux_dir"] and not p["demux_done"]:

run = to_test.Run(
create_element_run_dir(
tmp,
demux_dir=p["demux_dir"],
demux_done=p["demux_done"],
),
{},
CONFIG,
)
assert run.get_demultiplexing_status() == p["expected"]

Expand All @@ -140,7 +163,7 @@ def test_manifest_exists(
tmp,
run_finished=p["run_finished"],
),
{},
CONFIG,
)
assert run.manifest_exists() == p["expected"]

Expand All @@ -155,7 +178,7 @@ def test_start_demux(self, mock_db, create_dirs):
"taca.element.Element_Runs.Run.generate_demux_command"
) as mock_command:
mock_command.return_value = "test command"
run = to_test.Run(create_element_run_dir(create_dirs), {})
run = to_test.Run(create_element_run_dir(create_dirs), CONFIG)
run.start_demux()
mock_command.assert_called_once()
mock_call.assert_called_once_with(
Expand Down

0 comments on commit 4939939

Please sign in to comment.