-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added core-187 demo script; fixed minor issue in ensembl-fetch
- Loading branch information
Showing
3 changed files
with
49 additions
and
4 deletions.
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
43 changes: 43 additions & 0 deletions
43
tests/issues/core-187-missing-cds-equivalency-for-FAM58A/core-187-demo.py
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python | ||
|
||
"""CORE-187 suggested that we were missing a transcript, | ||
ENST00000576892, for FAM58A. This script demonstrates the cause: that | ||
transcript is on a patch region. | ||
""" | ||
|
||
|
||
import logging | ||
import sys | ||
|
||
import requests | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
base_uri = "http://grch37.rest.ensembl.org" | ||
|
||
def _fetch_json(path): | ||
uri = base_uri + path | ||
r = requests.get(uri, headers={"Content-Type" : "application/json"}) | ||
r.raise_for_status() | ||
logger.info('fetched '+uri) | ||
return r.json() | ||
|
||
def fetch_gene(hgnc): | ||
return _fetch_json("/xrefs/symbol/homo_sapiens/"+hgnc) | ||
|
||
def lookup(id): | ||
return _fetch_json("/lookup/id/{id}?expand=1".format(id=id)) | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
|
||
ensgs = [r['id'] for r in fetch_gene('FAM58A') if r['id'].startswith("ENSG")] | ||
|
||
for ensg in ensgs: | ||
l = lookup(ensg) | ||
txs = l['Transcript'] | ||
print("* {l[display_name]} {l[version]} {l[seq_region_name]} {l[object_type]}; {n} transcripts ".format(l=l, n=len(txs))) | ||
for tx in txs: | ||
print(" {tx[display_name]} {tx[id]} {tx[version]} {tx[seq_region_name]}; {n} exons".format(tx=tx, n=len(tx))) |