Skip to content

Commit

Permalink
pull from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Zhang authored and Richard Zhang committed May 25, 2022
2 parents 40eb3f0 + 0bd3126 commit 8a3d4d9
Show file tree
Hide file tree
Showing 52 changed files with 207,907 additions and 614 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.py linguist-language=python
*.ipynb linguist-documentation
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -33,13 +33,11 @@ jobs:
- name: Install dependencies
run: |
pip install pytest-cov
pip install numpy
pip install Cython
pip install codecov
make install
pip install .
- name: Test with pytest
run: |
python -m pytest -vv test/ --cov-report=xml --cov=cassiopeia
pytest -vv test/ --cov-report=xml --cov=cassiopeia
- name: After success
run: |
codecov
Expand Down
155 changes: 155 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,156 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.DS_Store
.idea
*.pyc
Expand All @@ -10,3 +163,5 @@ build
*.c
stdout.log
notebooks/.ipynb_checkpoints
cassiopeia/tools/branch_length_estimator/_iid_exponential_bayesian.cpp
docs/api/reference/**
5 changes: 2 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ build:
sphinx:
configuration: docs/conf.py
python:
version: 3.6
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- docs
- requirements: docs/requirements.txt
- docs
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
include cassiopeia/preprocess/*.pyx
include cassiopeia/solver/*.pyx
include *.toml
include LICENSE
recursive-include cassiopeia *
18 changes: 3 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,12 @@ clean_sdist:

clean: clean_develop clean_pypi

install:
- $(python) setup.py build
- $(python) setup.py build_ext --inplace
- $(python) -m pip install --user .
install:
- $(python) -m pip install .

check_build_reqs:
@$(python) -c 'import pytest' \
|| ( printf "$(redpip)Build requirements are missing. Run 'make prepare' to install them.$(normal)" ; false )

test: check_build_reqs
$(python) -m pytest -vv $(tests)


pypi: clean clean_sdist
set -x \
&& $(python) setup.py sdist bdist_wheel \
&& twine check dist/* \
&& twine upload --repository-url https://test.pypi.org/legacy/ dist/*

clean_pypi:
- rm -rf build/
$(python) -m pytest -vv $(tests)
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,31 @@ Free Software: MIT License
Installation
--------------

For users:

```
pip install git+https://github.com/YosefLab/Cassiopeia@master#egg=cassiopeia-lineage
```

For developers:

1. Clone the package as so: ``git clone https://github.com/YosefLab/Cassiopeia.git``

2. Ensure that you have python3.6 installed. You can install this via pip.
2. Ensure that you have Python >= 3.7 installed. (Python 3.6 may still work, but is not guaranteed.) We prefer using [miniconda](https://docs.conda.io/en/latest/miniconda.html).

3. Make sure that Gurobi is installed. You can follow the instructions listed [here](http://www.gurobi.com/academia/for-universities). To verify that it's working correctly, use the following tests:
3. [Optional] Make sure that Gurobi is installed. You can follow the instructions listed [here](http://www.gurobi.com/academia/for-universities). To verify that it's working correctly, use the following tests:
* Run the command ``gurobi.sh`` from a terminal window
* From the Gurobi installation directory (where there is a setup.py file), use ``python setup.py install --user``
4. Install Cassiopeia by first making sure you have stable version of `Cython` and `pytest`. Then, you can install Cassiopeia by running `make install` from the directory where you have Cassiopeia downloaded.
To verify that it installed correctly, try running our tests with `make test`.

4. Install Cassiopeia by first changing into the Cassiopeia directory and then `pip3 install .`. To install dev and docs requirements, you can run `pip3 install .[dev,docs]`.

To verify that it installed correctly, try running our tests with `pytest`.

Reference
----------------------

If you've found Cassiopeia useful for your research, please consider citing our paper published in Genome Biology:


```
Matthew G Jones*, Alex Khodaverdian*, Jeffrey J Quinn*, Michelle M Chan, Jeffrey A Hussmann, Robert Wang, Chenling Xu, Jonathan S Weissman, Nir Yosef. (2020), [*Inference of single-cell phylogenies from lineage tracing data using Cassiopeia*](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-020-02000-8), Genome Biology
```
61 changes: 61 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os
import shutil
from distutils.command.build_ext import build_ext
from distutils.core import Distribution, Extension

import numpy
from Cython.Build import cythonize

# https://github.com/mdgoldberg/poetry-cython-example


def build():
extensions = [
Extension(
"cassiopeia.preprocess.collapse_cython",
["cassiopeia/preprocess/collapse_cython.pyx"],
),
Extension(
"cassiopeia.solver.ilp_solver_utilities",
["cassiopeia/solver/ilp_solver_utilities.pyx"],
include_dirs=[numpy.get_include()],
),
Extension(
"cassiopeia.tools.branch_length_estimator._iid_exponential_bayesian",
sources=[
"cassiopeia/tools/branch_length_estimator/_iid_exponential_bayesian.pyx",
"cassiopeia/tools/branch_length_estimator/_iid_exponential_bayesian_cpp.cpp",
],
extra_compile_args=[
"-std=c++17",
"-Wall",
"-Wextra",
"-pedantic",
"-O3",
],
language="c++",
),
]
ext_modules = cythonize(
extensions,
compiler_directives={"language_level": 3},
)

distribution = Distribution({"name": "extended", "ext_modules": ext_modules})
distribution.package_dir = "extended"

cmd = build_ext(distribution)
cmd.ensure_finalized()
cmd.run()

# Copy built extensions back to the project
for output in cmd.get_outputs():
relative_extension = os.path.relpath(output, cmd.build_lib)
shutil.copyfile(output, relative_extension)
mode = os.stat(relative_extension).st_mode
mode |= (mode & 0o444) >> 2
os.chmod(relative_extension, mode)


if __name__ == "__main__":
build()
29 changes: 20 additions & 9 deletions cassiopeia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@

"""Top-level for Cassiopeia development."""

package_name = "cassiopeia"
__author__ = "Matt Jones, Alex Khodaveridan, Richard Zhang, Sebastian Prillo"
__email__ = "mattjones315@berkeley.edu"
__version__ = "0.0.1"

from . import pp
from . import preprocess as pp
from . import solver
from . import pl
from . import plotting as pl
from . import data
from . import critique
from . import sim
from . import tl
from . import simulator as sim
from . import tools as tl

# https://github.com/python-poetry/poetry/pull/2366#issuecomment-652418094
# https://github.com/python-poetry/poetry/issues/144#issuecomment-623927302
try:
import importlib.metadata as importlib_metadata
except ModuleNotFoundError:
import importlib_metadata
package_name = "cassiopeia-lineage"
__version__ = importlib_metadata.version(package_name)

import sys

sys.modules.update({f"{__name__}.{m}": globals()[m] for m in ["tl", "pp", "pl", "sim"]})
del sys

__all__ = ["pp", "solver", "pl", "data", "critique", "sim", "tl"]
4 changes: 0 additions & 4 deletions cassiopeia/critique/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"""Top level for the cassiopeia critique module."""

__author__ = "Matt Jones, Richard Zhang"
__email__ = "mattjones315@berkeley.edu"
__version__ = "0.0.1"

from .compare import robinson_foulds, triplets_correct
4 changes: 4 additions & 0 deletions cassiopeia/mixins/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,9 @@ class TreeMetricError(Exception):

class ParameterEstimateError(Exception):
"""An Exception class for the estimation and retrieval of tree parameters"""

pass


class PlottingError(Exception):
pass
Loading

0 comments on commit 8a3d4d9

Please sign in to comment.