From dc9ebcdbc6484696390430e4f2ba1bdad9dea6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Sv=C3=A4rd?= Date: Thu, 19 Dec 2024 17:56:18 +0100 Subject: [PATCH] black and isort --- cg_lims/EPPs/files/base.py | 2 +- cg_lims/EPPs/files/femtopulse_csv.py | 54 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/cg_lims/EPPs/files/base.py b/cg_lims/EPPs/files/base.py index a7909d12..6f0d142b 100644 --- a/cg_lims/EPPs/files/base.py +++ b/cg_lims/EPPs/files/base.py @@ -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 @@ -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) diff --git a/cg_lims/EPPs/files/femtopulse_csv.py b/cg_lims/EPPs/files/femtopulse_csv.py index 0aa0e987..6a0c34d4 100644 --- a/cg_lims/EPPs/files/femtopulse_csv.py +++ b/cg_lims/EPPs/files/femtopulse_csv.py @@ -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: @@ -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 = [] @@ -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) @@ -106,4 +108,4 @@ def make_femtopulse_csv( ) click.echo("The file was successfully generated.") except LimsError as e: - sys.exit(e.message) \ No newline at end of file + sys.exit(e.message)