-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix: update-samplesheet execute test & fix for snappy-compatible #254
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
23dd84e
Fix SodarAPI implementation & add tests
Nicolai-vKuegelgen b2b3f36
empty commit
Nicolai-vKuegelgen 1e3873a
fix: update-samplesheet execute test & fix for snappy-compatible
Nicolai-vKuegelgen eff1e79
Merge branch 'main' into fix-sodar-api
Nicolai-vKuegelgen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -351,11 +351,11 @@ def test_collect_sample_data( | |
"123e4567-e89b-12d3-a456-426655440000", | ||
] | ||
|
||
def run_usc_collect_sampledata(arg_list): | ||
def run_usc_collect_sampledata(arg_list, **kwargs): | ||
USC = helper_update_UCS(arg_list, UCS_class_object) | ||
isa_names = USC.gather_ISA_column_names(mock_isa_data[1], mock_isa_data[2]) | ||
sampledata_fields = USC.parse_sampledata_args(isa_names) | ||
return USC.collect_sample_data(isa_names, sampledata_fields) | ||
return USC.collect_sample_data(isa_names, sampledata_fields, **kwargs) | ||
|
||
# test merging of --ped & -s info (same samples) | ||
pd.testing.assert_frame_equal(run_usc_collect_sampledata(arg_list), expected) | ||
|
@@ -450,6 +450,13 @@ def run_usc_collect_sampledata(arg_list): | |
] | ||
pd.testing.assert_frame_equal(run_usc_collect_sampledata(arg_list), expected) | ||
|
||
# Test --snappy-compatible | ||
arg_list2 = arg_list[:] | ||
for i in [3, 10, 12, 17]: | ||
arg_list2[i] = arg_list2[i].replace("_", "-") | ||
arg_list2 += ["--snappy-compatible"] | ||
pd.testing.assert_frame_equal(run_usc_collect_sampledata(arg_list, snappy_compatible=True), expected) | ||
|
||
# - --ped and -s (same samples) | ||
arg_list += ["-p", "mv_samples.ped"] | ||
pd.testing.assert_frame_equal(run_usc_collect_sampledata(arg_list), expected) | ||
|
@@ -489,7 +496,6 @@ def run_usc_collect_sampledata(arg_list): | |
"Sample with different values found in combined sample data:" | ||
in caplog.records[-1].message | ||
) | ||
|
||
# >> that one might only fail in ISA validation? | ||
|
||
|
||
|
@@ -615,5 +621,100 @@ def test_update_isa_table(UCS_class_object, caplog): | |
pd.testing.assert_frame_equal(actual, expected) | ||
|
||
|
||
# FIXME: smoke test for execute (MV & germline-sheet) | ||
# - test --snappy_compatible | ||
@patch("cubi_tk.sodar.update_samplesheet.SodarAPI.upload_ISA_samplesheet") | ||
@patch("cubi_tk.sodar.update_samplesheet.SodarAPI._api_call") | ||
def test_execute(mock_api_call, mock_upload_isa, MV_isa_json, sample_df): | ||
|
||
# restrict to 1 sample, match cols to ISA | ||
sample_df = sample_df.iloc[0:1, :] | ||
sample_df.columns = [ | ||
"Source Name", | ||
"Characteristics[Family]", | ||
"Characteristics[Father]", | ||
"Characteristics[Mother]", | ||
"Characteristics[Sex]", | ||
"Characteristics[Disease status]", | ||
"Characteristics[Individual-ID]", | ||
"Characteristics[Probe-ID]", | ||
"Parameter Value[Barcode sequence]", | ||
"Parameter Value[Barcode name]", | ||
"Sample Name", | ||
"Extract Name", | ||
"Library Name" | ||
] | ||
|
||
parser = argparse.ArgumentParser() | ||
UpdateSamplesheetCommand.setup_argparse(parser) | ||
|
||
mock_api_call.return_value = MV_isa_json | ||
mock_upload_isa.return_value = 0 | ||
|
||
# Build expected content of to-be-uploaded files | ||
expected_i = MV_isa_json["investigation"]["tsv"] | ||
study_tsv = MV_isa_json["studies"]["s_modellvorhaben_rare_diseases.txt"]['tsv'] | ||
assay_tsv = MV_isa_json["assays"]["a_modellvorhaben_rare_diseases_genome_sequencing.txt"]['tsv'] | ||
start_s = pd.read_csv(StringIO(study_tsv), sep="\t", dtype=str) | ||
start_a = pd.read_csv(StringIO(assay_tsv), sep="\t", dtype=str) | ||
|
||
expected_s = pd.concat( | ||
[start_s, sample_df.iloc[:, [0, 1, 2, 3, 4, 5, 10]]], | ||
ignore_index=True | ||
) | ||
expected_s['Protocol REF'] = 'Sample collection' | ||
expected_s = expected_s.to_csv(sep="\t", index=False, header=study_tsv.split("\n")[0].split("\t")) | ||
|
||
expected_a = pd.concat( | ||
[start_a, sample_df.iloc[:, [10, 11, 12]]], | ||
ignore_index=True | ||
) | ||
expected_a['Protocol REF'] = 'Nucleic acid extraction WGS' | ||
expected_a['Protocol REF.1'] = 'Library construction WGS' | ||
expected_a['Protocol REF.2'] = 'Nucleic acid sequencing WGS' | ||
expected_a = expected_a.to_csv(sep="\t", index=False, header=assay_tsv.split("\n")[0].split("\t")) | ||
|
||
# Test germlinesheet default | ||
args = parser.parse_args([ | ||
"--sodar-api-token", "1234", | ||
"--sodar-url", "https://sodar.bihealth.org/", | ||
"-s", "FAM_01", "Ana_01", "0", "0", "male", "affected", | ||
"--no-autofill", | ||
"123e4567-e89b-12d3-a456-426655440000" | ||
]) | ||
UpdateSamplesheetCommand(args).execute() | ||
mock_upload_isa.assert_called_with( | ||
('i_Investigation.txt', expected_i), | ||
("s_modellvorhaben_rare_diseases.txt", expected_s), | ||
("a_modellvorhaben_rare_diseases_genome_sequencing.txt", expected_a), | ||
Comment on lines
+686
to
+687
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above |
||
) | ||
|
||
# Test MV default | ||
expected_s = pd.concat( | ||
[start_s, sample_df.iloc[:, [0, 1, 2, 3, 4, 5, 6, 7, 10]]], | ||
ignore_index=True | ||
) | ||
expected_s['Protocol REF'] = 'Sample collection' | ||
expected_s = expected_s.to_csv(sep="\t", index=False, header=study_tsv.split("\n")[0].split("\t")) | ||
|
||
expected_a = pd.concat( | ||
[start_a, sample_df.iloc[:, [8, 9, 10, 11, 12]]], | ||
ignore_index=True | ||
) | ||
expected_a['Protocol REF'] = 'Nucleic acid extraction WGS' | ||
expected_a['Protocol REF.1'] = 'Library construction WGS' | ||
expected_a['Protocol REF.2'] = 'Nucleic acid sequencing WGS' | ||
expected_a = expected_a.to_csv(sep="\t", index=False, header=assay_tsv.split("\n")[0].split("\t")) | ||
|
||
args = parser.parse_args([ | ||
"--sodar-api-token", "1234", | ||
"--sodar-url", "https://sodar.bihealth.org/", | ||
"-d", "MV", | ||
"-s", "FAM_01", "Ana_01", "0", "0", "male", "affected", "Ind_01", "Probe_01", "ATCG", "A1", | ||
"--no-autofill", | ||
"123e4567-e89b-12d3-a456-426655440000" | ||
]) | ||
UpdateSamplesheetCommand(args).execute() | ||
mock_upload_isa.assert_called_with( | ||
('i_Investigation.txt', expected_i), | ||
("s_modellvorhaben_rare_diseases.txt", expected_s), | ||
("a_modellvorhaben_rare_diseases_genome_sequencing.txt", expected_a), | ||
Comment on lines
+718
to
+719
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above |
||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use placeholder/foobar names instead?