Skip to content

Commit 6f81a69

Browse files
committed
remove genomic table stuff
1 parent d1fca22 commit 6f81a69

3 files changed

Lines changed: 23 additions & 71 deletions

File tree

compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ services:
1414
read_only: true
1515
bind:
1616
create_host_path: false
17-
- ./uta-setup.sql:/docker-entrypoint-initdb.d/uta-setup.sql
1817
ports:
1918
- 127.0.0.1:5432:5432
2019

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dev = [
4949
]
5050
tests = ["pytest", "pytest-cov", "pytest-asyncio", "mock"]
5151
docs = [
52-
"sphinx==6.1.3",
52+
"sphinx==6.2.1",
5353
"sphinx-autodoc-typehints==1.22.0",
5454
"sphinx-autobuild==2021.3.14",
5555
"sphinx-copybutton==0.5.2",

src/cool_seq_tool/sources/uta_database.py

Lines changed: 22 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -132,52 +132,6 @@ async def execute_query(
132132
)
133133
raise
134134

135-
async def create_genomic_table(self) -> None:
136-
"""Create the derived ``genomic`` table in the current schema if needed."""
137-
create_genomic_table = """
138-
CREATE TABLE IF NOT EXISTS genomic AS
139-
SELECT
140-
t.hgnc,
141-
aes.alt_ac,
142-
aes.alt_aln_method,
143-
aes.alt_strand,
144-
ae.start_i AS alt_start_i,
145-
ae.end_i AS alt_end_i
146-
FROM transcript t
147-
JOIN exon_set tes
148-
ON t.ac = tes.tx_ac
149-
AND tes.alt_aln_method = 'transcript'
150-
JOIN exon_set aes
151-
ON t.ac = aes.tx_ac
152-
AND aes.alt_aln_method <> 'transcript'
153-
JOIN exon te
154-
ON tes.exon_set_id = te.exon_set_id
155-
JOIN exon ae
156-
ON aes.exon_set_id = ae.exon_set_id
157-
AND te.ord = ae.ord
158-
LEFT JOIN exon_aln ea
159-
ON te.exon_id = ea.tx_exon_id
160-
AND ae.exon_id = ea.alt_exon_id;
161-
"""
162-
await self.execute_query(create_genomic_table)
163-
164-
indexes = [
165-
"""
166-
CREATE INDEX IF NOT EXISTS alt_pos_index
167-
ON genomic (alt_ac, alt_start_i, alt_end_i);
168-
""",
169-
"""
170-
CREATE INDEX IF NOT EXISTS gene_alt_index
171-
ON genomic (hgnc, alt_ac);
172-
""",
173-
"""
174-
CREATE INDEX IF NOT EXISTS alt_ac_index
175-
ON genomic (alt_ac);
176-
""",
177-
]
178-
for create_index in indexes:
179-
await self.execute_query(create_index)
180-
181135
async def get_alt_ac_start_or_end(
182136
self, tx_ac: str, tx_exon_start: int, tx_exon_end: int, gene: str | None
183137
) -> GenomicAlnData:
@@ -678,6 +632,11 @@ async def get_gene_from_ac(
678632
>>> result
679633
['BRCA1']
680634
635+
This function performs a relatively expensive condition check and is expected to
636+
be relatively slow (~100ms under ideal conditions). If users need a more efficient
637+
lookup of this form, they should either create their own materialized views/indices,
638+
or lobby for their inclusion in a new UTA release.
639+
681640
:param ac: NC accession, e.g. ``"NC_000001.11"``
682641
:param start_pos: Start position change
683642
:param end_pos: End position change
@@ -1028,9 +987,7 @@ def _normalize_uta_db_url(db_url: str) -> str:
1028987
)
1029988

1030989

1031-
async def create_uta_connection_pool(
1032-
db_url: str | None = None, initialize_genomic_table: bool = True
1033-
) -> AsyncConnectionPool:
990+
async def create_uta_connection_pool(db_url: str | None = None) -> AsyncConnectionPool:
1034991
"""Create and initialize a UTA connection pool.
1035992
1036993
Connection parameters are resolved in the following order:
@@ -1041,13 +998,23 @@ async def create_uta_connection_pool(
1041998
3. If not provided, fall back to environment variable ``UTA_DB_URL``
1042999
4. If not declared, then use default value
10431000
1044-
After opening the pool, a one-time initialization step is performed to ensure that
1045-
required genomic tables are present.
1001+
Connection strings are expected to look like this:
1002+
1003+
.. note::
10461004
1047-
:param db_url: PostgreSQL connection URI (e.g., ``postgresql://user@host:port/db?options=-csearch_path%3Duta_schema,public``).
1048-
If not provided, resolved from environment or defaults.
1049-
:param initialize_genomic_table: whether to attempt initialization of the ``genomic``
1050-
table which is used/managed by coolseqtool.
1005+
Connection strings are expected to look like this:
1006+
1007+
postgresql://user@host:port/db?options=-csearch_path%3Duta_schema,public
1008+
1009+
For example, this is the default:
1010+
1011+
postgresql://anonymous@localhost:5432/uta?options=-csearch_path%3Duta_20241220,public
1012+
1013+
However, biocommons-style connection strings are presently supported, although they are considered deprecated:
1014+
1015+
postgresql://anonymous@localhost:5432/uta/uta_20241220
1016+
1017+
:param db_url: PostgreSQL connection URI If not provided, resolved from environment or defaults.
10511018
:return: An open ``AsyncConnectionPool`` configured for the UTA database
10521019
"""
10531020
if "UTA_DB_PROD" in os.environ:
@@ -1061,20 +1028,6 @@ async def create_uta_connection_pool(
10611028
)
10621029
pool = AsyncConnectionPool(conninfo=db_url, open=False)
10631030
await pool.open()
1064-
if initialize_genomic_table:
1065-
warnings.warn(
1066-
"Genomic table initialization during connection pool construction is deprecated and subject to deletion in future releases. Users should perform this operation manually using `UtaRepository.create_genomic_table()`.",
1067-
DeprecationWarning,
1068-
stacklevel=2,
1069-
)
1070-
try:
1071-
async with pool.connection() as conn:
1072-
await UtaRepository(conn).create_genomic_table()
1073-
# catch all exceptions -- this is probably a critical error, it's good to
1074-
# close the pool first
1075-
except:
1076-
await pool.close()
1077-
raise
10781031
return pool
10791032

10801033

0 commit comments

Comments
 (0)