Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix variable #39

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions rsync_to_rdisc.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def rsync_server_remote(hpc_server, client, to_be_transferred, mount_path, run_f
for run in to_be_transferred:
with open(settings.log_path, 'a', newline='\n') as log_file:
log_file_writer = writer(log_file, delimiter='\t')
log_file_writer.writerows([["#########"], [f"Date: {date}", f"Run_folder: {run}"]])
log_file_writer.writerows([["#########"], [f"Date: {date}"], [f"Run_folder: {run}"]])

transfer_settings = to_be_transferred[run]
# settings per folder data type, such as remote input dir and local output dir, etc.
Expand Down Expand Up @@ -272,9 +272,9 @@ def rsync_server_remote(hpc_server, client, to_be_transferred, mount_path, run_f
upload_result_exomedepth=upload_result_exomedepth
)
# Do not include run in transferred_runs.txt if temp error file is not empty.
with open(f"{settings.wkdir}/transferred_runs.txt", 'a', newline='\n') as log_file:
log_file_writer = writer(log_file, delimiter='\t')
log_file_writer.writerow([f"{run}_{transfer_settings['name']}", email_state])
with open(f"{settings.wkdir}/transferred_runs.txt", 'a', newline='\n') as transferred_file:
file_writer = writer(transferred_file, delimiter='\t')
file_writer.writerow([f"{run}_{transfer_settings['name']}", email_state])

return rsync_succes

Expand Down
16 changes: 11 additions & 5 deletions test_rsync_to_rdisc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def set_up_test(tmp_path_factory):
run = "230920_A01131_0356_AHKM7VDRX3"
analysis = f"{run}_1" # run ok + exomedepth
analysis_transfer_settings = rsync_to_rdisc.settings.transfer_settings['bgarray']['transfers'][0]
Path(f"{rsync_to_rdisc.settings.wkdir}/transferred_runs.txt").write_text(analysis) # Other analysis will be added as part of the tests.

# Other analysis will be added as part of the tests.
Path(f"{rsync_to_rdisc.settings.wkdir}/transferred_runs.txt").write_text(analysis)

# Processed folder
for project in range(1, 6):
Expand Down Expand Up @@ -327,7 +327,9 @@ def test_rsync_ok(self, set_up_test, mocker, mock_send_mail_transfer_state):
mock_check_rsync.assert_called_once()
mock_send_mail_transfer_state.assert_called_once()
mock_send_mail_transfer_state.reset_mock()
assert f"{set_up_test['run']}_3_TRANSFER\tok" in Path(f"{rsync_to_rdisc.settings.wkdir}/transferred_runs.txt").read_text()
assert (
f"{set_up_test['run']}_3_TRANSFER\tok" in Path(f"{rsync_to_rdisc.settings.wkdir}/transferred_runs.txt").read_text()
)

def test_rsync_error(self, set_up_test, mocker, mock_send_mail_transfer_state):
mocker.patch("rsync_to_rdisc.check_if_file_missing", return_value=[])
Expand All @@ -338,7 +340,9 @@ def test_rsync_error(self, set_up_test, mocker, mock_send_mail_transfer_state):
{f"{set_up_test['run']}_3": rsync_to_rdisc.settings.transfer_settings['bgarray']['transfers'][0]},
set_up_test['tmp_path'], f"{rsync_to_rdisc.settings.wkdir}/transferred_runs.txt",
)
assert f"{set_up_test['run']}_3_Exomes" not in Path(f"{rsync_to_rdisc.settings.wkdir}/transferred_runs.txt").read_text()
assert (
f"{set_up_test['run']}_3_Exomes" not in Path(f"{rsync_to_rdisc.settings.wkdir}/transferred_runs.txt").read_text()
)

# parametrize GATK / ExomeDepth error and no errors.
@pytest.mark.parametrize("project,gatk_succes,ed_succes,state", [
Expand All @@ -351,7 +355,9 @@ def test_rsync_error(self, set_up_test, mocker, mock_send_mail_transfer_state):
("5", "warning", "error", "vcf_upload_error"),
("6", "error", "warning", "vcf_upload_error"),
])
def test_vcf_upload_error(self, project, gatk_succes, ed_succes, state, set_up_test, mocker, mock_send_mail_transfer_state):
def test_vcf_upload_error(
self, project, gatk_succes, ed_succes, state, set_up_test, mocker, mock_send_mail_transfer_state
):
analysis = f"{set_up_test['run']}_{project}"
mocker.patch("rsync_to_rdisc.check_if_file_missing", return_value=[])
mocker.patch("rsync_to_rdisc.os.system")
Expand Down
Loading