Skip to content

Commit

Permalink
add pgscatalog.calc
Browse files Browse the repository at this point in the history
  • Loading branch information
nebfield committed Feb 3, 2025
1 parent 30b2ad2 commit 53accf9
Show file tree
Hide file tree
Showing 8 changed files with 1,199 additions and 1,132 deletions.
58 changes: 58 additions & 0 deletions pgscatalog.calc/noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import nox

nox.options.error_on_external_run = True
nox.options.default_venv_backend = "uv"


# test every version of python we support!
@nox.session
@nox.parametrize("python", ["3.12", "3.11", "3.10"])
def tests(session):
"""Run pytest for all supported python versions"""
session.run_install(
"uv",
"sync",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("pytest", "--ignore", "noxfile.py")


@nox.session
@nox.parametrize("python", ["3.10"])
def lint(session):
"""Run linting checks"""
# https://nox.thea.codes/en/stable/cookbook.html#using-a-lockfile
# note: uv is set up to install the test and lint dependency groups
session.run_install(
"uv",
"sync",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("ruff", "check")
session.run("mypy", ".")


@nox.session(default=False)
def coverage(session):
"""Run pytest and output a coverage report.
Not default for codecov.io integration with GitHub actions
"""
session.run_install(
"uv",
"sync",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("pytest", "--ignore", "noxfile.py", "--cov", "--cov-report", "xml")


# nox cookbook: https://nox.thea.codes/en/stable/cookbook.html
# It's a good idea to keep your dev session out of the default list
# so it's not run twice accidentally
@nox.session(default=False)
def dev(session: nox.Session) -> None:
"""
Set up a python development environment for the project at ".venv".
"""
session.run("uv", "venv")
session.run("uv", "sync")
1,106 changes: 0 additions & 1,106 deletions pgscatalog.calc/poetry.lock

This file was deleted.

3 changes: 0 additions & 3 deletions pgscatalog.calc/poetry.toml

This file was deleted.

89 changes: 68 additions & 21 deletions pgscatalog.calc/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,85 @@
[tool.poetry]
[project]
name = "pgscatalog.calc"
version = "0.3.0"
description = "Libraries and applications for working with calculated polygenic scores"
authors = ["Benjamin Wingfield <[email protected]>", "Samuel Lambert <[email protected]>", "Laurent Gil <[email protected]>"]
license = {text = "Apache License (2.0)"}
authors = [
{name = "Benjamin Wingfield", email = "[email protected]"},
{name = "Samuel Lambert", email = "[email protected]"},
{name = "Laurent Gil", email = "[email protected]"},
{name = "Florent Yvon", email = "[email protected]"}
]
readme = "README.md"
packages = [
{ include = "pgscatalog", from = "src" },
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

[tool.poetry.dependencies]
python = ">=3.10"
"pgscatalog.core" = "^0.3.1"
numpy = "^1.26.4"
pandas = "^2.2.0"
pyarrow = "^15.0.0"
scikit-learn = "^1.4.0"
scipy = "^1.12.0"
requires-python = ">=3.10"
dependencies = [
"numpy~=1.26",
"pandas~=2.2.0",
"pgscatalog-core>=0.3.3",
"pyarrow~=15.0.0",
"scikit-learn~=1.4",
"scipy~=1.12",
]

[tool.poetry.scripts]
# https://peps.python.org/pep-0621/
[project.scripts]
pgscatalog-aggregate = 'pgscatalog.calc.cli.aggregate_cli:run_aggregate'
pgscatalog-ancestry-adjust = 'pgscatalog.calc.cli.ancestry_cli:run_ancestry'

[tool.poetry.group.dev.dependencies]
pytest = "^8.0.0"
pytest-cov = "^4.1.0"
# https://peps.python.org/pep-0735/
[dependency-groups]
lint = [
"ruff>=0.9.4",
"mypy>=1.14.1"
]
test = [
"pytest>=8.3.4",
"pytest-coverage>=0.0",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[tool.hatch.build.targets.wheel]
packages = ["src"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q --doctest-modules"
minversion = "8.0"
addopts = "--doctest-modules"
filterwarnings = ["error"]
pythonpath = [
"src"
]
consider_namespace_packages = true

[tool.coverage.run]
source = ['src/pgscatalog/calc', "tests"]
source = ["src/pgscatalog/core", "tests"]
concurrency = ["multiprocessing"]
parallel = true
sigterm = true

[tool.uv]
default-groups = ["test", "lint"]

[tool.mypy]
files = ["src/**/*.py"]
warn_unused_configs = true
ignore_missing_imports = true
follow_imports = "silent"
disallow_untyped_calls = false
disallow_incomplete_defs = true

[tool.setuptools.packages.find]
where = ["src"]
1 change: 0 additions & 1 deletion pgscatalog.calc/src/pgscatalog/calc/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__all__ = []
2 changes: 2 additions & 0 deletions pgscatalog.calc/src/pgscatalog/calc/lib/_ancestry/read.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# mypy: ignore-errors

import logging
import pandas as pd

Expand Down
6 changes: 5 additions & 1 deletion pgscatalog.calc/src/pgscatalog/calc/lib/_ancestry/tools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# mypy: ignore-errors

import logging
import pandas as pd
import numpy as np
Expand Down Expand Up @@ -342,7 +344,9 @@ def pgs_adjust(
if np.var(results_ref[sum_col]) == 0:
scorecols_drop.add(c_pgs)
logger.warning(
"Skipping adjustment: {} has 0 variance in PGS SUM [REFERENCE]".format(c_pgs)
"Skipping adjustment: {} has 0 variance in PGS SUM [REFERENCE]".format(
c_pgs
)
)

# Report PGS values with respect to distribution of PGS in the most similar reference population
Expand Down
Loading

0 comments on commit 53accf9

Please sign in to comment.