Conversation
…, merged create_json_file and write_json_file, moving away from manual queries towards using pypika to generate SQL
…PECIFIED. added validate to fetch functions
| except Exception as e: | ||
| logger.warning(f"Database error: {e}") | ||
| logger.warning("Rolling back") | ||
| # rollback failed transaction | ||
| self.connection.rollback() | ||
| return {} |
There was a problem hiding this comment.
If you're not writing to the database there is nothing to rollback.
convert_gvf_to_vcf/metadataJSON.py
Outdated
|
|
||
| ) | ||
| project_title_dict = self.load_from_db(project_title_query.get_sql(quote_char=None)) | ||
| project_title = next(iter(project_title_dict.values()))[0] |
There was a problem hiding this comment.
See my comment in load_from_db but this seems very complicated for just getting the first element of a list.
Also you never check to see if the list contains something which would raise a exception.
There was a problem hiding this comment.
Change has been implemented in c0e2cd7 using validate_fetch_result to handle None.
convert_gvf_to_vcf/metadataJSON.py
Outdated
| def _get_sample_pre_registered(self, study_accession, biosample_accession): | ||
| # requires analysisAlias, sampleinVCF, biosample_accession | ||
| sample_analysis_alias = self._fetch_analysis_alias(study_accession) | ||
| sample_sampleinvcf = "UNSPECIFIED_SAMPLE_IN_VCF" |
There was a problem hiding this comment.
We need to find the actual sample name otherwise we cannot link this sample to the data.
There was a problem hiding this comment.
This change has been implemented in commit 27aa782 under the assumption sampleinVCF = sample_id.
| experiment_type = self.validate_fetch_result("experimentType", experiment_type_dict) | ||
| return experiment_type | ||
|
|
||
| def _fetch_reference_genome(self, study_accession): |
There was a problem hiding this comment.
Agree that this needs to be resolved, outside the scope of this ticket, this will be addressed in another ticket (EVA-4096)
|
|
||
| for sample_status in sample_registration_statuses: | ||
| if sample_status.is_sample_preregistered: | ||
| sample_metadata = self._get_sample_pre_registered(study_accession, sample_status.sample_accession, sample_status.sample_id) |
There was a problem hiding this comment.
Agree with change on attribute error for namedtuple. This has been implemented in commit 847075d.
| .select(ds.BIOPROJECT_ACCESSION) | ||
| .where(ds.STUDY_ACCESSION == study_accession) | ||
| ) | ||
| project_accession_dict = self.load_from_db(project_accession_query.get_sql(quote_char=None)) |
There was a problem hiding this comment.
Agree with what to do if project_accession_dict is empty. This has been implemented in commit c68f41b.
| .where(ds.STUDY_ACCESSION == study_accession) | ||
| ) | ||
| project_accession_dict = self.load_from_db(project_accession_query.get_sql(quote_char=None)) | ||
| project_accession = self.validate_fetch_result("projectAccession", project_accession_dict) |
There was a problem hiding this comment.
Change implemented in 0dc8338 using validate_fetch_result to handle None.
| analysis_description = self.validate_fetch_result("description", analysis_description_dict) | ||
| return analysis_description | ||
|
|
||
| def _fetch_experiment_type(self, study_accession): |
There was a problem hiding this comment.
Agree with the comment about not being validated against the EVA enum. Suggest this is outside of the scope of this ticket
| parser.add_argument("study_accession", help="DGVa Study Accession") | ||
| parser.add_argument("-a", "--assembly", help="FASTA assembly file") | ||
| parser.add_argument("--log", help="Path to log file") | ||
| parser.add_argument("--config", help="Path to config file") |
There was a problem hiding this comment.
--config is optional but treated as required = This has been implemented in commit a0b3d81 by checking for presence of config before obtaining metadata.
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("gvf_input", help="GVF input file.") | ||
| parser.add_argument("vcf_output", help="VCF output file.") | ||
| parser.add_argument("json_output", help="JSON output file.") |
There was a problem hiding this comment.
Making json_output and study_accession optional: this change has been implemented in 147659f by making arguments optional.
…or missing results
…ed in the function name
convert_gvf_to_vcf/metadataJSON.py
Outdated
| # assumption the name: sampleinVCF = sample_id | ||
| sample_sampleinvcf = sample_id | ||
| sample_object = { | ||
| "analysisAlias": sample_analysis_alias, |
There was a problem hiding this comment.
| "analysisAlias": sample_analysis_alias, | |
| "analysisAlias": [sample_analysis_alias], |
tests/test_metadataJSON.py
Outdated
| metadata_client._connection = mock_unhealthy | ||
| result = metadata_client.connection | ||
| # did you close the unhealthy connection | ||
| mock_unhealthy.close_assert_called_once() |
There was a problem hiding this comment.
| mock_unhealthy.close_assert_called_once() | |
| mock_unhealthy.close.assert_called_once() |
| mock_connection_object_existing = Mock() | ||
| mock_connection.return_value = mock_connection_object_existing |
There was a problem hiding this comment.
This two lines are not used.
| mock_connection_object_existing = Mock() | |
| mock_connection.return_value = mock_connection_object_existing |
No description provided.