Source code for schrodinger.protein.gpcr.annotate
"""
This module is for annotating GPCR sequences using data from the GPCR DB.
Copyright Schrodinger, LLC. All rights reserved.
"""
import json
import inflect
from . import gpcrdb
from . import sql
from .sql import create_conn
[docs]@create_conn
def get_sequence(entry_name, *, conn=None):
"""
Get the sequence for the given entry
:param entry_name: GPCR DB entry name (e.g. 5ht1a_human)
:type entry_name: str
:param conn: keyword-only; if not passed, will open default connection
:type conn: sqlite3.Connection
:rtype: str
"""
resp = conn.execute("SELECT sequence FROM entries WHERE entry_name = ?",
[entry_name])
rows = list(resp)
if len(rows) == 1:
return rows[0][0]
else:
n_rows = inflect.engine().no("row", len(rows))
raise ValueError(f"Found {n_rows} with entry name {entry_name}")
[docs]@create_conn
def get_families(entry_name, *, conn=None):
"""
Get the GPCR families for the given entry
:param entry_name: GPCR DB entry name (e.g. 5ht1a_human)
:type entry_name: str
:param conn: keyword-only; if not passed, will open default connection
:type conn: sqlite3.Connection
:rtype: list[str]
"""
resp = conn.execute("SELECT families FROM entries WHERE entry_name = ?",
[entry_name])
rows = list(resp)
if len(rows) == 1:
families = rows[0][0]
return json.loads(families)
else:
n_rows = inflect.engine().no("row", len(rows))
raise ValueError(f"Found {n_rows} with entry name {entry_name}")
[docs]@create_conn
def get_residue_annotations(entry_name, *, conn=None):
"""
Get the residue annotations for the given entry
:param entry_name: GPCR DB entry name (e.g. 5ht1a_human)
:type entry_name: str
:param conn: keyword-only; if not passed, will open default connection
:type conn: sqlite3.Connection
:rtype: list[dict]
"""
residue_rows = conn.execute(sql.SELECT_RESIDUES_SQL, [entry_name])
return [dict(zip(sql.RESIDUES_KEYS, row)) for row in residue_rows]
[docs]def get_gpcrdb_url(entry_name):
"""
Get the GPCR DB URL for the given entry
:param entry_name: GPCR DB entry name (e.g. 5ht1a_human)
:type entry_name: str
"""
return gpcrdb.get_url(entry_name)