Skip to content
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- id: mixed-line-ending
args: [ --fix=lf ]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
rev: v0.8.6
hooks:
- id: ruff-format
- id: ruff
Expand Down
31 changes: 25 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dev = [
"ipython",
"ipykernel",
"psycopg2-binary",
"ruff==0.5.0"
"ruff==0.8.6"
]
tests = ["pytest", "pytest-cov", "pytest-asyncio==0.18.3", "mock"]
docs = [
Expand Down Expand Up @@ -116,10 +116,14 @@ lint.select = [
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
"SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf
"SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
"ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
"PLC", # https://docs.astral.sh/ruff/rules/#convention-c
"PLE", # https://docs.astral.sh/ruff/rules/#error-e_1
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
"FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
Expand All @@ -138,14 +142,15 @@ lint.fixable = [
"PT",
"RSE",
"SIM",
"PLC",
"PLE",
"TRY",
"PERF",
"FURB",
"RUF"
]

# ANN003 - missing-type-kwargs
# ANN101 - missing-type-self
# ANN102 - missing-type-cls
# D203 - one-blank-line-before-class
# D205 - blank-line-after-summary
# D206 - indent-with-spaces*
Expand All @@ -159,26 +164,40 @@ lint.fixable = [
# E501 - line-too-long*
# W191 - tab-indentation*
# S321 - suspicious-ftp-lib-usage
# PLC0206 - dict-index-missing-items
# *ignored for compatibility with formatter
lint.ignore = [
"ANN003", "ANN101", "ANN102",
"ANN003",
"D203", "D205", "D206", "D213", "D300", "D400", "D415",
"E111", "E114", "E117", "E501",
"W191",
"S321",
"PLC0206",
]

[tool.ruff.lint.per-file-ignores]
# ANN001 - missing-type-function-argument
# ANN2 - missing-return-type
# ANN102 - missing-type-cls
# D100 - undocumented-public-module
# D102 - undocumented-public-class
# D103 - undocumented-public-function
# N805 - invalid-first-argument-name-for-method
# F821 - undefined-name
# F401 - unused-import
# INP001 - implicit-namespace-package
# SLF001 - private-member-access
# ARG001 - unused-function-argument
"tests/*" = ["ANN001", "ANN2", "ANN102", "S101", "INP001", "SLF001", "ARG001"]
"tests/*" = [
"ANN001",
"ANN2",
"D100",
"D102",
"D103",
"S101",
"INP001",
"SLF001",
"ARG001"
]
"*__init__.py" = ["F401"]
"src/cool_seq_tool/schemas.py" = ["ANN201", "N805", "ANN001"]

Expand Down
2 changes: 1 addition & 1 deletion src/cool_seq_tool/mappers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .exon_genomic_coords import ExonGenomicCoordsMapper


__all__ = ["AlignmentMapper", "LiftOver", "ManeTranscript", "ExonGenomicCoordsMapper"]
__all__ = ["AlignmentMapper", "ExonGenomicCoordsMapper", "LiftOver", "ManeTranscript"]
7 changes: 2 additions & 5 deletions src/cool_seq_tool/mappers/exon_genomic_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,11 +1022,8 @@ def _use_alt_start_i(is_seg_start: bool, strand: Strand) -> bool:
:return ``True`` if alt_start_i should be used, ``False`` if alt_end_i should
be used
"""
return (
is_seg_start
and strand == Strand.POSITIVE
or not is_seg_start
and strand == Strand.NEGATIVE
return (is_seg_start and strand == Strand.POSITIVE) or (
not is_seg_start and strand == Strand.NEGATIVE
)

@staticmethod
Expand Down
20 changes: 9 additions & 11 deletions src/cool_seq_tool/resources/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ async def check_status(
try:
get_data_file(r)
except FileNotFoundError:
_logger.error(
_logger.exception(
"%s does not exist at configured location %s", name_lower, declared_path
)
except ValueError:
_logger.error(
_logger.exception(
"%s configured at %s is not a valid file.", name_lower, declared_path
)
except Exception as e:
Expand All @@ -107,19 +107,17 @@ async def check_status(
chain_file_37_to_38=chain_file_37_to_38,
chain_file_38_to_37=chain_file_38_to_37,
)
except (FileNotFoundError, ChainfileError) as e:
_logger.error("agct converter setup failed: %s", e)
except (FileNotFoundError, ChainfileError):
_logger.exception("agct converter setup failed")
except Exception as e:
_logger.critical("Encountered unexpected error setting up agct: %s", e)
else:
status["liftover"] = True

try:
await UtaDatabase.create(db_url)
except (OSError, InvalidCatalogNameError, UndefinedTableError) as e:
_logger.error(
"Encountered error instantiating UTA at URI %s: %s", UTA_DB_URL, e
)
except (OSError, InvalidCatalogNameError, UndefinedTableError):
_logger.exception("Encountered error instantiating UTA at URI %s", UTA_DB_URL)
except Exception as e:
_logger.critical(
"Encountered unexpected error instantiating UTA from URI %s: %s",
Expand All @@ -134,10 +132,10 @@ async def check_status(
sr = SeqRepo(root_dir=SEQREPO_ROOT_DIR)
sra = SeqRepoAccess(sr)
sra.sr["NC_000001.11"][1000:1001]
except OSError as e:
_logger.error("Encountered error while instantiating SeqRepo: %s", e)
except OSError:
_logger.exception("Encountered error while instantiating SeqRepo")
except KeyError:
_logger.error("SeqRepo data fetch test failed -- is it populated?")
_logger.exception("SeqRepo data fetch test failed -- is it populated?")
except Exception as e:
_logger.critical("Encountered unexpected error setting up SeqRepo: %s", e)
else:
Expand Down
22 changes: 11 additions & 11 deletions src/cool_seq_tool/sources/uta_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ async def create_pool(self) -> None:
database=self.args.database,
)
except InterfaceError as e:
_logger.error(
"While creating connection pool, encountered exception %s", e
_logger.exception(
"While creating connection pool, encountered exception"
)
msg = "Could not create connection pool"
raise Exception(msg) from e
raise Exception(msg) from e # noqa: TRY002

@classmethod
async def create(
Expand Down Expand Up @@ -221,7 +221,7 @@ async def _create_genomic_table(self) -> None:
WHERE table_schema = '{self.schema}'
AND table_name = 'genomic'
);
""" # noqa: S608
"""
genomic_table_exists = await self.execute_query(check_table_exists)
genomic_table_exists = genomic_table_exists[0].get("exists")
if genomic_table_exists is None:
Expand Down Expand Up @@ -250,7 +250,7 @@ async def _create_genomic_table(self) -> None:
LEFT JOIN {self.schema}.exon_aln ea ON
(((te.exon_id = ea.tx_exon_id) AND
(ae.exon_id = ea.alt_exon_id))));
""" # noqa: S608
"""
await self.execute_query(create_genomic_table)

indexes = [
Expand Down Expand Up @@ -499,7 +499,7 @@ async def get_tx_exon_aln_v_data(
AND {start_pos} BETWEEN {pos_q}
AND {end_pos} BETWEEN {pos_q}
{order_by_cond}
""" # noqa: S608
"""
result = await self.execute_query(query)
if not result:
_logger.warning("Unable to find transcript alignment for query: %s", query)
Expand Down Expand Up @@ -852,8 +852,8 @@ async def get_chr_assembly(self, ac: str) -> tuple[str, Assembly] | None:

try:
assembly = Assembly(assembly)
except ValueError as e:
_logger.error(e)
except ValueError:
_logger.exception("Unable to parse %s as an Assembly", assembly)
return None

return chromosome, assembly
Expand Down Expand Up @@ -924,11 +924,11 @@ def get_secret() -> str:

try:
get_secret_value_response = client.get_secret_value(SecretId=secret_name)
except ClientError as e:
except ClientError:
# For a list of exceptions thrown, see
# https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html
_logger.error(e)
raise e
_logger.exception("Encountered AWS client error fetching UTA DB secret")
raise
else:
return get_secret_value_response["SecretString"]

Expand Down
14 changes: 7 additions & 7 deletions tests/mappers/test_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _expected(assembly):
return _expected


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_get_cds_start(test_alignment_mapper):
"""Test that _get_cds_start method works correctly"""
# Valid
Expand All @@ -125,7 +125,7 @@ async def test_get_cds_start(test_alignment_mapper):
assert w == "Accession NM_004333.6293702 not found in UTA db"


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_p_to_c(test_alignment_mapper, braf_v600e_c, egfr_l858r_c):
"""Test that p_to_c works as expected"""
# BRAF V600E
Expand Down Expand Up @@ -164,7 +164,7 @@ async def test_p_to_c(test_alignment_mapper, braf_v600e_c, egfr_l858r_c):
}


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_p_to_c_invalid(test_alignment_mapper):
"""Test invalid queries for p_to_c method"""
# Invalid protein accession
Expand All @@ -175,7 +175,7 @@ async def test_p_to_c_invalid(test_alignment_mapper):
assert resp is None


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_c_to_g(
test_alignment_mapper,
braf_v600e_grch37,
Expand Down Expand Up @@ -227,7 +227,7 @@ async def test_c_to_g(
assert resp == expected, params


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_c_to_g_invalid(test_alignment_mapper):
"""Test invalid queries for c_to_g method"""
# Should not expect to find anything given these two positions
Expand Down Expand Up @@ -262,7 +262,7 @@ async def test_c_to_g_invalid(test_alignment_mapper):
assert w == "c_start_pos and c_end_pos are not a valid range for the codon(s)"


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_p_to_g(
test_alignment_mapper,
braf_v600e_grch37,
Expand Down Expand Up @@ -350,7 +350,7 @@ async def test_p_to_g(
assert resp == hras_t2a(assembly), params


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_p_to_g_invalid(test_alignment_mapper):
"""Test invalid queries for p_to_g method"""
# Invalid protein accession
Expand Down
Loading