Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Python application

on:
push:
branches: [ "master", "develop"]
branches: [ "main", "develop", "CI-CD"]
pull_request:
branches: [ "master", "develop"]
branches: [ "main", "develop"]

permissions:
contents: read
Expand All @@ -19,22 +19,27 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pip install .[test] ruff

- name: Lint - fail on real issues
run: ruff check . --select F,E9

- name: Lint - style (non-blocking)
run: ruff check . --select E,B,I || true

## ADD LATER
# - name: Format check
# run: ruff format --check .

- name: Test with pytest
run: |
pytest
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ build/
*.tar
*.zip

# Unit test / coverage reports #
################################
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.*
*,cover

# Logs and databases #
######################
*.ipynb_checkpoints
Expand Down
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

default_language_version:
python: python3.11

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: debug-statements

- repo: https://github.com/rhysd/actionlint
rev: v1.7.0
hooks:
- id: actionlint
2 changes: 0 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import sys
sys.path.insert(0, os.path.abspath('../../src/perpl')) # Adjust to include your package

import sphinx_rtd_theme

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

Expand Down
7 changes: 4 additions & 3 deletions notebooks/make_ACTN2_Affimer_PERPL_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.19.2
# jupytext_version: 1.19.3
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
Expand All @@ -24,9 +24,10 @@
# ## Imports

import numpy as np
import pandas as pd
# import pandas as pd
import matplotlib.pyplot as plt
from perpl.modelling import modelling_general, zdisk_modelling, zdisk_plots
from perpl.modelling import zdisk_modelling, zdisk_plots
# from perpl.modelling import modelling_general
from perpl.io import plotting

# ## Set average estimated localisation precision for Affimer and PALM data.
Expand Down
4 changes: 1 addition & 3 deletions notebooks/make_Nup107_Z_PERPL_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.17.1
# jupytext_version: 1.19.3
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
Expand All @@ -29,7 +29,6 @@
import matplotlib.pyplot as plt

from perpl.modelling import modelling_general, two_layer_fitting, background_models
from perpl.statistics import modelstats
from perpl.statistics.modelstats import akaike_weights
# -

Expand Down Expand Up @@ -165,7 +164,6 @@
weights = akaike_weights([1.])
print(weights)

# + [markdown] jp-MarkdownHeadingCollapsed=true
# ## Plot model components

# +
Expand Down
4 changes: 2 additions & 2 deletions notebooks/make_mEos_LASP2andMYPN_PERPL_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.17.1
# jupytext_version: 1.19.3
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
Expand All @@ -27,7 +27,7 @@
import numpy as np
import matplotlib.pyplot as plt

from perpl.modelling import modelling_general, zdisk_modelling, zdisk_plots
from perpl.modelling import zdisk_modelling, zdisk_plots
from perpl.io import plotting
# -

Expand Down
29 changes: 25 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
requires = ["setuptools>=64.0", "setuptools-scm>=8.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]

[project]
name = "perpl"
version = "1.3.0"
# dynamic = ["version"]
authors = [
{ name="Alistair Curd", email="[email protected]" }
]
Expand Down Expand Up @@ -41,4 +38,28 @@ modeldistances = "perpl.run_distance_modelling:main"
Homepage = "https://github.com/AlistairCurd/PERPL-Python3"
Issues = "https://github.com/AlistairCurd/PERPL-Python3/issues"

# [tool.tox], [tox] ?

[project.optional-dependencies]
test = [
"pytest~=8.0",
"pytest-cov~=5.0"
]

dev = [
"perpl[test]",
"ruff~=0.4",
"pre-commit~=3.7"
]

[tool.pytest.ini_options]
addopts = "-v --color=yes --cov=perpl --cov-report=term --cov-report=xml --cov-report=html"

[tool.ruff]
line-length = 88
target-version = "py311"

[tool.ruff.lint]
select = ["E", "F", "B", "I"]

[tool.ruff.format]
quote-style = "double"
51 changes: 27 additions & 24 deletions src/perpl/modelling/centriole_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
"""

import time
from scipy.ndimage.filters import gaussian_filter
from scipy.io import loadmat
import numpy as np

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy.io import loadmat
from scipy.ndimage.filters import gaussian_filter

import perpl.modelling.modelling_general as models
from perpl.modelling.modelling_general import ModelWithFitSettings
from relative_positions import getdistances
from perpl.modelling.background_models import pair_correlation_disk
from perpl.modelling.modelling_general import ModelWithFitSettings
from perpl.relative_positions import getdistances


def get_input_data(
Expand Down Expand Up @@ -1030,7 +1031,7 @@ def make_fit_results_table_variable_vertices_model_9fold_no_bg(
# Populate the tables
max_fit_distance = len(distance_histograms_list[0])

for i, histogram in enumerate(distance_histograms_list):
for i, _ in enumerate(distance_histograms_list):
# Do the fit
(params_optimised, params_covar, params_1sd_error) = (
models.fit_model_to_experiment(
Expand Down Expand Up @@ -1158,7 +1159,8 @@ def main():
np.save(outfile_dist_hist_list, distance_histograms_list)

# Choose model
# model_with_info = set_up_variable_vertices_model_9fold_internal_bg_with_fit_settings()
# model_with_info = \
# set_up_variable_vertices_model_9fold_internal_bg_with_fit_settings()
model_with_info = set_up_variable_vertices_model_9fold_no_bg_with_fit_settings()

# Could modify the fit parameter settings here
Expand Down Expand Up @@ -1217,7 +1219,8 @@ def main():
)
)
# estimated_params_df.to_csv(
# 'C:/Temp/Centriole/5nm_precision_distance_histograms_normalised_parameter_estimates.csv',
# "C:/Temp/Centriole/"
# + "5nm_precision_distance_histograms_normalised_parameter_estimates.csv",
# index=False
# )

Expand Down Expand Up @@ -1258,14 +1261,14 @@ def main():
# model_with_info.vector_input_model)

# For model without internal background
stdev = plot_95_ci(
axes,
x_values,
model_with_info.model_rpd,
params_optimised,
params_covar,
model_with_info.vector_input_model,
)
# stdev = plot_95_ci(
# axes,
# x_values,
# model_with_info.model_rpd,
# params_optimised,
# params_covar,
# model_with_info.vector_input_model,
#)
axes.set_title(
"Centriole "
+ repr(i)
Expand Down Expand Up @@ -1309,14 +1312,14 @@ def main():
fitted_curve_values = model_with_info.model_rpd(x_values, *params_optimised)
axes.plot(x_values, fitted_curve_values, color="xkcd:red", lw=0.5)

stdev = plot_95_ci(
axes,
x_values,
model_with_info.model_rpd,
params_optimised,
params_covar,
model_with_info.vector_input_model,
)
# stdev = plot_95_ci(
# axes,
# x_values,
# model_with_info.model_rpd,
# params_optimised,
# params_covar,
# model_with_info.vector_input_model,
#)
axes.set_title("All centrioles")


Expand Down
15 changes: 9 additions & 6 deletions src/perpl/modelling/dna_paint_data_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@

"""

from scipy.optimize import curve_fit
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit

import perpl.modelling.modelling_general as models
import perpl.modelling.polyhedramodelling as poly
import perpl.statistics.modelstats as stats
import perpl.modelling.modelling_general as models
from perpl.modelling.modelling_general import ModelWithFitSettings
from perpl.modelling.modelling_general import stdev_of_model
from perpl.modelling.modelling_general import (
ModelWithFitSettings,
stdev_of_model,
)


def create_default_fitting_params_dicts():
Expand Down Expand Up @@ -937,7 +940,7 @@ def plot_model_components_tri_prism(
"""
distance_values = np.arange(0, fitlength + 1, 1)

fig = plt.figure()
fig = plt.figure() # noqa: F841 # Prefer OO style, but not worth changing atm.
axes = plt.subplot(111)
axes.set_xlim([0, fitlength])
axes.set_xlabel(r"$\Delta$XYZ (nm)")
Expand Down
22 changes: 11 additions & 11 deletions src/perpl/modelling/zdisk_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@
specific language governing permissions and limitations under the License.
"""

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.signal import find_peaks

import perpl.modelling.linearrepeatmodels as linmods
import perpl.modelling.zdisk_modelling as zdisk_modelling
from perpl.modelling.modelling_general import kde_1nm
from perpl.modelling.modelling_general import pairwise_correlation_1d
from perpl.modelling.modelling_general import stdev_of_model
from perpl.io.plotting import estimate_rpd_churchman_1d
from perpl.modelling.zdisk_modelling import read_relpos_from_pickles
from perpl.modelling.zdisk_modelling import getaxialseparations_no_smoothing
from perpl.modelling.zdisk_modelling import remove_duplicates
from perpl.modelling.zdisk_modelling import (
set_up_model_4_variable_peaks_with_fit_settings,
from perpl.modelling.modelling_general import (
kde_1nm,
pairwise_correlation_1d,
stdev_of_model,
)
from perpl.modelling.zdisk_modelling import (
fitmodel_to_hist,
getaxialseparations_no_smoothing,
# read_relpos_from_pickles,
remove_duplicates,
# set_up_model_4_variable_peaks_with_fit_settings,
set_up_model_5_variable_peaks_with_fit_settings,
)
from perpl.modelling.zdisk_modelling import fitmodel_to_hist


def plot_distance_hist(
Expand Down Expand Up @@ -80,7 +80,7 @@ def plot_distance_hist(
histaxes.set_ylim(bottom=0)
histaxes.set_title("Histogram")
histaxes.set_xlabel(
f"$\Delta$Axial (nm) ($\Delta$Transverse < {transverse_limit} nm)"
rf"$\Delta$Axial (nm) ($\Delta$Transverse < {transverse_limit} nm)"
)
histaxes.set_ylabel("Counts")
if close_plots:
Expand Down
Loading
Loading