Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Calculate Amount scripts for more flexibility #562

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Changes from 1 commit
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
15 changes: 10 additions & 5 deletions cg_lims/EPPs/udf/calculate/calculate_amount_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
@options.concentration_udf()
@options.amount_udf_option()
@options.volume_udf()
@options.subtract_volume_option()
@options.subtract_volume()
@options.preset_volume()
@options.measurement()
@options.input()
@click.pass_context
Expand All @@ -25,12 +26,14 @@ def calculate_amount_ng(
volume_udf: str,
concentration_udf: str,
subtract_volume: str,
preset_volume: float,
measurement: bool = False,
input: bool = False,
):
"""Calculates and auto-fills the quantities of DNA in sample from concentration and volume
measurements. The volume is subtracted by either 0 or 3 in the calculations. This is
because the lab uses 0 or 3 ul in the initial qc measurements."""
measurements. The volume can be subtracted by an optional specification in the cli. This is
because the lab uses some microliters of the sample in the qc measurements. A pre-set
volume can be set in the cli as well."""

LOG.info(f"Running {ctx.command_path} with params: {ctx.params}")

Expand All @@ -43,13 +46,15 @@ def calculate_amount_ng(
missing_udfs_count: int = 0
artifacts_with_missing_udf: List = []
for artifact in artifacts:
vol: float = artifact.udf.get(volume_udf)
if preset_volume:
vol = float(preset_volume)
elif volume_udf:
vol = artifact.udf.get(volume_udf)
conc: float = artifact.udf.get(concentration_udf)
if None in [conc, vol]:
missing_udfs_count += 1
artifacts_with_missing_udf.append(artifact.id)
continue

artifact.udf[amount_udf] = conc * (vol - int(subtract_volume))
artifact.put()
if missing_udfs_count:
Expand Down
Loading