Skip to content

Commit

Permalink
Updated to integrate scripts and transition over to using versioningi…
Browse files Browse the repository at this point in the history
…t for version control
  • Loading branch information
alexholehouse committed Oct 22, 2024
1 parent c528e66 commit c5e2059
Show file tree
Hide file tree
Showing 20 changed files with 120 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ __pycache__/
*~

metapredict/tests/test_cli/output/*
!metapredict/tests/test_cli/output/readme.txt


# cython-specific stuff
metapredict/backend/cython/domain_definition.c
Expand Down
7 changes: 6 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ include LICENSE
include MANIFEST.in

graft metapredict
global-exclude *.py[cod] __pycache__ *.so
graft metapredict/scripts
global-exclude *.py[cod] __pycache__ *.so

#recursive-include metapredict/backend/networks *
#recursive-exclude metapredict/backend/tests *

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ Emenecker, R. J., Griffith, D. & Holehouse, A. S. Metapredict V2: An update to m

For changes see the `changelog.md` file in this directory.

## Running tests
Note that to run tests you must compile the cython code in place. We suggest doing this by running the following set of commands:

pip uninstall metapredict; rm -rf build dist *.egg-info; python -m build; pip install .

## Acknowledgements

PARROT, created by Dan Griffith, was used to generate the network used for metapredict. See [https://pypi.org/project/idptools-parrot/](https://pypi.org/project/idptools-parrot/) for some very cool machine learning stuff.
Expand Down
16 changes: 16 additions & 0 deletions install_for_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/zsh
# This script cleans everything

# remove all previous build directories

echo "Deleting previous build directories, if present"
rm -rf build dist *.egg-info > /dev/null 2>&1

# remove cython files
echo "Deleting cython files, if present"
rm metapredict/backend/cython/*so > /dev/null 2>&1
rm metapredict/backend/cython/*c > /dev/null 2>&1

echo "Building the package"
python -m build
python setup.py build_ext --inplace
7 changes: 2 additions & 5 deletions metapredict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
import os
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("metapredict")
except PackageNotFoundError:
# package is not installed
pass
# import current version
from ._version import __version__

# To crash on LIBOMP error set this to False
IGNORE_LIBOMP_ERROR = True
Expand Down
1 change: 1 addition & 0 deletions metapredict/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "2.63+18.gc528e66.dirty"
Empty file added metapredict/scripts/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion scripts/metapredict-graph-disorder → ...ict/scripts/metapredict_graph_disorder.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from metapredict import meta


if __name__ == "__main__":
def main():

# Parse command line arguments.
parser = argparse.ArgumentParser(description='Generate disorder figures for all sequences in a FASTA file.')
Expand Down
2 changes: 1 addition & 1 deletion scripts/metapredict-graph-pLDDT → ...redict/scripts/metapredict_graph_pLDDT.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from metapredict import meta


if __name__ == "__main__":
def main():

# Parse command line arguments.
parser = argparse.ArgumentParser(description='Generate Alphafold2 pLDDT score figures for all sequences in a FASTA file.')
Expand Down
2 changes: 1 addition & 1 deletion scripts/metapredict-name → metapredict/scripts/metapredict_name.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from metapredict.backend.uniprot_predictions import seq_from_name
from getSequence import getseq

if __name__ == "__main__":
def main():

# Parse command line arguments.
parser = argparse.ArgumentParser(description='Predict intrinsic disorder from a protein name.')
Expand Down
2 changes: 1 addition & 1 deletion scripts/metapredict-predict-disorder → ...t/scripts/metapredict_predict_disorder.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import metapredict as meta


if __name__ == "__main__":
def main():

# Parse command line arguments.
parser = argparse.ArgumentParser(description='Generate disorder scores for all sequences in a FASTA file.')
Expand Down
6 changes: 1 addition & 5 deletions scripts/metapredict-predict-idrs → ...edict/scripts/metapredict_predict_idrs.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
import protfasta

from metapredict.meta import predict_disorder_batch



import metapredict as meta


if __name__ == "__main__":
def main():

# Parse command line arguments.
parser = argparse.ArgumentParser(description='Predict IDRs for all sequences in a FASTA file.')
Expand Down
3 changes: 1 addition & 2 deletions scripts/metapredict-predict-pLDDT → ...dict/scripts/metapredict_predict_pLDDT.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import os
import argparse


import metapredict as meta


if __name__ == "__main__":
def main():

# Parse command line arguments.
parser = argparse.ArgumentParser(description='Generate AlphaFold2 pLDDT scores for all sequences in a FASTA file.')
Expand Down
3 changes: 1 addition & 2 deletions scripts/metapredict-quick-graph → ...redict/scripts/metapredict_quick_graph.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

VALID_AA = ['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y']


if __name__ == "__main__":
def main():
# Parse command line arguments.
parser = argparse.ArgumentParser(description='Predict intrinsic disorder of amino acid sequences.')
parser.add_argument('sequence', help='The amino acid sequence to predict disorder for.')
Expand Down
2 changes: 1 addition & 1 deletion scripts/metapredict-quick-predict → ...dict/scripts/metapredict_quick_predict.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import argparse
import metapredict as meta

if __name__ == "__main__":
def main():
# Parse command line arguments.
parser = argparse.ArgumentParser(description='Predict intrinsic disorder of amino acid sequences.')
parser.add_argument('sequence', help='The amino acid sequence to predict disorder for.')
Expand Down
2 changes: 1 addition & 1 deletion scripts/metapredict-uniprot → metapredict/scripts/metapredict_uniprot.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from metapredict.metapredict_exceptions import MetapredictError
import metapredict as meta

if __name__ == "__main__":
def main():

# Parse command line arguments.
parser = argparse.ArgumentParser(description='Predict intrinsic disorder from a UniProt accession number.')
Expand Down
1 change: 1 addition & 0 deletions metapredict/tests/output/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory stores test output
65 changes: 43 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=61", "setuptools-scm>=8", "wheel", "cython", "numpy"]
requires = ["setuptools>=61", "cython", "numpy", "versioningit~=2.0"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -25,28 +25,49 @@ dependencies = [
"getSequence >= 1.6",
]

[project.scripts]
metapredict-graph-disorder = "scripts.metapredict_graph_disorder:main"
metapredict-predict-disorder = "scripts.metapredict_predict_disorder:main"
metapredict-quick-graph = "scripts.metapredict_quick_graph:main"
metapredict-quick-predict = "scripts.metapredict_quick_predict:main"
metapredict-uniprot = "scripts.metapredict_uniprot:main"
metapredict-predict-idrs = "scripts.metapredict_predict_idrs:main"
metapredict-graph-pLDDT = "scripts.metapredict_graph_pLDDT:main"
metapredict-predict-pLDDT = "scripts.metapredict_predict_pLDDT:main"
metapredict-name = "scripts.metapredict_name:main"

[tool.coverage.run]
omit = [
"*/tests/*",
[project.optional-dependencies]
test = [
"pytest>=6.1.2",
]

[tool.yapf]
column_limit = 119
indent_width = 4
use_tabs = false

[tool.flake8]
max-line-length = 119
[project.scripts]
metapredict-graph-disorder = "metapredict.scripts.metapredict_graph_disorder:main"
metapredict-predict-disorder = "metapredict.scripts.metapredict_predict_disorder:main"
metapredict-quick-graph = "metapredict.scripts.metapredict_quick_graph:main"
metapredict-quick-predict = "metapredict.scripts.metapredict_quick_predict:main"
metapredict-uniprot = "metapredict.scripts.metapredict_uniprot:main"
metapredict-predict-idrs = "metapredict.scripts.metapredict_predict_idrs:main"
metapredict-graph-pLDDT = "metapredict.scripts.metapredict_graph_pLDDT:main"
metapredict-predict-pLDDT = "metapredict.scripts.metapredict_predict_pLDDT:main"
metapredict-name = "metapredict.scripts.metapredict_name:main"

[tool.setuptools]
zip-safe = false
include-package-data = true

[tool.setuptools.packages.find]
namespaces = true
where = ["."]
include = ["metapredict", "metapredict.*"] # Discover all sub-packages under metapredict

[tool.setuptools.package-data]
metapredict = ["py.typed"]

[tool.versioningit]
default-version = "1+unknown"

[tool.versioningit.format]
distance = "{base_version}+{distance}.{vcs}{rev}"
dirty = "{base_version}+{distance}.{vcs}{rev}.dirty"
distance-dirty = "{base_version}+{distance}.{vcs}{rev}.dirty"

[tool.versioningit.vcs]
# The method key:
method = "git" # <- The method name
# Parameters to pass to the method:
match = ["*"]
default-tag = "1.0.0"

[tool.setuptools_scm]
[tool.versioningit.write]
file = "metapredict/_version.py"
22 changes: 22 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Helper file to handle all configs

[coverage:run]
# .coveragerc to control coverage.py and pytest-cov
omit =
# Omit the tests
*/tests/*
# Omit generated versioneer
metapredict/_version.py

[yapf]
# YAPF, in .style.yapf files this shows up as "[style]" header
COLUMN_LIMIT = 119
INDENT_WIDTH = 4
USE_TABS = False

[flake8]
# Flake8, PyFlakes, etc
max-line-length = 119

[aliases]
test = pytest
23 changes: 13 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
from Cython.Build import cythonize
import os
import numpy
from setuptools_scm import get_version

cython_file = os.path.join("metapredict", "backend", "cython", "domain_definition.pyx")

extensions = [
Extension(
name="metapredict.backend.cython.domain_definition",
sources=[cython_file],
include_dirs=[numpy.get_include()],
)
]

sources=[cython_file],
include_dirs=[numpy.get_include()],
)
]


setup(
ext_modules=cythonize(extensions, compiler_directives={'language_level': "3"}),
version=get_version(),
ext_modules = cythonize(extensions, compiler_directives={'language_level' : "3"}),
packages=find_packages(),
include_package_data=True,
)

# Optional include package data to ship with your package
# Customize MANIFEST.in if the general case does not suit your needs
# Comment out this line to prevent the files from being packaged with your software
include_package_data=True
)

0 comments on commit c5e2059

Please sign in to comment.