Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: enable cool-seq-tool injection #158

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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