Skip to content

Commit

Permalink
Release v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gfrn committed May 14, 2024
1 parent c2b5884 commit 7159208
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog
==========

+++++++++
v1.6.0 (14/05/2024)
+++++++++

**Added**

- B Factor fit plot (:code:`/{autoProcId}/bFactorFit`)

+++++++++
v1.5.0 (25/03/2024)
+++++++++
Expand Down
4 changes: 2 additions & 2 deletions src/pato/auth/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def movie(movieId: int) -> int:
return movieId

@staticmethod
def autoproc_program(autoProcProgramId: int) -> int:
return autoProcProgramId
def autoproc_program(autoProcId: int) -> int:
return autoProcId

@staticmethod
def processing_job(processingJobId: int) -> int:
Expand Down
20 changes: 19 additions & 1 deletion src/pato/crud/autoproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from lims_utils.models import Paged
from lims_utils.tables import (
CTF,
BFactorFit,
CryoemInitialModel,
MotionCorrection,
Movie,
Expand All @@ -17,7 +18,7 @@
from lims_utils.tables import (
t_ParticleClassification_has_CryoemInitialModel as ParticleClassificationHasCryoem,
)
from sqlalchemy import UnaryExpression, and_, or_, select
from sqlalchemy import UnaryExpression, and_, func, or_, select

from ..models.response import (
Classification,
Expand Down Expand Up @@ -102,6 +103,23 @@ def get_particle_picker(autoProcId: int, filterNull: bool, limit: int, page: int
}


def get_b_factor_fit(autoProcId: int):
query = (
(
select(
func.ln(BFactorFit.numberOfParticles).label("numberOfParticles"),
(1 / func.pow(BFactorFit.resolution, 2)).label("resolution"),
)
.select_from(ParticleClassificationGroup)
.filter(ParticleClassificationGroup.programId == autoProcId)
)
.join(ParticleClassification)
.join(BFactorFit)
)

return db.session.execute(query).all()


def get_classification(
autoProcId: int,
limit: int,
Expand Down
5 changes: 5 additions & 0 deletions src/pato/models/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,8 @@ class IceThicknessWithAverage(OrmBaseModel):

class ReprocessingResponse(BaseModel):
processingJobId: int


class BFactorFitOut(BaseModel):
numberOfParticles: float
resolution: float
7 changes: 7 additions & 0 deletions src/pato/routes/autoproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ..crud import autoproc as crud
from ..crud import generic
from ..models.response import (
BFactorFitOut,
Classification,
CtfBaseSpa,
FullMovie,
Expand Down Expand Up @@ -151,3 +152,9 @@ def get_particle_count(
return generic.get_particle_count(
parent_type="autoProc", parent_id=autoProcId, minimum=minimum, dataBin=dataBin
)


@router.get("/{autoProcId}/bFactorFit", response_model=ItemList[BFactorFitOut])
def get_b_factor_fit(autoProcId: int = Depends(auth)):
"""Get B factor fit data"""
return ItemList(items=crud.get_b_factor_fit(autoProcId=autoProcId))
13 changes: 13 additions & 0 deletions tests/autoproc/test_b_factor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def test_get_user(mock_permissions, client):
"""Get B factor fit data for an autoprocessing program"""
resp = client.get("/autoProc/56986680/bFactorFit")
assert resp.status_code == 200
assert len(resp.json()["items"]) == 1


def test_get_minimum(mock_permissions, client):
"""Get B Factor fit data for an autoprocessing program that does not have
B factor fit data"""
resp = client.get("/autoProc/56425592/bFactorFit")
assert resp.status_code == 200
assert len(resp.json()["items"]) == 0

0 comments on commit 7159208

Please sign in to comment.