Skip to content

Commit

Permalink
Merge pull request #19 from ccaitlingo/remove-error-import
Browse files Browse the repository at this point in the history
Remove error import
  • Loading branch information
ccaitlingo authored Jul 5, 2023
2 parents ae09fad + 1dbd86a commit 6f49b97
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 24 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ Read the official cdot documentation [here](https://github.com/SACGF/cdot).
| Data Provider Function | uta | cdot |
| ------------------------- |-----------| ----------|
| get_seq | |
| get_acs_for_protein | * | *
| get_acs_for_protein_seq | | Not implemented (note in hgvs to drop this method)
| get_gene_info | Includes datetime of when transcript was added |
| get_tx_exons | Includes the following additional fields: hgnc, tx_aseq, alt_aseq, test_exon_set_id, aes_exon_set_id, tx_exon_id, alt_exon_id, exon_aln_id
| get_tx_for_gene | * | *
| get_tx_for_region |
| get_alignments_for_region | | Not implemented
| get_alignments_for_region | |
| get_tx_identity_info |
| get_tx_info | | Does not perform alignments (does not use the alt_c argument) when fetching transcripts
| get_tx_info | |
| get_tx_mapping_options |
| get_similar_transcripts |
| get_similar_transcripts | | Not implemented (hgvs does not use this function)
| get_pro_ac_for_tx_ac |
| get_assembly_map |

Expand All @@ -47,7 +47,7 @@ In python:
Assign any of the following supported clients to your hgvs data provider.

>>> hdp = utaclients.uta.connect()
>>> hdp = utaclients.uta_rest.connect()
>>> hdp = utaclients.utarest.connect()
>>> hdp = utaclients.cdot.connect()

Then you can get started using all the functionalities of hgvs.
Expand Down
2 changes: 1 addition & 1 deletion src/uta_clients/cdot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cdot.hgvs.dataproviders import RESTDataProvider
from cdot.hgvs.dataproviders import HGVSDataNotAvailableError, RESTDataProvider


def connect():
Expand Down
2 changes: 1 addition & 1 deletion src/uta_clients/uta.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from hgvs.dataproviders.uta import connect
from hgvs.dataproviders.uta import HGVSDataNotAvailableError, HGVSError, connect
46 changes: 46 additions & 0 deletions tests/cassettes/test_cdot_alignments_for_region_e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-requests/2.31.0
method: GET
uri: https://cdot.cc/transcripts/region/NC_000007.13/splign/0/50
response:
body:
string: '{"results": []}'
headers:
Access-Control-Allow-Origin:
- http://203.101.229.44
Cache-Control:
- max-age=86400
Connection:
- keep-alive
Content-Length:
- '15'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Wed, 05 Jul 2023 17:05:31 GMT
Expires:
- Thu, 06 Jul 2023 17:05:31 GMT
Referrer-Policy:
- same-origin
Server:
- gunicorn
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
version: 1
41 changes: 41 additions & 0 deletions tests/cassettes/test_cdot_alignments_for_region_ne.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-requests/2.31.0
method: GET
uri: https://cdot.cc/transcripts/region/fake/splign/0/50
response:
body:
string: "\n<!doctype html>\n<html lang=\"en\">\n<head>\n <title>Server Error
(500)</title>\n</head>\n<body>\n <h1>Server Error (500)</h1><p></p>\n</body>\n</html>\n"
headers:
Connection:
- keep-alive
Content-Length:
- '145'
Content-Type:
- text/html
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Wed, 05 Jul 2023 17:03:03 GMT
Referrer-Policy:
- same-origin
Server:
- gunicorn
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 500
message: Internal Server Error
version: 1
4 changes: 2 additions & 2 deletions tests/cassettes/test_cdot_tx_info_ne.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ interactions:
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Thu, 15 Jun 2023 23:36:27 GMT
- Wed, 05 Jul 2023 16:54:44 GMT
Expires:
- Fri, 16 Jun 2023 23:06:23 GMT
- Thu, 06 Jul 2023 16:54:44 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down
25 changes: 10 additions & 15 deletions tests/test_cdot_vs_uta.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import datetime
from typing import Dict, List

import hgvs.dataproviders.uta as uta
import pytest

import src.uta_clients.cdot as cdot
from src.uta_clients import cdot, uta


def just_values(dictionaries: List[Dict]) -> List[List]:
Expand Down Expand Up @@ -63,7 +62,7 @@ def test_cdot_seq_e_indices():
assert u == c


@pytest.mark.skip(reason="cdot has different transcripts than uta")
@pytest.mark.skip(reason="not implemented in cdot")
# @pytest.mark.vcr
def test_cdot_acs_for_protein_seq_e():
"""Existing seq."""
Expand All @@ -72,7 +71,7 @@ def test_cdot_acs_for_protein_seq_e():
assert u == c


@pytest.mark.skip(reason="cdot has different transcripts than uta")
@pytest.mark.skip(reason="not implemented in cdot")
# @pytest.mark.vcr
def test_cdot_acs_for_protein_seq_ne():
"""Nonexisting seq."""
Expand All @@ -81,7 +80,7 @@ def test_cdot_acs_for_protein_seq_ne():
assert u == c


@pytest.mark.skip(reason="error not implemented in cdot")
@pytest.mark.skip(reason="not implemented in cdot")
# @pytest.mark.vcr
def test_cdot_acs_for_protein_seq_ne_nonalphabetical():
"""Non-alphabetic character seq."""
Expand Down Expand Up @@ -200,26 +199,23 @@ def test_cdot_tx_for_region_ne_params():
uta.connect().get_tx_for_region("fake", "splign")


@pytest.mark.skip(reason="not implemented in cdot")
# @pytest.mark.vcr
@pytest.mark.vcr
def test_cdot_alignments_for_region_e(): # Need example
"""Existing region."""
u = uta.connect().get_alignments_for_region("NC_000007.13", 0, 50)
c = cdot.connect().get_alignments_for_region("NC_000007.13", 0, 50)
assert u == c


@pytest.mark.skip(reason="not implemented in cdot")
# @pytest.mark.vcr
@pytest.mark.vcr
def test_cdot_alignments_for_region_ne():
"""Nonexisting region"""
u = uta.connect().get_alignments_for_region("fake", 0, 50)
c = cdot.connect().get_alignments_for_region("fake", 0, 50)
assert u == c


@pytest.mark.skip(reason="not implemented in cdot")
# @pytest.mark.vcr
@pytest.mark.vcr
def test_cdot_alignments_region_e_params():
"""Existing region with only some params."""
with pytest.raises(TypeError):
Expand All @@ -228,8 +224,7 @@ def test_cdot_alignments_region_e_params():
uta.connect().get_alignments_for_region("NC_000007.13")


@pytest.mark.skip(reason="not implemented in cdot")
# @pytest.mark.vcr
@pytest.mark.vcr
def test_cdot_alignments_region_ne_params():
"""Existing region with only some params."""
with pytest.raises(TypeError):
Expand Down Expand Up @@ -262,11 +257,11 @@ def test_cdot_tx_info_e():
assert u == c


@pytest.mark.xfail
@pytest.mark.vcr
def test_cdot_tx_info_ne():
"""Nonexisting seq."""
assert cdot.connect().get_tx_info("NM_199425.2", "fake", "splign") == None
with pytest.raises(cdot.HGVSDataNotAvailableError):
cdot.connect().get_tx_info("NM_199425.2", "fake", "splign")
with pytest.raises(uta.HGVSDataNotAvailableError):
uta.connect().get_tx_info("NM_199425.2", "fake", "splign")

Expand Down

0 comments on commit 6f49b97

Please sign in to comment.