Skip to content

Commit

Permalink
feat!: enable cool-seq-tool injection (#158)
Browse files Browse the repository at this point in the history
* provide CST object directly instead of taking constructor params
* suppress data checks in test
  • Loading branch information
jsstevenson authored Jul 16, 2024
1 parent 0b557c2 commit b686d01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
16 changes: 5 additions & 11 deletions src/fusor/fusor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re
from urllib.parse import quote

from biocommons.seqrepo import SeqRepo
from bioutils.accessions import coerce_namespace
from cool_seq_tool.app import CoolSeqTool
from cool_seq_tool.schemas import ResidueMode
Expand Down Expand Up @@ -65,26 +64,21 @@ class FUSOR:

def __init__(
self,
seqrepo_data_path: str | None = None,
gene_database: GeneDatabase | None = None,
uta_db_url: str | None = None,
cool_seq_tool: CoolSeqTool | None = None,
) -> None:
"""Initialize FUSOR class.
:param seqrepo_data_path: Path to SeqRepo data directory
:param cool_seq_tool: Cool-Seq-Tool instance
:param gene_database: gene normalizer database instance
:param uta_db_url: Postgres URL for UTA
"""
if not gene_database:
gene_database = create_db()
self.gene_normalizer = QueryHandler(gene_database)

cst_params = {}
if uta_db_url:
cst_params["db_url"] = uta_db_url
if seqrepo_data_path:
cst_params["sr"] = SeqRepo(seqrepo_data_path)
self.cool_seq_tool = CoolSeqTool(**cst_params)
if not cool_seq_tool:
cool_seq_tool = CoolSeqTool()
self.cool_seq_tool = cool_seq_tool
self.seqrepo = self.cool_seq_tool.seqrepo_access.sr

@staticmethod
Expand Down
15 changes: 13 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging

import pytest
from cool_seq_tool.app import CoolSeqTool

from fusor.fusor import FUSOR

Expand Down Expand Up @@ -30,8 +31,18 @@ def pytest_configure(config):

@pytest.fixture(scope="session")
def fusor_instance():
"""Create test fixture for fusor object"""
return FUSOR()
"""Create test fixture for fusor object
Suppresses checks for CoolSeqTool external resources. Otherwise, on CST startup,
it will try to check that its MANE summary file is up-to-date, which is an FTP call
to the NCBI servers and can hang sometimes.
If those files aren't available, create a CST instance in another session -- by
default, it should save files to a centralized location that this test instance can
access.
"""
cst = CoolSeqTool(force_local_files=True)
return FUSOR(cool_seq_tool=cst)


@pytest.fixture(scope="session")
Expand Down

0 comments on commit b686d01

Please sign in to comment.