-
Notifications
You must be signed in to change notification settings - Fork 48
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 liftover #5326
Open
northwestwitch
wants to merge
8
commits into
main
Choose a base branch
from
refactor_liftover
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix liftover #5326
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c83eaad
Fix liftover
6d3d2c7
PR ref on changelog
9065748
Replace url in 2 other tests
223a10a
One more fix in a test
5fedc8d
Replace one more
a6d3fee
Typo
f69feb0
Small fixes
a74869d
Remove pointless test
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
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
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 |
---|---|---|
|
@@ -4,53 +4,33 @@ | |
from requests.exceptions import MissingSchema | ||
from requests.models import Response | ||
|
||
from scout.utils.ensembl_rest_clients import RESTAPI_37 | ||
from scout.utils.ensembl_rest_clients import RESTAPI_URL | ||
|
||
|
||
@responses.activate | ||
def test_liftover(ensembl_rest_client_37, ensembl_liftover_response): | ||
def test_liftover(ensembl_rest_client, ensembl_liftover_response): | ||
"""Test send request for coordinates liftover""" | ||
# GIVEN a patched response from Ensembl | ||
url = f"{RESTAPI_37}/map/human/GRCh37/X:1000000..1000100/GRCh38?content-type=application/json" | ||
url = f"{RESTAPI_URL}/map/human/GRCh37/X:1000000..1000100/GRCh38?content-type=application/json" | ||
responses.add( | ||
responses.GET, | ||
url, | ||
json=ensembl_liftover_response, | ||
status=200, | ||
) | ||
client = ensembl_rest_client_37 | ||
client = ensembl_rest_client | ||
# WHEN sending the liftover request the function should return a mapped locus | ||
mapped_coords = client.liftover("37", "X", 1000000, 1000100) | ||
assert mapped_coords[0]["mapped"] | ||
|
||
|
||
@responses.activate | ||
def test_send_gene_request(ensembl_gene_response, ensembl_rest_client_37): | ||
"""Test send request with correct params and endpoint""" | ||
url = f"{RESTAPI_37}/overlap/id/ENSG00000103591?feature=gene" | ||
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. This overlap functionality is not even used in Scout so the test is pointless |
||
client = ensembl_rest_client_37 | ||
responses.add( | ||
responses.GET, | ||
url, | ||
json=ensembl_gene_response, | ||
status=200, | ||
) | ||
data = client.send_request(url) | ||
|
||
# get all gene for the ensembl gene, They should be a list of items | ||
assert data[0]["assembly_name"] == "GRCh37" | ||
assert data[0]["external_name"] == "AAGAB" | ||
assert data[0]["start"] | ||
assert data[0]["end"] | ||
|
||
|
||
def test_send_request_fakey_url(mock_app, ensembl_rest_client_37, mocker): | ||
def test_send_request_fakey_url(mock_app, ensembl_rest_client, mocker): | ||
"""Test the Ensembl REST client with an URL that is raising missing schema error.""" | ||
|
||
# GIVEN a completely invalid URL | ||
url = "fakeyurl" | ||
# GIVEN a patched Ensembl client | ||
client = ensembl_rest_client_37 | ||
client = ensembl_rest_client | ||
mocker.patch("requests.get", side_effect=MissingSchema("Invalid URL")) | ||
|
||
# THEN the client should return no content | ||
|
@@ -59,12 +39,12 @@ def test_send_request_fakey_url(mock_app, ensembl_rest_client_37, mocker): | |
assert data is None | ||
|
||
|
||
def test_send_request_unavaailable(mock_app, ensembl_rest_client_37, mocker): | ||
def test_send_request_unavaailable(mock_app, ensembl_rest_client, mocker): | ||
"""Test the Ensembl REST client with an URL that is not available (500 error).""" | ||
|
||
url = f"{RESTAPI_37}/fakeyurl" | ||
url = f"{RESTAPI_URL}/fakeyurl" | ||
# GIVEN a patched Ensembl client | ||
client = ensembl_rest_client_37 | ||
client = ensembl_rest_client | ||
|
||
# GIVEN a mocked 550 response from Ensembl | ||
mock_response = Response() | ||
|
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.
Back in the day we had this distinction because we had more REST API functions. This is no longer needed now, I think
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.
Ah wait a sec, there is one functionality that is not liftover. I'll convert this to a draft again
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.
Ah no, it's just a test, nothing used in the code. I think I'll just remove it