Skip to content

Commit

Permalink
Move to pyproject.toml, python=3.11, Ruff pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bede committed Nov 17, 2023
1 parent 91fb933 commit 7d73c0e
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.t linguist-detectable=false
*.ctl linguist-detectable=false
*.html linguist-detectable=false

*.t linguist-detectable=false
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.9, 3.11]
python-version: [3.11]
name: Python ${{ matrix.python-version }} (${{ matrix.os }})
steps:
- uses: actions/checkout@v2
Expand All @@ -19,10 +19,8 @@ jobs:
conda-channels: bioconda
- name: Install
run: |
conda install paml datrie
pip install --upgrade pip setuptools wheel
pip install pytest
pip install .
conda env create -f environment.yml
pip install '.[dev]'
- name: Test
run: |
pytest -s --slow
Expand Down
19 changes: 9 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.5
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If the conda package manager is already installed, skip this step, otherwise:

An `x86_64` Miniconda installation is required in order to install Vespasian.

- If your Mac has an Intel processor, skip this step. Otherwise:
- If using a Mac with an Intel processor, skip this step. Otherwise:

```bash
arch -x86_64 zsh
Expand All @@ -45,7 +45,7 @@ An `x86_64` Miniconda installation is required in order to install Vespasian.

### Installing Vespasian

- If using a Mac with an Intel processor, skip this step. Otherwise, run:
- If using a Mac has an Intel processor, skip this step. Otherwise:

```bash
arch -x86_64 zsh
Expand All @@ -68,10 +68,10 @@ An `x86_64` Miniconda installation is required in order to install Vespasian.
### Development install

```bash
conda create -y -n vespasian-dev python=3.11 paml==4.10.6 pytest black pre-commit -c conda-forge -c bioconda
conda create -y -n vespasian-dev python=3.11 paml==4.10.6 -c conda-forge -c bioconda
conda activate vespasian-dev
git clone https://github.com/bede/vespasian
pip install --editable ./vespasian
pip install --editable './vespasian[dev]'
```


Expand Down
3 changes: 0 additions & 3 deletions pypi.sh

This file was deleted.

38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "vespasian"
authors = [{name = "Bede Constantinides", email = "bedeabc@gmail.com"}]
license = {file = "LICENSE"}
readme = "README.md"
dynamic = ["version", "description"]
requires-python = ">=3.11"
dependencies = [
"biopython>=1.78",
"treeswift==1.1.14",
"tqdm",
"argh",
"pyyaml",
"parmap",
"snakemake",
"pandas>=1.2.4",
"numpy>=1.20.2",
"scipy>=1.6.2"
]

[project.scripts]
vespasian = "vespasian.cli:main"

[project.optional-dependencies]
dev = [
"pytest>=7.4.3",
"pre-commit>=3.5.0",
"ruff>=0.1.5",
"flit>=3.9.0"
]

[tool.ruff]
# Ignore forward annotation syntax errors and ambiguous variable name
ignore = ["F722", "E741"]
38 changes: 0 additions & 38 deletions setup.py

This file was deleted.

1 change: 1 addition & 0 deletions vespasian/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
"""Genome scale evolutionary hypothesis testing"""
__version__ = "0.5.3"
1 change: 0 additions & 1 deletion vespasian/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import warnings

from math import ceil
from pprint import pprint

import argh

Expand Down
11 changes: 6 additions & 5 deletions vespasian/util.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import os
import shutil

import tqdm

from Bio import AlignIO, SeqIO
from Bio import SeqIO

from vespasian import vespasian


def convert_phylip(fasta_path, phylip_path):
"""Convert fasta to sequential phylip format"""
chunkify_string = lambda x, n: [x[i : i + n] for i in range(0, len(x), n)]

def chunkify_string(string, chunksize):
return [string[i : i + chunksize] for i in range(0, len(string), chunksize)]

records = list(SeqIO.parse(fasta_path, "fasta"))
indent_len = max(len(r.id) for r in records) + 2
indent_fmt = "\n" + " " * indent_len
Expand All @@ -27,7 +28,7 @@ def convert_phylip(fasta_path, phylip_path):

def reformat_environments(codeml_root):
"""Reformat vespasian codeml environments for use with legacy codeml_reader"""
codeml_envs = vespa.list_codeml_dirs(codeml_root)
codeml_envs = vespasian.list_codeml_dirs(codeml_root)
for env in codeml_envs:
convert_phylip(f"{env}/align.fa", f"{env}/align.phy")
shutil.copy(f"{env}/tree.nwk", f"{env}/tree")
4 changes: 1 addition & 3 deletions vespasian/vespasian.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
import parmap
import treeswift

import numpy as np
import pandas as pd

from Bio import AlignIO, SeqIO
from scipy.stats import chi2, chisquare
from scipy.stats import chi2

from vespasian import util

Expand Down Expand Up @@ -645,7 +644,6 @@ def filter_results(results):
r["model"],
) # Tuple-keyed dict of family-tree-model
# print(key)
# pprint(r)
if r["lnl"] > names_lnls[key]:
names_lnls[key] = r["lnl"]
names_records[key] = r
Expand Down

0 comments on commit 7d73c0e

Please sign in to comment.