From 2a098fe395438f29be127c8827653250a03bf740 Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 22 Oct 2024 15:00:17 -0400 Subject: [PATCH 1/5] separate request for RNA only samples --- seqr/views/apis/report_api_tests.py | 43 ++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/seqr/views/apis/report_api_tests.py b/seqr/views/apis/report_api_tests.py index 767af58fe3..9f25daf765 100644 --- a/seqr/views/apis/report_api_tests.py +++ b/seqr/views/apis/report_api_tests.py @@ -66,16 +66,6 @@ 'Recontactable': 'Yes', }, }, - { - "id": "rec2B67GmXpAkQW8z", - "fields": { - 'SeqrCollaboratorSampleID': 'NA19679', - 'CollaboratorSampleID': 'NA19679', - 'CollaboratorParticipantID': 'NA19679', - 'SMID': 'SM-N1P91', - 'Recontactable': 'Yes', - }, - }, { "id": "rec2Nkg10N1KssPc3", "fields": { @@ -97,6 +87,20 @@ }, ]} +AIRTABLE_RNA_ONLY_GREGOR_SAMPLE_RECORDS = { + "records": [ + { + "id": "rec2B67GmXpAkQW8z", + "fields": { + 'SeqrCollaboratorSampleID': 'NA19679', + 'CollaboratorSampleID': 'NA19679', + 'CollaboratorParticipantID': 'NA19679', + 'SMID': 'SM-N1P91', + 'Recontactable': 'Yes', + }, + }, +]} + AIRTABLE_GREGOR_RECORDS = { "records": [ { @@ -793,12 +797,25 @@ def _test_gregor_export(self, url, mock_subprocess, mock_temp_dir, mock_open, mo mock_temp_dir.return_value.__enter__.return_value = '/mock/tmp' mock_subprocess.return_value.wait.return_value = 1 + airtable_sample_url = f'{AIRTABLE_URL}/app3Y97xtbbaOopVR/Samples' responses.add( - responses.GET, '{}/app3Y97xtbbaOopVR/Samples'.format(AIRTABLE_URL), json=AIRTABLE_GREGOR_SAMPLE_RECORDS, - status=200) + responses.GET, airtable_sample_url, json=AIRTABLE_GREGOR_SAMPLE_RECORDS, status=200, match=[ + responses.matchers.query_param_matcher({'fields[]': ['CollaboratorSampleID', 'CollaboratorParticipantID', 'Recontactable', 'SMID']}, strict_match=False), + ] + ) + responses.add( + responses.GET, airtable_sample_url, json=AIRTABLE_GREGOR_SAMPLE_RECORDS, status=200, match=[ + responses.matchers.query_param_matcher({'fields[]': ['SeqrCollaboratorSampleID', 'CollaboratorParticipantID', 'Recontactable', 'SMID']}, strict_match=False), + ] + ) + responses.add( + responses.GET, airtable_sample_url, json=AIRTABLE_RNA_ONLY_GREGOR_SAMPLE_RECORDS, status=200, + match=[responses.matchers.query_param_matcher({'fields[]': 'SMID'}, strict_match=False)] + ) responses.add( responses.GET, '{}/app3Y97xtbbaOopVR/GREGoR Data Model'.format(AIRTABLE_URL), json=AIRTABLE_GREGOR_RECORDS, status=200) + responses.add(responses.GET, MOCK_DATA_MODEL_URL, status=404) response = self.client.post(url, content_type='application/json', data=json.dumps({})) @@ -827,7 +844,7 @@ def _test_gregor_export(self, url, mock_subprocess, mock_temp_dir, mock_open, mo self.assertEqual(response.status_code, 400) recommended_warnings = [ - 'The following entries are missing recommended "recontactable" in the "participant" table: Broad_HG00731, Broad_HG00732, Broad_HG00733, Broad_NA19678, Broad_NA20870, Broad_NA20872, Broad_NA20874, Broad_NA20875, Broad_NA20876, Broad_NA20881', + 'The following entries are missing recommended "recontactable" in the "participant" table: Broad_HG00731, Broad_HG00732, Broad_HG00733, Broad_NA19678, Broad_NA19679, Broad_NA20870, Broad_NA20872, Broad_NA20874, Broad_NA20875, Broad_NA20876, Broad_NA20881', 'The following entries are missing recommended "reported_race" in the "participant" table: Broad_HG00733, Broad_NA19678, Broad_NA19679, Broad_NA20870, Broad_NA20872, Broad_NA20874, Broad_NA20875, Broad_NA20876, Broad_NA20881, Broad_NA20888', 'The following entries are missing recommended "phenotype_description" in the "participant" table: Broad_NA20870, Broad_NA20872, Broad_NA20874, Broad_NA20875, Broad_NA20876, Broad_NA20881, Broad_NA20888', 'The following entries are missing recommended "age_at_enrollment" in the "participant" table: Broad_HG00731, Broad_NA20870, Broad_NA20872, Broad_NA20875, Broad_NA20876, Broad_NA20881, Broad_NA20888', From 760bc875fda42cb7d66107213a755a2740b067ca Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 29 Oct 2024 15:30:47 -0400 Subject: [PATCH 2/5] update fixture --- seqr/views/apis/report_api_tests.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/seqr/views/apis/report_api_tests.py b/seqr/views/apis/report_api_tests.py index 6034d57f54..97deef376b 100644 --- a/seqr/views/apis/report_api_tests.py +++ b/seqr/views/apis/report_api_tests.py @@ -92,11 +92,8 @@ { "id": "rec2B67GmXpAkQW8z", "fields": { - 'SeqrCollaboratorSampleID': 'NA19679', - 'CollaboratorSampleID': 'NA19679', - 'CollaboratorParticipantID': 'NA19679', + # 'CollaboratorSampleID': 'NA19679', 'SMID': 'SM-N1P91', - 'Recontactable': 'Yes', }, }, ]} @@ -143,7 +140,6 @@ "id": "rec4B7OGmQpVkQW7z", "fields": { 'CollaboratorParticipantID': 'NA19679', - 'CollaboratorSampleID_rna': 'NA19679', 'SMID_rna': ['rec2B67GmXpAkQW8z'], 'seq_library_prep_kit_method_rna': 'Unknown', 'library_prep_type_rna': 'stranded poly-A pulldown', @@ -869,7 +865,7 @@ def _test_gregor_export(self, url, mock_subprocess, mock_temp_dir, mock_open, mo 'The following entries are missing required "mean_coverage" (from Airtable) in the "aligned_dna_short_read" table: Broad_exome_VCGS_FAM203_621_D2_1', 'The following entries have non-unique values for "alignment_software" (from Airtable) in the "aligned_dna_short_read" table: BWA-MEM-2.3 (Broad_exome_NA20888_1, Broad_exome_VCGS_FAM203_621_D2_1)', 'The following entries have invalid values for "analysis_details" (from Airtable) in the "aligned_dna_short_read" table. Allowed values are a google bucket path starting with gs://. Invalid values: Broad_exome_VCGS_FAM203_621_D2_1 (DOI:10.5281/zenodo.4469317)', - 'The following entries have invalid values for "date_data_generation" (from Airtable) in the "experiment_rna_short_read" table. Allowed values have data type float. Invalid values: NA19679 (2023-02-11)', + # 'The following entries have invalid values for "date_data_generation" (from Airtable) in the "experiment_rna_short_read" table. Allowed values have data type float. Invalid values: NA19679 (2023-02-11)', 'The following entries are missing required "experiment_id" (from Airtable) in the "genetic_findings" table: Broad_NA19675_1_21_3343353', 'The following entries have non-unique values for "experiment_id" (from Airtable) in the "genetic_findings" table: Broad_exome_VCGS_FAM203_621_D2 (Broad_HG00731_19_1912632, Broad_HG00731_1_248367227)', ] From e4905e60e889668963527df687ce3d6888d84bc3 Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 29 Oct 2024 15:38:47 -0400 Subject: [PATCH 3/5] clean up --- seqr/views/apis/report_api_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seqr/views/apis/report_api_tests.py b/seqr/views/apis/report_api_tests.py index 97deef376b..e4f8e41a60 100644 --- a/seqr/views/apis/report_api_tests.py +++ b/seqr/views/apis/report_api_tests.py @@ -92,7 +92,6 @@ { "id": "rec2B67GmXpAkQW8z", "fields": { - # 'CollaboratorSampleID': 'NA19679', 'SMID': 'SM-N1P91', }, }, @@ -140,6 +139,7 @@ "id": "rec4B7OGmQpVkQW7z", "fields": { 'CollaboratorParticipantID': 'NA19679', + 'CollaboratorSampleID_rna': 'NA19679', 'SMID_rna': ['rec2B67GmXpAkQW8z'], 'seq_library_prep_kit_method_rna': 'Unknown', 'library_prep_type_rna': 'stranded poly-A pulldown', @@ -865,7 +865,7 @@ def _test_gregor_export(self, url, mock_subprocess, mock_temp_dir, mock_open, mo 'The following entries are missing required "mean_coverage" (from Airtable) in the "aligned_dna_short_read" table: Broad_exome_VCGS_FAM203_621_D2_1', 'The following entries have non-unique values for "alignment_software" (from Airtable) in the "aligned_dna_short_read" table: BWA-MEM-2.3 (Broad_exome_NA20888_1, Broad_exome_VCGS_FAM203_621_D2_1)', 'The following entries have invalid values for "analysis_details" (from Airtable) in the "aligned_dna_short_read" table. Allowed values are a google bucket path starting with gs://. Invalid values: Broad_exome_VCGS_FAM203_621_D2_1 (DOI:10.5281/zenodo.4469317)', - # 'The following entries have invalid values for "date_data_generation" (from Airtable) in the "experiment_rna_short_read" table. Allowed values have data type float. Invalid values: NA19679 (2023-02-11)', + 'The following entries have invalid values for "date_data_generation" (from Airtable) in the "experiment_rna_short_read" table. Allowed values have data type float. Invalid values: NA19679 (2023-02-11)', 'The following entries are missing required "experiment_id" (from Airtable) in the "genetic_findings" table: Broad_NA19675_1_21_3343353', 'The following entries have non-unique values for "experiment_id" (from Airtable) in the "genetic_findings" table: Broad_exome_VCGS_FAM203_621_D2 (Broad_HG00731_19_1912632, Broad_HG00731_1_248367227)', ] From 76a5bae8c137d6dfbf4a54549dd2951752d116a4 Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 29 Oct 2024 16:46:22 -0400 Subject: [PATCH 4/5] fix test --- seqr/views/apis/report_api_tests.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/seqr/views/apis/report_api_tests.py b/seqr/views/apis/report_api_tests.py index e4f8e41a60..7883635178 100644 --- a/seqr/views/apis/report_api_tests.py +++ b/seqr/views/apis/report_api_tests.py @@ -66,6 +66,15 @@ 'Recontactable': 'Yes', }, }, + { + "id": "rec2Nkg10N1KssX1c", + "fields": { + 'SeqrCollaboratorSampleID': 'NA19679', + 'CollaboratorSampleID': 'NA19679', + 'CollaboratorParticipantID': 'NA19679', + 'SMID': 'SM-X1P92', + }, + }, { "id": "rec2Nkg10N1KssPc3", "fields": { @@ -1123,7 +1132,7 @@ def _assert_expected_file(self, actual_rows, expected_rows, additional_calls=0, def _test_expected_gregor_airtable_calls(self, additional_samples=None, additional_mondo_ids=None): mondo_ids = ['0044970'] + (additional_mondo_ids or []) - self.assertEqual(len(responses.calls), len(mondo_ids) + 4) + self.assertEqual(len(responses.calls), len(mondo_ids) + 5) self.assertSetEqual( {call.request.url for call in responses.calls[:len(mondo_ids)]}, {f'https://monarchinitiative.org/v3/api/entity/MONDO:{mondo_id}' for mondo_id in mondo_ids} @@ -1163,8 +1172,11 @@ def _test_expected_gregor_airtable_calls(self, additional_samples=None, addition len(mondo_ids) + 2, "OR(CollaboratorParticipantID='NA19675',CollaboratorParticipantID='NA19679',CollaboratorParticipantID='NA20888',CollaboratorParticipantID='VCGS_FAM203_621')", metadata_fields, ) + self.assert_expected_airtable_call( + len(mondo_ids) + 3,"OR(RECORD_ID()='rec2B67GmXpAkQW8z')",['SMID'], + ) - self.assertEqual(responses.calls[len(mondo_ids) + 3].request.url, MOCK_DATA_MODEL_URL) + self.assertEqual(responses.calls[len(mondo_ids) + 4].request.url, MOCK_DATA_MODEL_URL) def test_family_metadata(self): url = reverse(family_metadata, args=['R0003_test']) From 50da13c509d82d28700b2aa577dc42538c6a16e9 Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 29 Oct 2024 16:47:51 -0400 Subject: [PATCH 5/5] clean up --- seqr/views/apis/report_api_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seqr/views/apis/report_api_tests.py b/seqr/views/apis/report_api_tests.py index 7883635178..fefa27df4b 100644 --- a/seqr/views/apis/report_api_tests.py +++ b/seqr/views/apis/report_api_tests.py @@ -73,6 +73,7 @@ 'CollaboratorSampleID': 'NA19679', 'CollaboratorParticipantID': 'NA19679', 'SMID': 'SM-X1P92', + 'Recontactable': 'Yes', }, }, { @@ -849,7 +850,7 @@ def _test_gregor_export(self, url, mock_subprocess, mock_temp_dir, mock_open, mo self.assertEqual(response.status_code, 400) recommended_warnings = [ - 'The following entries are missing recommended "recontactable" in the "participant" table: Broad_HG00731, Broad_HG00732, Broad_HG00733, Broad_NA19678, Broad_NA19679, Broad_NA20870, Broad_NA20872, Broad_NA20874, Broad_NA20875, Broad_NA20876, Broad_NA20881', + 'The following entries are missing recommended "recontactable" in the "participant" table: Broad_HG00731, Broad_HG00732, Broad_HG00733, Broad_NA19678, Broad_NA20870, Broad_NA20872, Broad_NA20874, Broad_NA20875, Broad_NA20876, Broad_NA20881', 'The following entries are missing recommended "reported_race" in the "participant" table: Broad_HG00733, Broad_NA19678, Broad_NA19679, Broad_NA20870, Broad_NA20872, Broad_NA20874, Broad_NA20875, Broad_NA20876, Broad_NA20881, Broad_NA20888', 'The following entries are missing recommended "phenotype_description" in the "participant" table: Broad_NA20870, Broad_NA20872, Broad_NA20874, Broad_NA20875, Broad_NA20876, Broad_NA20881, Broad_NA20888', 'The following entries are missing recommended "age_at_enrollment" in the "participant" table: Broad_HG00731, Broad_NA20870, Broad_NA20872, Broad_NA20875, Broad_NA20876, Broad_NA20881, Broad_NA20888',