Skip to content

Commit 5f2cfc3

Browse files
committed
Merge v1a, support commented BEDs
1 parent 432f97a commit 5f2cfc3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+6550
-1507
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
matrix:
88
os: [ubuntu-latest, macos-latest]
9-
python-version: ["3.10", "3.11"]
9+
python-version: ["3.11"]
1010
name: Python ${{ matrix.python-version }} (${{ matrix.os }})
1111
steps:
1212
- uses: actions/checkout@v3
@@ -16,11 +16,9 @@ jobs:
1616
python-version: ${{ matrix.python-version }}
1717
- name: Install dependencies
1818
run: |
19-
python -m pip install pytest
20-
python -m pip install .
21-
git clone https://github.com/pha4ge/primer-schemes.git
19+
python -m pip install '.[dev]'
2220
- name: Test with pytest
21+
env:
22+
PRIMASCHEMA_ROOT_PATH: ${{ github.workspace }}
2323
run: |
2424
pytest
25-
env:
26-
PRIMER_SCHEMES_PATH: "${{ github.workspace }}/primer-schemes"

.pre-commit-config.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.2.0
4-
hooks:
5-
- id: check-yaml
6-
- id: end-of-file-fixer
7-
- id: trailing-whitespace
8-
- repo: https://github.com/psf/black
9-
rev: 22.3.0
10-
hooks:
11-
- id: black
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.4.4
4+
hooks:
5+
- id: ruff
6+
args: [ --fix ]
7+
- id: ruff-format

README.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
# Primaschema
44

5-
The toolkit for validating and building tiling amplicon PCR primer scheme definitions for inclusion in the [PHA4GE primer-schemes repository](https://github.com/pha4ge/primer-schemes), using 6 or 7 column Primal Scheme-like BED files and scheme metadata contained in a YAML file.
5+
**🚨 Migration to v1 scheme specification in progress**
66

7+
A toolkit for fetching, validating and interrogating tiled amplicon PCR primer scheme definitions. Provides convenient programmatic accesss to the [PHA4GE primer-schemes repository](https://github.com/pha4ge/primer-schemes), a community repository of tiled amplicons primer schemes.
78

89

9-
## Install (Python 3.10+)
10+
## Install (Python 3.8+)
1011

11-
```
12+
```shell
1213
# Latest stable release
1314
pip install primaschema
1415

@@ -19,13 +20,14 @@ pip install ./primaschema
1920
# Development
2021
git clone https://github.com/pha4ge/primaschema.git
2122
cd primaschema
22-
pip install --editable ./
23+
pip install --editable '.[dev]'
24+
pre-commit install
2325
pytest
2426
```
2527

2628
Some Primaschema commands use components from the [primer-schemes](https://github.com/pha4ge/primer-schemes) repository. To show Primaschema where to find these, create the environment variable `PRIMER_SCHEMES_PATH` pointing to the location of the primer-schemes directory on your machine:
2729

28-
```
30+
```shell
2931
git clone https://github.com/pha4ge/primer-schemes.git
3032
export PRIMER_SCHEMES_PATH="/path/to/primer-schemes"
3133
```
@@ -35,32 +37,28 @@ export PRIMER_SCHEMES_PATH="/path/to/primer-schemes"
3537
## Usage
3638

3739
```
38-
% primaschema --help
40+
% primaschema -h
3941
usage: primaschema [-h] [--version]
40-
{hash-ref,hash-bed,validate,validate-recursive,build,build-recursive,build-manifest,diff,6to7,7to6,show-non-ref-alts}
41-
...
42+
{validate,build,build-manifest,hash-ref,hash-bed,diff,6to7,7to6,plot,show-intervals,show-discordant-primers,subset,sync} ...
4243
4344
positional arguments:
44-
{hash-ref,hash-bed,validate,validate-recursive,build,build-recursive,build-manifest,diff,6to7,7to6,show-non-ref-alts}
45+
{validate,build,build-manifest,hash-ref,hash-bed,diff,6to7,7to6,plot,show-intervals,show-discordant-primers,subset,sync}
46+
validate Validate one or more primer scheme definitions comprising info.yml, primer.bed and reference.fasta
47+
build Build one or more primer scheme definitions comprising info.yml, primer.bed and reference.fasta
48+
build-manifest Build a complete manifest of schemes contained in the specified directory
4549
hash-ref Generate reference sequence checksum
4650
hash-bed Generate a bed file checksum
47-
validate Validate a primer scheme bundle containing info.yml, primer.bed and reference.fasta
48-
validate-recursive Recursively validate primer scheme bundles in the specified directory
49-
build Build a primer scheme bundle containing info.yml, primer.bed and reference.fasta
50-
build-recursive Recursively build primer scheme bundles in the specified directory
51-
build-manifest Build a complete manifest of schemes contained in the specified directory
5251
diff Show the symmetric difference of records in two bed files
53-
6to7 Convert a 6 column scheme.bed file to a 7 column primer.bed file using a reference sequence
54-
7to6 Convert a 7 column primer.bed file to a 6 column scheme.bed file by droppign a column
55-
show-non-ref-alts Show primer records with sequences not matching the reference sequence
52+
6to7 Convert a 6 column scheme.bed file to a 7 column primer.bed file using reference backfill
53+
7to6 Convert a 7 column primer.bed file to a 6 column scheme.bed file by removing a column
54+
plot Plot amplicon and primer coords from 7 column primer.bed
55+
show-intervals Show amplicon start and end coordinates given a BED file of primer coordinates
56+
show-discordant-primers
57+
Show primer records with sequences not matching the reference sequence
58+
subset Extract a primer.bed and reference.fasta scheme subset for a single chromosome
59+
sync Retrieve/update local copy of remote primer scheme repository
5660
5761
options:
5862
-h, --help show this help message and exit
5963
--version show program's version number and exit
60-
61-
62-
% primaschema build test/data/primer-schemes/eden/v1
63-
INFO: Scheme bed file has the expected number of columns (6)
64-
INFO: Writing info.yml with checksums
65-
INFO: Generating primer.bed from scheme.bed and reference.fasta
6664
```

pyproject.toml

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
[build-system]
2-
requires = [
3-
"setuptools >= 64",
4-
"wheel >= 0.37.1",
5-
]
6-
build-backend = "setuptools.build_meta"
2+
requires = ["flit_core >=3.2,<4"]
3+
build-backend = "flit_core.buildapi"
74

85
[project]
96
name = "primaschema"
10-
description = "A toolkit for primer scheme defintions"
7+
authors = [
8+
{name = "Bede Constantinides", email="[email protected]"},
9+
{name = "Peter van Heusden", email="[email protected]"}
10+
]
11+
dynamic = ["version", "description"]
1112
readme = "README.md"
12-
requires-python = ">=3.10"
13+
requires-python = ">=3.8"
1314
keywords = ["genomics"]
1415
license = {text = "MIT License"}
1516
classifiers = [
1617
"Framework :: Django",
17-
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.12",
1819
"Environment :: Console",
1920
"Intended Audience :: Science/Research",
2021
"License :: OSI Approved :: MIT License",
@@ -23,21 +24,33 @@ classifiers = [
2324
"Operating System :: MacOS",
2425
]
2526
dependencies = [
26-
"biopython == 1.80",
27-
"defopt == 6.4.0",
28-
"pandas >= 1.5.3",
29-
"pre-commit",
30-
"pytest",
27+
"altair>=5.3.0",
28+
"biopython>=1.80",
29+
"defopt==6.4.0",
30+
"httpx>=0.27.0",
3131
"jsonschema",
32-
"pyyaml",
33-
"linkml==1.5.2",
32+
"linkml",
33+
"natsort>=8.4.0",
34+
"pandas>=1.5.3",
35+
"platformdirs>=4.2.2",
36+
"pydantic>=2.0.0",
37+
"pyyaml>=6.0.2",
38+
"vl-convert-python>=1.6.0"
3439
]
35-
dynamic = ["version"]
40+
3641
[project.scripts]
3742
primaschema = "primaschema.cli:main"
3843

39-
[tool.setuptools.dynamic]
40-
version = {attr = "primaschema.__version__"}
44+
[project.urls]
45+
Home = "https://github.com/pha4ge/primaschema"
46+
47+
[project.optional-dependencies]
48+
dev = [
49+
"pytest",
50+
"pre-commit",
51+
"flit"
52+
]
53+
54+
[tool.flit.external-data]
55+
directory = "test"
4156

42-
[tool.setuptools.packages.find]
43-
where = ["src"]

src/primaschema/__init__.py

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,64 @@
1+
"""Infrastructure for tiled amplicon PCR primer scheme definitions"""
2+
3+
import logging
4+
import logging.config
5+
import os
6+
17
from pathlib import Path
28

3-
__version__ = "0.2.0"
9+
from platformdirs import user_data_dir
10+
11+
12+
__version__ = "1.0.0a0"
13+
14+
15+
SCHEMES_ARCHIVE_URL = os.environ.get(
16+
"PRIMASCHEMA_SCHEMES_ARCHIVE_URL",
17+
"https://github.com/pha4ge/primer-schemes/archive/refs/heads/main.tar.gz",
18+
)
19+
CACHE_DIR = Path(
20+
os.environ.get("PRIMASCHEMA_CACHE_DIR") or user_data_dir("primaschema", "PHA4GE")
21+
)
22+
23+
PKG_DIR = Path(
24+
os.environ.get(
25+
"PRIMASCHEMA_ROOT_PATH", Path(__file__).absolute().parent.parent.parent
26+
)
27+
)
28+
SCHEMA_DIR = PKG_DIR / "src" / "primaschema" / "schema"
29+
MANIFEST_SCHEMA_PATH = SCHEMA_DIR / "manifest.json"
30+
MANIFEST_HEADER_PATH = SCHEMA_DIR / "manifest-header.yml"
31+
32+
logging_config = {
33+
"version": 1,
34+
"disable_existing_loggers": False,
35+
"formatters": {
36+
"default": {
37+
"format": "%(name)s %(levelname)s: %(message)s",
38+
},
39+
},
40+
"handlers": {
41+
"console": {
42+
"class": "logging.StreamHandler",
43+
"formatter": "default",
44+
"level": "INFO",
45+
"stream": "ext://sys.stderr",
46+
},
47+
},
48+
"root": {
49+
"handlers": ["console"],
50+
"level": "INFO",
51+
},
52+
"loggers": {
53+
"primaschema": {
54+
"handlers": ["console"],
55+
"level": "INFO",
56+
"propagate": False,
57+
},
58+
},
59+
}
60+
61+
logging.config.dictConfig(logging_config)
62+
logger = logging.getLogger("primaschema")
463

5-
# pkg_dir = Path(__file__)
6-
# data_dir = pkg_dir.parent / "data"
64+
logger.debug(f"{PKG_DIR=} {SCHEMA_DIR=}")

0 commit comments

Comments
 (0)