Skip to content

Commit

Permalink
fixing error message
Browse files Browse the repository at this point in the history
  • Loading branch information
idalindegaard committed Jan 4, 2024
1 parent d6376e4 commit b637c16
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cg_lims/EPPs/udf/calculate/pool_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from cg_lims.get.artifacts import get_artifacts

LOG = logging.getLogger(__name__)

failed_samples = []

def get_final_concentration(process: Process, final_concentration_udf: str) -> float:
"""Return final concentration value from process."""
Expand Down Expand Up @@ -49,15 +49,21 @@ def get_total_volume(artifact: Artifact, total_volume_udf: str) -> float:


def calculate_sample_volume(
final_concentration: float, total_volume: float, sample_concentration: float
final_concentration: float, artifact: Artifact
) -> float:
"""Calculate and return the sample volume needed to reach the desired final concentration."""
sample_concentration: float = get_artifact_concentration(
artifact=artifact, concentration_udf=concentration_udf
)
total_volume: float = get_total_volume(artifact=artifact, total_volume_udf=total_volume_udf)
if final_concentration > sample_concentration:
error_message: str = (
f"The final concentration ({final_concentration} nM) is"
f" higher than the original one ({sample_concentration} nM). No dilution needed."
)
LOG.error(error_message)
global failed_samples
failed_samples = failed_samples.append(artifact.samples[0].id)
return total_volume
return (final_concentration * total_volume) / sample_concentration

Expand Down Expand Up @@ -119,6 +125,10 @@ def pool_normalization(ctx: click.Context):
buffer_volume_udf="Volume Buffer (ul)",
concentration_udf="Concentration (nM)",
)
if failed_samples:
error_message = f"The following samples had a lower concentration than targeted: {failed_samples}"
LOG.info(error_message)
raise InvalidValueError(error_message)
message: str = "Volumes were successfully calculated."
LOG.info(message)
click.echo(message)
Expand Down

0 comments on commit b637c16

Please sign in to comment.