-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add new grpc endpoint to get genome id from accession id #63
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
17fbf7d
Add new grpc endpoint to get genome id from accession id
jyothishnt 019bdf6
review comments update
jyothishnt 026335f
update url endpoint
jyothishnt ef29bfe
add 404
jyothishnt e8fd064
logging
jyothishnt dcccbf9
review comment
jyothishnt 01a2481
update api spec doc
jyothishnt 7584965
update api spec; return json response
jyothishnt e6cd8ef
add 404 in api spec
jyothishnt 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
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
import json | ||
import logging | ||
from typing import Annotated | ||
|
||
|
@@ -25,7 +26,7 @@ | |
from api.models.statistics import GenomeStatistics, ExampleObjectList | ||
from api.models.popular_species import PopularSpeciesGroup | ||
from api.models.karyotype import Karyotype | ||
from api.models.genome import BriefGenomeDetails, GenomeDetails, DatasetAttributes | ||
from api.models.genome import BriefGenomeDetails, GenomeDetails, DatasetAttributes, GenomeByKeyword | ||
from api.models.ftplinks import FTPLinks | ||
|
||
from core.config import GRPC_HOST, GRPC_PORT | ||
|
@@ -238,3 +239,21 @@ async def get_genome_dataset_attributes( | |
except Exception as ex: | ||
logging.error(ex) | ||
return response_error_handler({"status": 500}) | ||
|
||
@router.get("/genome") | ||
async def get_genome_by_keyword(request: Request, assembly_accession_id: str): | ||
if (assembly_accession_id == ""): | ||
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. What if assembly accession ID doesn’t exist in the response? |
||
not_found_response = {"message": "missing assembly_accession_id"} | ||
return responses.JSONResponse(not_found_response, status_code=404) | ||
try: | ||
genome_response = grpc_client.get_genome_by_specific_keyword(assembly_accession_id=assembly_accession_id) | ||
latest_genome_by_keyword_object = GenomeByKeyword() | ||
for arr in genome_response: | ||
arr = MessageToDict(arr) | ||
genome_by_keyword_object = GenomeByKeyword(**arr) | ||
if (genome_by_keyword_object.release_version > latest_genome_by_keyword_object.release_version): | ||
latest_genome_by_keyword_object = genome_by_keyword_object | ||
return latest_genome_by_keyword_object | ||
except Exception as ex: | ||
logging.error(ex) | ||
return response_error_handler({"status": 500}) |
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.
Didn't we say that since
genome
in other routes has a different shape, this route should be called something other thangenome
?