Skip to content

Commit

Permalink
black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl-Svard committed Dec 19, 2024
1 parent b3ac980 commit dc9ebcd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cg_lims/EPPs/files/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import click
from cg_lims.EPPs.files.barcode_tubes import make_barcode_csv
from cg_lims.EPPs.files.csv_for_kapa_truble_shooting.csv_for_kapa_debug import trouble_shoot_kapa
from cg_lims.EPPs.files.femtopulse_csv import make_femtopulse_csv

# commands
from cg_lims.EPPs.files.file_to_udf import csv_well_to_udf
Expand All @@ -14,7 +15,6 @@
from cg_lims.EPPs.files.smrt_link.run_design import create_smrtlink_run_design
from cg_lims.EPPs.files.smrt_link.sample_setup import create_smrtlink_sample_setup
from cg_lims.EPPs.files.xml_to_udf import parse_run_parameters
from cg_lims.EPPs.files.femtopulse_csv import make_femtopulse_csv


@click.group(invoke_without_command=True)
Expand Down
54 changes: 28 additions & 26 deletions cg_lims/EPPs/files/femtopulse_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@

import click
import pandas as pd
from genologics.lims import Artifact

from cg_lims import options
from cg_lims.exceptions import InvalidValueError, LimsError
from cg_lims.get.artifacts import get_artifacts
from genologics.lims import Artifact

LOG = logging.getLogger(__name__)

ROWS = list(range(1,13)) # List numbered 1 to 12
WELL_POSITIONS = [f"A{i}" for i in range(1,13)] # List with well positions A1-A12
SAMPLE_NAMES = [""] * 12 # List with twelve empty positions for sample names
ROWS = list(range(1, 13)) # List numbered 1 to 12
WELL_POSITIONS = [f"A{i}" for i in range(1, 13)] # List with well positions A1-A12
SAMPLE_NAMES = [""] * 12 # List with twelve empty positions for sample names


def parse_well(artifact_position: str) -> str:
Expand All @@ -27,12 +26,9 @@ def parse_well(artifact_position: str) -> str:
return None


def get_data_and_write(
artifacts: List[Artifact],
file: str
):
"""Make a csv file for a Femtopulse run start with three columns:
one numbered 1-12, one with the sample position/well for the run and
def get_data_and_write(artifacts: List[Artifact], file: str):
"""Make a csv file for a Femtopulse run start with three columns:
one numbered 1-12, one with the sample position/well for the run and
a column with the sample name or ladder (in the 12th position)."""

failed_samples: list = []
Expand All @@ -52,35 +48,41 @@ def get_data_and_write(
if index < 11:
SAMPLE_NAMES[index] = artifact_name
else:
failed_samples.append({"artifact_name": artifact_name,
"parsed_well": parsed_well,
"error": "This position is reserved for the ladder."})
failed_samples.append(
{
"artifact_name": artifact_name,
"parsed_well": parsed_well,
"error": "This position is reserved for the ladder.",
}
)
else:
failed_samples.append({"artifact_name": artifact_name,
"parsed_well": parsed_well,
"error": "Position is not possible for the run."})
failed_samples.append(
{
"artifact_name": artifact_name,
"parsed_well": parsed_well,
"error": "Position is not possible for the run.",
}
)

# Prints out error message(s)
if failed_samples:
error_index: int = 0
for sample in failed_samples:
error_message: str = f"Sample {sample['artifact_name']} in position {sample['parsed_well']}: {sample['error']}"
error_message: str = (
f"Sample {sample['artifact_name']} in position {sample['parsed_well']}: {sample['error']}"
)
if error_index < 1:
all_errors: str = error_message
error_index =+ 1
error_index = +1
else:
all_errors = all_errors + ' ' + error_message
all_errors = all_errors + " " + error_message
raise InvalidValueError(f"Errors found: {all_errors}")

# The ladder will always be in well A12
SAMPLE_NAMES[-1] = "ladder"

# Create the csv file
df = pd.DataFrame({
0: ROWS,
1: WELL_POSITIONS,
2: SAMPLE_NAMES
})
df = pd.DataFrame({0: ROWS, 1: WELL_POSITIONS, 2: SAMPLE_NAMES})
df.to_csv(Path(file), index=False, header=False)


Expand All @@ -106,4 +108,4 @@ def make_femtopulse_csv(
)
click.echo("The file was successfully generated.")
except LimsError as e:
sys.exit(e.message)
sys.exit(e.message)

0 comments on commit dc9ebcd

Please sign in to comment.