-
Notifications
You must be signed in to change notification settings - Fork 2
Features/updater refactor #32
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e93b273
Initial refactor with changes made to the organism update
dpopleton bc6601b
Fiadded new genset and assembly updates
dpopleton f60e708
Full refactor of updater before testing. Created release check for AP…
dpopleton 4f8c7b6
Full refactor of updater before testing. Created release check for AP…
dpopleton 93fc4a1
Update genome.py
dpopleton 7c4f4fd
Fixed Tests
dpopleton 18ea79d
Modified test dbs to use E. coli taxid
dpopleton 6b974d1
Modified test dbs to use specific unique name.
dpopleton 659aca5
Improved fetch taxonomy names within api
dpopleton 1c397de
Added taxid genome api check
dpopleton c3cf0a7
added a change for taxid check. Major rework already in PR so it isn'…
dpopleton fad763c
added a change for taxid check. Major rework already in PR so it isn'…
dpopleton 03eef45
added a change for taxid check. Major rework already in PR so it isn'…
dpopleton 43534ae
updated test tables
dpopleton 06c7c3c
Fixed api test and altered get sequences
dpopleton ffcd9f2
added attrib_type to tests
dpopleton 8ce5ea4
Reworked Tests
dpopleton 3e06aef
Reworked Tests
dpopleton 7baee2a
Reworked Tests
dpopleton 216ef2c
Added lrg skip for assembly sequences
dpopleton 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # See the NOTICE file distributed with this work for additional information | ||
| # regarding copyright ownership. | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import sqlalchemy as db | ||
| from sqlalchemy.engine import make_url | ||
|
|
||
| from ensembl.production.metadata.api.base import BaseAdaptor | ||
| from ensembl.production.metadata.api.models import GenomeDataset, Dataset | ||
| import logging | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class DatasetAdaptor(BaseAdaptor): | ||
| def __init__(self, metadata_uri): | ||
| super().__init__(metadata_uri) | ||
|
|
||
| def check_release_status(self, dataset_uuid): | ||
| with self.metadata_db.session_scope() as session: | ||
| # Query to check if a release_id exists for the given genome_uuid | ||
| dataset_id = session.query(Dataset.dataset_id).filter(Dataset.dataset_uuid == dataset_uuid).scalar() | ||
| if dataset_id is None: | ||
| return "UUID not found" | ||
|
|
||
| # Now we check if there exists a genome dataset with the corresponding dataset_id and a non-null release_id | ||
| result = session.query( | ||
| session.query(GenomeDataset).filter(GenomeDataset.dataset_id == dataset_id, | ||
| GenomeDataset.release_id.isnot(None)).exists() | ||
| ).scalar() | ||
| return result |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |||||
| from sqlalchemy.engine import make_url | ||||||
|
|
||||||
| from ensembl.core.models import Meta | ||||||
| from ensembl.production.metadata.api.models import DatasetSource | ||||||
| from ensembl.database import DBConnection | ||||||
| from ensembl.production.metadata.api.models import EnsemblRelease | ||||||
|
|
||||||
|
|
@@ -21,17 +22,15 @@ class BaseMetaUpdater: | |||||
| def __init__(self, db_uri, metadata_uri, taxonomy_uri, release=None): | ||||||
| self.db_uri = db_uri | ||||||
| self.db = DBConnection(self.db_uri) | ||||||
| self.species = None | ||||||
| self.db_type = None | ||||||
| self.metadata_db = DBConnection(metadata_uri) | ||||||
| # We will add a release later. For now, the release must be specified for it to be used. | ||||||
| if release is None: | ||||||
| self.listed_release = None | ||||||
| self.listed_release_is_current = None | ||||||
| else: | ||||||
| self.listed_release = release | ||||||
| self.listed_release_is_current = EnsemblRelease.is_current | ||||||
| self.metadata_db = DBConnection(metadata_uri) | ||||||
| self.taxonomy_uri = taxonomy_uri | ||||||
|
|
||||||
|
|
||||||
| # Basic API for the meta table in the submission database. | ||||||
| def get_meta_single_meta_key(self, species_id, parameter): | ||||||
|
|
@@ -43,4 +42,29 @@ def get_meta_single_meta_key(self, species_id, parameter): | |||||
| else: | ||||||
| return result[0] | ||||||
|
|
||||||
| def get_meta_list_from_prefix_meta_key(self, species_id, prefix): | ||||||
| with self.db.session_scope() as session: | ||||||
| query = session.query(Meta.meta_key, Meta.meta_value).filter( | ||||||
| Meta.meta_key.like(f'{prefix}%'), | ||||||
| Meta.species_id == species_id | ||||||
| ) | ||||||
| result = query.all() | ||||||
| if not result: | ||||||
| return {} | ||||||
| else: | ||||||
| # Build a dictionary out of the results. | ||||||
| result_dict = {key: value for key, value in result} | ||||||
| return result_dict | ||||||
|
|
||||||
| def get_or_new_source(self, meta_session, db_uri, db_type): | ||||||
| name = make_url(db_uri).database | ||||||
| dataset_source = meta_session.query(DatasetSource).filter(DatasetSource.name == name).one_or_none() | ||||||
| if dataset_source is None: | ||||||
| dataset_source = DatasetSource( | ||||||
| type=db_type, # core/fungen etc | ||||||
| name=name # dbname | ||||||
| ) | ||||||
| meta_session.add(dataset_source) # Only add a new DatasetSource to the session if it doesn't exist | ||||||
| return dataset_source, "new" | ||||||
|
Contributor
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. Status
Suggested change
|
||||||
| else: | ||||||
| return dataset_source, "existing" | ||||||
|
Contributor
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.
Suggested change
or setting Enum class will be standard |
||||||
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.
loaded genomes are not assigned to any release, needed extra step to assign the genomes to release will this be handled in future developments and taxonomy_uri is not used is it required for future purposes?