From 44165ca8324519fc76d6371ca53ea72861590db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Sv=C3=A4rd?= <60181709+Karl-Svard@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:22:29 +0100 Subject: [PATCH] Format the entire repo with Black and iSort (#469)(patch) ### Fixed - the formatting of all the Python files in the repository --- cg_lims/EPPs/arnold/base.py | 3 +- cg_lims/EPPs/arnold/flow_cell.py | 7 +- cg_lims/EPPs/arnold/prep.py | 12 +- cg_lims/EPPs/arnold/sample.py | 6 +- cg_lims/EPPs/arnold/sequencing.py | 8 +- cg_lims/EPPs/base.py | 7 +- cg_lims/EPPs/files/barcode_tubes.py | 58 ++++----- cg_lims/EPPs/files/base.py | 8 +- .../csv_for_kapa_debug.py | 21 ++-- .../csv_for_kapa_truble_shooting/models.py | 3 +- cg_lims/EPPs/files/file_to_udf.py | 9 +- cg_lims/EPPs/files/hamilton/base.py | 4 +- .../hamilton/buffer_exchange_twist_file.py | 5 +- cg_lims/EPPs/files/hamilton/make_kapa_csv.py | 3 +- .../EPPs/files/hamilton/normalization_file.py | 3 +- .../files/hamilton/sars_cov2_prep_file.py | 5 +- .../make_96well_placement_map.py | 30 +++-- .../files/pooling_map/make_pooling_map.py | 9 +- .../files/sample_sheet/create_sample_sheet.py | 21 ++-- cg_lims/EPPs/files/sample_sheet/models.py | 7 +- cg_lims/EPPs/files/xml_to_udf.py | 11 +- cg_lims/EPPs/move/move_samples.py | 3 +- cg_lims/EPPs/move/rerun_samples.py | 5 +- cg_lims/EPPs/qc/models.py | 1 - .../EPPs/qc/sequencing_artifact_manager.py | 5 +- cg_lims/EPPs/qc/sequencing_quality_control.py | 6 +- cg_lims/EPPs/udf/base.py | 2 +- cg_lims/EPPs/udf/calculate/base.py | 21 ++-- .../calculate_average_size_and_set_qc.py | 10 +- cg_lims/EPPs/udf/calculate/calculate_beads.py | 2 +- .../calculate_microbial_aliquot_volumes.py | 7 +- .../calculate_resuspension_buffer_volumes.py | 7 +- .../calculate/calculate_water_volume_rna.py | 3 +- cg_lims/EPPs/udf/calculate/constants.py | 2 +- .../EPPs/udf/calculate/get_missing_reads.py | 5 +- .../udf/calculate/maf_calculate_volume.py | 5 +- .../EPPs/udf/calculate/molar_concentration.py | 7 +- .../udf/calculate/novaseq_x_denaturation.py | 13 +- .../EPPs/udf/calculate/novaseq_x_volumes.py | 13 +- .../EPPs/udf/calculate/pool_normalization.py | 8 +- .../udf/calculate/twist_aliquot_amount.py | 3 +- .../udf/calculate/twist_aliquot_volume.py | 3 +- .../twist_get_volumes_from_buffer.py | 3 +- cg_lims/EPPs/udf/calculate/twist_qc_amount.py | 3 +- cg_lims/EPPs/udf/check/check_artifact_udfs.py | 3 +- cg_lims/EPPs/udf/check/check_process_udfs.py | 3 +- .../aggregate_qc_flags_and_copy_fields.py | 34 +++-- cg_lims/EPPs/udf/copy/artifact_to_artifact.py | 16 ++- cg_lims/EPPs/udf/copy/artifact_to_sample.py | 1 - cg_lims/EPPs/udf/copy/base.py | 14 +-- .../EPPs/udf/copy/measurement_to_analyte.py | 13 +- .../EPPs/udf/copy/original_well_to_sample.py | 5 +- cg_lims/EPPs/udf/copy/process_to_artifact.py | 14 +-- cg_lims/EPPs/udf/copy/process_to_sample.py | 1 - cg_lims/EPPs/udf/copy/qc_to_sample.py | 1 - cg_lims/EPPs/udf/copy/reads_to_sequence.py | 9 +- cg_lims/EPPs/udf/copy/sample_to_artifact.py | 4 +- cg_lims/EPPs/udf/set/base.py | 9 +- .../udf/set/replace_flow_cell_output_path.py | 4 +- cg_lims/EPPs/udf/set/set_barcode.py | 21 ++-- cg_lims/EPPs/udf/set/set_method.py | 6 +- cg_lims/EPPs/udf/set/set_sample_date.py | 9 +- .../EPPs/udf/set/set_samples_reads_missing.py | 3 +- .../EPPs/udf/set/set_sequencing_settings.py | 11 +- cg_lims/commands/base.py | 6 +- cg_lims/files/manage_csv_files.py | 44 ++++--- cg_lims/get/artifacts.py | 11 +- cg_lims/get/samples.py | 5 +- cg_lims/get/udfs.py | 6 +- cg_lims/models/api/master_steps/__init__.py | 8 +- ...mples_for_enzymatic_fragmentation_twist.py | 9 +- .../bead_purification_twist_v2.py | 5 +- .../api/master_steps/buffer_exchange_v2.py | 5 +- .../master_steps/capture_and_wash_twist_v2.py | 5 +- .../hybridize_library_twist_v2.py | 9 +- .../kapa_library_preparation_twist_v1.py | 9 +- .../api/master_steps/pool_samples_twist_v2.py | 5 +- cg_lims/models/api/sample.py | 5 +- cg_lims/models/arnold/base_step.py | 5 +- cg_lims/models/arnold/flow_cell.py | 2 +- .../arnold/prep/microbial_prep/__init__.py | 8 +- .../prep/microbial_prep/buffer_exchange.py | 7 +- .../microbial_library_prep_nextera.py | 6 +- ...ion_of_microbial_samples_for_sequencing.py | 7 +- .../normalization_of_microbial_samples.py | 7 +- .../post_pcr_bead_purification.py | 7 +- .../prep/microbial_prep/reception_control.py | 7 +- cg_lims/models/arnold/prep/rna/__init__.py | 4 +- .../rna/a_tailing_and_adapter_ligation.py | 7 +- .../rna/aliquot_samples_for_fragmentation.py | 7 +- ...normalization_of_samples_for_sequencing.py | 7 +- .../arnold/prep/rna/reception_control.py | 6 +- .../arnold/prep/sars_cov_2_prep/__init__.py | 3 +- .../sars_cov_2_prep/library_preparation.py | 7 +- .../sars_cov_2_prep/pooling_and_cleanup.py | 8 +- .../prep/sars_cov_2_prep/reception_control.py | 6 +- cg_lims/models/arnold/prep/twist/__init__.py | 17 +-- ...mples_for_enzymatic_fragmentation_twist.py | 7 +- .../prep/twist/amplify_captured_libraries.py | 7 +- .../prep/twist/bead_purification_twist.py | 6 +- .../arnold/prep/twist/buffer_exchange.py | 8 +- .../prep/twist/capture_and_wash_twist.py | 7 +- .../twist/enzymatic_fragmentation_twist.py | 7 +- .../prep/twist/hybridize_library_twist.py | 6 +- .../twist/kapa_library_preparation_twist.py | 4 +- ...normalization_of_samples_for_sequencing.py | 7 +- .../arnold/prep/twist/pool_samples_twist.py | 6 +- .../arnold/prep/twist/reception_control.py | 8 +- cg_lims/models/arnold/prep/wgs/__init__.py | 6 +- .../prep/wgs/aliquot_sampels_for_covaris.py | 6 +- ...ze_selection_a_tailing_adapter_ligation.py | 7 +- .../prep/wgs/fragment_dna_truseq_dna.py | 7 +- .../arnold/prep/wgs/reception_control.py | 8 +- cg_lims/models/arnold/sample.py | 3 +- .../sequencing/novaseq_6000/__init__.py | 4 +- .../bcl_conversion_and_demultiplexing.py | 9 +- .../novaseq_6000/define_run_format.py | 7 +- .../standard_make_pool_and_denature.py | 7 +- .../standard_prepare_for_sequencing.py | 7 +- .../novaseq_6000/xp_denature_and_examp.py | 7 +- .../novaseq_6000/xp_load_to_flowcell.py | 7 +- .../arnold/sequencing/novaseq_x/__init__.py | 4 +- .../bcl_conversion_and_demultiplexing.py | 9 +- .../sequencing/novaseq_x/define_run_format.py | 7 +- .../novaseq_x/make_pool_and_denature.py | 7 +- .../novaseq_x/prepare_for_sequencing.py | 7 +- cg_lims/objects.py | 13 +- cg_lims/put/queue.py | 3 +- cg_lims/scripts/base.py | 4 +- cg_lims/scripts/check_config.py | 6 +- cg_lims/scripts/fetch_sample_info.py | 53 ++++---- .../one_time_scripts/add_sample_meta_data.py | 13 +- cg_lims/scripts/one_time_scripts/base.py | 4 +- .../one_time_scripts/fetch_tga_samples.py | 8 +- .../one_time_scripts/load_arnold_flowcells.py | 5 +- .../one_time_scripts/load_arnold_steps.py | 7 +- .../one_time_scripts/process_to_artifact.py | 6 +- cg_lims/set/qc.py | 3 +- cg_lims/set/udfs.py | 4 +- cg_lims/status_db_api.py | 5 +- cg_lims/token_manager.py | 3 +- setup.py | 2 +- tests/EPPs/arnold/test_arnold_covid_prep.py | 9 +- .../EPPs/arnold/test_arnold_load_flowcell.py | 4 +- .../EPPs/arnold/test_arnold_microbial_prep.py | 9 +- .../arnold/test_arnold_novaseq_standard.py | 9 +- tests/EPPs/arnold/test_arnold_twist_prep.py | 9 +- tests/EPPs/arnold/test_arnold_wgs_prep.py | 9 +- tests/EPPs/files/test_barcode_tubes.py | 18 +-- .../files/test_buffer_exchange_twist_file.py | 6 +- .../files/test_hamilton_normalization_file.py | 6 +- tests/EPPs/files/test_make_kapa_csv.py | 6 +- tests/EPPs/files/test_sars_cov2_prep_file.py | 7 +- .../qc/test_sequencing_artifact_manager.py | 4 +- .../qc/test_sequencing_quality_checker.py | 3 +- .../test_calculate_average_size_and_set_qc.py | 3 +- .../udf/calculate/test_calculate_beads.py | 1 - ...est_calculate_microbial_aliquot_volumes.py | 7 +- ...t_calculate_resuspension_buffer_volumes.py | 7 +- .../test_calculate_water_volume_rna.py | 13 +- .../calculate/test_find_reads_to_sequence.py | 11 +- .../calculate/test_maf_calculate_volume.py | 5 +- .../test_sum_missing_reads_in_pool.py | 8 +- .../udf/calculate/test_twist_qc_amount.py | 32 ++--- .../udf/check/test_check_artifact_udfs.py | 6 +- ...test_aggregate_qc_flags_and_copy_fields.py | 3 +- .../udf/copy/test_artifact_to_artifact.py | 21 ++-- .../udf/copy/test_measurement_to_analyte.py | 5 +- tests/EPPs/udf/copy/test_original_position.py | 29 +++-- tests/EPPs/udf/set/test_qc_to_sample.py | 8 +- tests/EPPs/udf/set/test_set_barcode.py | 119 ++++++++++-------- tests/EPPs/udf/set/test_set_dates.py | 14 +-- tests/EPPs/udf/set/test_set_method.py | 12 +- .../udf/set/test_set_samples_reads_missing.py | 3 +- tests/commands/test_base.py | 3 +- tests/conftest.py | 22 ++-- tests/get/test_artifacts.py | 8 +- tests/get/test_udfs.py | 6 +- tests/test_status_db_api_client.py | 2 +- 179 files changed, 725 insertions(+), 871 deletions(-) diff --git a/cg_lims/EPPs/arnold/base.py b/cg_lims/EPPs/arnold/base.py index 7c2207d2..f22f4fdb 100644 --- a/cg_lims/EPPs/arnold/base.py +++ b/cg_lims/EPPs/arnold/base.py @@ -1,11 +1,10 @@ #!/usr/bin/env python import click - +from cg_lims.EPPs.arnold.flow_cell import flow_cell from cg_lims.EPPs.arnold.prep import prep from cg_lims.EPPs.arnold.sample import sample from cg_lims.EPPs.arnold.sequencing import sequencing -from cg_lims.EPPs.arnold.flow_cell import flow_cell @click.group(invoke_without_command=True) diff --git a/cg_lims/EPPs/arnold/flow_cell.py b/cg_lims/EPPs/arnold/flow_cell.py index f0af7f42..2db120e9 100644 --- a/cg_lims/EPPs/arnold/flow_cell.py +++ b/cg_lims/EPPs/arnold/flow_cell.py @@ -2,15 +2,12 @@ from typing import List import click -from genologics.lims import Process, Lims, Artifact import requests -from requests import Response - from cg_lims.exceptions import LimsError from cg_lims.get.artifacts import OutputGenerationType, OutputType, get_output_artifacts - from cg_lims.models.arnold.flow_cell import FlowCell, Lane - +from genologics.lims import Artifact, Lims, Process +from requests import Response LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/arnold/prep.py b/cg_lims/EPPs/arnold/prep.py index 697f98cf..591d01b5 100644 --- a/cg_lims/EPPs/arnold/prep.py +++ b/cg_lims/EPPs/arnold/prep.py @@ -1,22 +1,20 @@ +import json import logging from typing import List, Literal import click -from genologics.lims import Lims, Process, Sample import requests -from requests import Response -import json - from cg_lims import options from cg_lims.exceptions import LimsError from cg_lims.get.samples import get_process_samples from cg_lims.models.arnold.base_step import BaseStep from cg_lims.models.arnold.prep.microbial_prep import build_microbial_step_documents -from cg_lims.models.arnold.prep.wgs import build_wgs_documents +from cg_lims.models.arnold.prep.rna import build_rna_documents from cg_lims.models.arnold.prep.sars_cov_2_prep import build_sars_cov_2_documents from cg_lims.models.arnold.prep.twist import build_twist_documents -from cg_lims.models.arnold.prep.rna import build_rna_documents - +from cg_lims.models.arnold.prep.wgs import build_wgs_documents +from genologics.lims import Lims, Process, Sample +from requests import Response LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/arnold/sample.py b/cg_lims/EPPs/arnold/sample.py index 74bc512c..a39017c4 100644 --- a/cg_lims/EPPs/arnold/sample.py +++ b/cg_lims/EPPs/arnold/sample.py @@ -1,14 +1,14 @@ +import json import logging from typing import List import click -from genologics.lims import Process, Sample import requests -from requests import Response -import json from cg_lims.exceptions import LimsError from cg_lims.get.samples import get_process_samples from cg_lims.models.arnold.sample import ArnoldSample +from genologics.lims import Process, Sample +from requests import Response LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/arnold/sequencing.py b/cg_lims/EPPs/arnold/sequencing.py index 3ecb55ea..7824ee53 100644 --- a/cg_lims/EPPs/arnold/sequencing.py +++ b/cg_lims/EPPs/arnold/sequencing.py @@ -1,19 +1,17 @@ +import json import logging from typing import List, Literal import click -from genologics.lims import Lims, Process, Sample import requests -from requests import Response -import json - from cg_lims import options from cg_lims.exceptions import LimsError from cg_lims.get.samples import get_process_samples from cg_lims.models.arnold.base_step import BaseStep from cg_lims.models.arnold.sequencing.novaseq_6000 import build_novaseq_6000_step_documents from cg_lims.models.arnold.sequencing.novaseq_x import build_novaseq_x_step_documents - +from genologics.lims import Lims, Process, Sample +from requests import Response LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/base.py b/cg_lims/EPPs/base.py index 7d9a8ba8..0e7202bd 100644 --- a/cg_lims/EPPs/base.py +++ b/cg_lims/EPPs/base.py @@ -3,17 +3,16 @@ import pathlib import click -from genologics.entities import Process - from cg_lims import options +from cg_lims.EPPs.arnold import arnold_upload from cg_lims.EPPs.files import files # commands from cg_lims.EPPs.move import move -from cg_lims.EPPs.udf import udf from cg_lims.EPPs.qc import qc -from cg_lims.EPPs.arnold import arnold_upload +from cg_lims.EPPs.udf import udf from cg_lims.get.files import get_log_content +from genologics.entities import Process @click.group(invoke_without_command=True) diff --git a/cg_lims/EPPs/files/barcode_tubes.py b/cg_lims/EPPs/files/barcode_tubes.py index 3bc2bd02..4871f3ab 100644 --- a/cg_lims/EPPs/files/barcode_tubes.py +++ b/cg_lims/EPPs/files/barcode_tubes.py @@ -1,22 +1,22 @@ -import re import logging +import re import sys -import click -import pandas as pd - from pathlib import Path from typing import List -from genologics.lims import Artifact + +import click +import pandas as pd from cg_lims import options -from cg_lims.exceptions import LimsError, InvalidValueError, MissingValueError +from cg_lims.exceptions import InvalidValueError, LimsError, MissingValueError from cg_lims.get.artifacts import get_artifacts from cg_lims.get.fields import get_barcode - +from genologics.lims import Artifact LOG = logging.getLogger(__name__) + def get_data_and_write( - artifacts: List[Artifact], + artifacts: List[Artifact], file: str, ): """Making a barcode csv file with sample names as barcode.""" @@ -31,51 +31,45 @@ def get_data_and_write( art_container_type = artifact.container.type.name if art_container_type.lower() != "tube": - LOG.info( - f"Sample {barcode} does not have container type \"Tube\" therefore excluded." + f'Sample {barcode} does not have container type "Tube" therefore excluded.' ) continue - - - #Function to get project nr and sample id - f=lambda x: re.findall(r'\d+',x) - + + # Function to get project nr and sample id + f = lambda x: re.findall(r"\d+", x) + file_rows.append([barcode, f(barcode)[0], int(f(barcode)[1])]) # ^^^^^ ^^^^^^ - # e.g. ACC10001A1 = 10001 1 - + # e.g. ACC10001A1 = 10001 1 + except: - unexpected_container_type = + 1 + unexpected_container_type = +1 failed_samples.append(artifact.samples[0].id) if unexpected_container_type: failed_message = " ".join(map(str, failed_samples)) raise InvalidValueError( - f"The following samples are missing a container: {failed_message} of type \"Tube\"." + f'The following samples are missing a container: {failed_message} of type "Tube".' ) if file_rows == []: - raise MissingValueError( - f"Missing samples with container type \"Tube\"." - ) + raise MissingValueError(f'Missing samples with container type "Tube".') # Sort and create csv file. unfiltered_df = pd.DataFrame( - data=file_rows, - index = None, - columns = [ + data=file_rows, + index=None, + columns=[ "Barcode", "Project", "id", - ] - ).sort_values(by=["Project","id"]) - + ], + ).sort_values(by=["Project", "id"]) + # Filter off unwanted columns out = unfiltered_df["Barcode"] out.to_csv(Path(file), index=False) - - @click.command() @@ -83,7 +77,9 @@ def get_data_and_write( @options.input() @click.pass_context def make_barcode_csv( - ctx: click.Context, file: str, input: bool, + ctx: click.Context, + file: str, + input: bool, ): """Script to make barcode for tubes""" diff --git a/cg_lims/EPPs/files/base.py b/cg_lims/EPPs/files/base.py index cfe4b744..d8805488 100644 --- a/cg_lims/EPPs/files/base.py +++ b/cg_lims/EPPs/files/base.py @@ -1,15 +1,15 @@ #!/usr/bin/env python 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 # commands from cg_lims.EPPs.files.file_to_udf import csv_well_to_udf from cg_lims.EPPs.files.hamilton.base import hamilton -from cg_lims.EPPs.files.xml_to_udf import parse_run_parameters -from cg_lims.EPPs.files.pooling_map.make_pooling_map import pool_map from cg_lims.EPPs.files.placement_map.make_96well_placement_map import placement_map -from cg_lims.EPPs.files.csv_for_kapa_truble_shooting.csv_for_kapa_debug import trouble_shoot_kapa -from cg_lims.EPPs.files.barcode_tubes import make_barcode_csv +from cg_lims.EPPs.files.pooling_map.make_pooling_map import pool_map from cg_lims.EPPs.files.sample_sheet.create_sample_sheet import create_sample_sheet +from cg_lims.EPPs.files.xml_to_udf import parse_run_parameters @click.group(invoke_without_command=True) diff --git a/cg_lims/EPPs/files/csv_for_kapa_truble_shooting/csv_for_kapa_debug.py b/cg_lims/EPPs/files/csv_for_kapa_truble_shooting/csv_for_kapa_debug.py index a5f73533..f413e1c2 100644 --- a/cg_lims/EPPs/files/csv_for_kapa_truble_shooting/csv_for_kapa_debug.py +++ b/cg_lims/EPPs/files/csv_for_kapa_truble_shooting/csv_for_kapa_debug.py @@ -1,26 +1,25 @@ import csv +import logging import sys from pathlib import Path from typing import List import click -import logging -from genologics.lims import Lims - from cg_lims import options -from cg_lims.EPPs.files.csv_for_kapa_truble_shooting.models import DebugKapaCSV, HEADERS +from cg_lims.EPPs.files.csv_for_kapa_truble_shooting.models import HEADERS, DebugKapaCSV +from cg_lims.exceptions import FileError, LimsError +from cg_lims.get.artifacts import get_artifact_by_name +from cg_lims.get.files import get_file_path from cg_lims.models.api.master_steps import ( - HybridizeLibraryTWIST, AliquotsamplesforenzymaticfragmentationTWIST, - KAPALibraryPreparation, - PoolsamplesforhybridizationTWIST, - CaptureandWashTWIST, BeadPurificationTWIST, BufferExchange, + CaptureandWashTWIST, + HybridizeLibraryTWIST, + KAPALibraryPreparation, + PoolsamplesforhybridizationTWIST, ) -from cg_lims.exceptions import LimsError, FileError -from cg_lims.get.artifacts import get_artifact_by_name -from cg_lims.get.files import get_file_path +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/files/csv_for_kapa_truble_shooting/models.py b/cg_lims/EPPs/files/csv_for_kapa_truble_shooting/models.py index 0a36ca50..2d04ede3 100644 --- a/cg_lims/EPPs/files/csv_for_kapa_truble_shooting/models.py +++ b/cg_lims/EPPs/files/csv_for_kapa_truble_shooting/models.py @@ -1,6 +1,5 @@ -from pydantic.v1 import BaseModel, Field - from cg_lims.models.api.master_steps import HybridizeLibraryTWIST +from pydantic.v1 import BaseModel, Field class DebugKapaCSV(BaseModel): diff --git a/cg_lims/EPPs/files/file_to_udf.py b/cg_lims/EPPs/files/file_to_udf.py index f5b58f2f..456a565f 100644 --- a/cg_lims/EPPs/files/file_to_udf.py +++ b/cg_lims/EPPs/files/file_to_udf.py @@ -1,17 +1,16 @@ #!/usr/bin/env python +import csv import logging import sys -import csv from pathlib import Path import click -from genologics.entities import Artifact - from cg_lims import options from cg_lims.exceptions import LimsError, MissingArtifactError, MissingFileError from cg_lims.get.artifacts import get_artifact_by_name from cg_lims.get.files import get_file_path +from genologics.entities import Artifact LOG = logging.getLogger(__name__) @@ -53,7 +52,7 @@ def set_udfs(well_field: str, value_field: str, udf: str, well_dict: dict, resul continue art = well_dict[well] try: - art.udf[udf] = str(value) + art.udf[udf] = str(value) except: art.udf[udf] = float(value) art.put() @@ -62,7 +61,7 @@ def set_udfs(well_field: str, value_field: str, udf: str, well_dict: dict, resul if passed_arts < len(well_dict.keys()): error_msg.append("Some samples in the step were not represented in the file.") - error_string = ' '.join(list(set(error_msg))) + error_string = " ".join(list(set(error_msg))) if error_msg: raise MissingArtifactError(error_string) diff --git a/cg_lims/EPPs/files/hamilton/base.py b/cg_lims/EPPs/files/hamilton/base.py index 2e1c23c9..3646e537 100644 --- a/cg_lims/EPPs/files/hamilton/base.py +++ b/cg_lims/EPPs/files/hamilton/base.py @@ -1,10 +1,10 @@ import click +from cg_lims.EPPs.files.hamilton.buffer_exchange_twist_file import buffer_exchange_twist_file +from cg_lims.EPPs.files.hamilton.make_kapa_csv import make_kapa_csv # commands from cg_lims.EPPs.files.hamilton.normalization_file import barcode_file -from cg_lims.EPPs.files.hamilton.make_kapa_csv import make_kapa_csv from cg_lims.EPPs.files.hamilton.sars_cov2_prep_file import sars_cov2_prep_file -from cg_lims.EPPs.files.hamilton.buffer_exchange_twist_file import buffer_exchange_twist_file @click.group(invoke_without_command=True) diff --git a/cg_lims/EPPs/files/hamilton/buffer_exchange_twist_file.py b/cg_lims/EPPs/files/hamilton/buffer_exchange_twist_file.py index 7256538b..4f6521c1 100644 --- a/cg_lims/EPPs/files/hamilton/buffer_exchange_twist_file.py +++ b/cg_lims/EPPs/files/hamilton/buffer_exchange_twist_file.py @@ -2,17 +2,16 @@ import logging import sys - -import click from typing import List -from genologics.entities import Artifact +import click from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.files.manage_csv_files import make_plate_file from cg_lims.get.artifacts import get_artifacts from cg_lims.get.fields import get_artifact_well from cg_lims.get.samples import get_one_sample_from_artifact +from genologics.entities import Artifact LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/files/hamilton/make_kapa_csv.py b/cg_lims/EPPs/files/hamilton/make_kapa_csv.py index e8df76e0..53c65604 100644 --- a/cg_lims/EPPs/files/hamilton/make_kapa_csv.py +++ b/cg_lims/EPPs/files/hamilton/make_kapa_csv.py @@ -4,13 +4,12 @@ import sys import click -from genologics.lims import Lims - from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.files.manage_csv_files import make_plate_file from cg_lims.get.artifacts import get_artifacts, get_latest_analyte from cg_lims.get.fields import get_index_well +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/files/hamilton/normalization_file.py b/cg_lims/EPPs/files/hamilton/normalization_file.py index 6330ed6d..86167b2b 100644 --- a/cg_lims/EPPs/files/hamilton/normalization_file.py +++ b/cg_lims/EPPs/files/hamilton/normalization_file.py @@ -5,13 +5,12 @@ from typing import List import click -from genologics.lims import Artifact - from cg_lims import options from cg_lims.EPPs.files.hamilton.models import BarcodeFileRow from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.files.manage_csv_files import build_csv, sort_csv_plate_and_tube from cg_lims.get.artifacts import get_artifacts +from genologics.lims import Artifact LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/files/hamilton/sars_cov2_prep_file.py b/cg_lims/EPPs/files/hamilton/sars_cov2_prep_file.py index 68e89db3..fd8aae5a 100644 --- a/cg_lims/EPPs/files/hamilton/sars_cov2_prep_file.py +++ b/cg_lims/EPPs/files/hamilton/sars_cov2_prep_file.py @@ -5,14 +5,13 @@ from typing import List import click -from genologics.lims import Artifact - from cg_lims import options from cg_lims.EPPs.files.hamilton.models import CovidPrepFileRow from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.files.manage_csv_files import build_csv, sort_csv from cg_lims.get.artifacts import get_artifacts -from cg_lims.get.fields import get_index_well, get_artifact_well +from cg_lims.get.fields import get_artifact_well, get_index_well +from genologics.lims import Artifact LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/files/placement_map/make_96well_placement_map.py b/cg_lims/EPPs/files/placement_map/make_96well_placement_map.py index 49581316..9c01fe0f 100644 --- a/cg_lims/EPPs/files/placement_map/make_96well_placement_map.py +++ b/cg_lims/EPPs/files/placement_map/make_96well_placement_map.py @@ -1,13 +1,14 @@ import logging import sys -from typing import List, Dict -import click from datetime import date -from genologics.entities import Artifact, Process -from genologics.lims import Lims +from typing import Dict, List + +import click from cg_lims import options from cg_lims.exceptions import LimsError -from .models import PlacementMapHeader, WellInfo, PlateInfo +from genologics.entities import Artifact, Process +from genologics.lims import Lims + from .hmtl_templates import ( PLACEMENT_MAP_HEADER, PLATE_HEADER_SECTION, @@ -16,6 +17,7 @@ VISUAL_PLACEMENT_MAP_HEADER, VISUAL_PLACEMENT_MAP_WELL, ) +from .models import PlacementMapHeader, PlateInfo, WellInfo LOG = logging.getLogger(__name__) @@ -43,7 +45,11 @@ def get_placement_map_data( def make_source_dest_info( - source_artifact: Artifact, dest_artifact: Artifact, original_well: str, input_udfs: List[str], output_udfs: List[str] + source_artifact: Artifact, + dest_artifact: Artifact, + original_well: str, + input_udfs: List[str], + output_udfs: List[str], ) -> WellInfo: """Collecting info about a well.""" @@ -67,7 +73,9 @@ def make_source_dest_info( container_name = source_artifact.location[0].name well_source = "Source Well" well = source_artifact.location[1] - udf_info = more_sample_info(source_artifact, input_udfs) + more_sample_info(dest_artifact, output_udfs) + udf_info = more_sample_info(source_artifact, input_udfs) + more_sample_info( + dest_artifact, output_udfs + ) return WellInfo( project_name=sample.project.name, sample_name=sample_name, @@ -155,7 +163,9 @@ def make_html(placement_map: dict, process: Process, original_well: str) -> str: @options.artifact_udfs(help="Output artifact UDFs to show in the placement map.") @options.original_well() @click.pass_context -def placement_map(ctx, file: str, sample_udfs: List[str], artifact_udfs: List[str], original_well: str): +def placement_map( + ctx, file: str, sample_udfs: List[str], artifact_udfs: List[str], original_well: str +): """Create a 96 well placement map.""" LOG.info(f"Running {ctx.command_path} with params: {ctx.params}") @@ -163,7 +173,9 @@ def placement_map(ctx, file: str, sample_udfs: List[str], artifact_udfs: List[st lims = ctx.obj["lims"] try: - placement_map_data = get_placement_map_data(lims, process, sample_udfs, artifact_udfs, original_well) + placement_map_data = get_placement_map_data( + lims, process, sample_udfs, artifact_udfs, original_well + ) html = make_html(placement_map_data, process, original_well) with open(f"{file}.html", "w") as file: file.write(html) diff --git a/cg_lims/EPPs/files/pooling_map/make_pooling_map.py b/cg_lims/EPPs/files/pooling_map/make_pooling_map.py index 2c828672..77d57d48 100644 --- a/cg_lims/EPPs/files/pooling_map/make_pooling_map.py +++ b/cg_lims/EPPs/files/pooling_map/make_pooling_map.py @@ -1,12 +1,10 @@ import logging import sys -from typing import List, Tuple from datetime import date +from typing import List, Tuple + import click -from genologics.entities import Artifact, Process from cg_lims import options -from cg_lims.exceptions import LimsError -from cg_lims.get.artifacts import get_artifacts from cg_lims.EPPs.files.pooling_map.hmtl_templates import ( PLACEMENT_MAP_HEADER, POOL_HEADER, @@ -18,6 +16,9 @@ PoolSection, SampleTableSection, ) +from cg_lims.exceptions import LimsError +from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact, Process from matplotlib import colors COLORS = list(colors.TABLEAU_COLORS.values()) diff --git a/cg_lims/EPPs/files/sample_sheet/create_sample_sheet.py b/cg_lims/EPPs/files/sample_sheet/create_sample_sheet.py index 8ced634a..bb768c70 100644 --- a/cg_lims/EPPs/files/sample_sheet/create_sample_sheet.py +++ b/cg_lims/EPPs/files/sample_sheet/create_sample_sheet.py @@ -1,23 +1,22 @@ -import re import logging +import re import sys -import click +from typing import Dict, List, Optional -from typing import List, Optional, Dict -from genologics.lims import Lims -from genologics.entities import Artifact, Process, ReagentType +import click from cg_lims import options -from cg_lims.exceptions import LimsError, InvalidValueError -from cg_lims.get.artifacts import get_artifact_lane, get_artifacts from cg_lims.EPPs.files.sample_sheet.models import ( + IlluminaIndex, IndexSetup, IndexType, - SampleSheetHeader, - IlluminaIndex, - NovaSeqXRun, LaneSample, + NovaSeqXRun, + SampleSheetHeader, ) - +from cg_lims.exceptions import InvalidValueError, LimsError +from cg_lims.get.artifacts import get_artifact_lane, get_artifacts +from genologics.entities import Artifact, Process, ReagentType +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/files/sample_sheet/models.py b/cg_lims/EPPs/files/sample_sheet/models.py index cc18bfaa..07dc29db 100644 --- a/cg_lims/EPPs/files/sample_sheet/models.py +++ b/cg_lims/EPPs/files/sample_sheet/models.py @@ -1,7 +1,8 @@ -from genologics.lims import Process -from typing import Optional import logging -from cg_lims.enums import StrEnum, IntEnum +from typing import Optional + +from cg_lims.enums import IntEnum, StrEnum +from genologics.lims import Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/files/xml_to_udf.py b/cg_lims/EPPs/files/xml_to_udf.py index 23552a28..6879d34f 100644 --- a/cg_lims/EPPs/files/xml_to_udf.py +++ b/cg_lims/EPPs/files/xml_to_udf.py @@ -1,17 +1,16 @@ +import glob import logging -import sys import os -import glob -from typing import List, Dict +import sys from pathlib import Path +from typing import Dict, List from xml.etree import ElementTree import click -from genologics.entities import Process -from genologics.lims import Lims - from cg_lims import options from cg_lims.exceptions import LimsError, MissingFileError +from genologics.entities import Process +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/move/move_samples.py b/cg_lims/EPPs/move/move_samples.py index a94a2569..c482b043 100755 --- a/cg_lims/EPPs/move/move_samples.py +++ b/cg_lims/EPPs/move/move_samples.py @@ -2,10 +2,9 @@ import logging import sys -from typing import Optional, List +from typing import List, Optional import click - from cg_lims import options from cg_lims.exceptions import LimsError from cg_lims.get.artifacts import filter_artifacts, get_artifacts diff --git a/cg_lims/EPPs/move/rerun_samples.py b/cg_lims/EPPs/move/rerun_samples.py index c852ea3f..e5d697c5 100644 --- a/cg_lims/EPPs/move/rerun_samples.py +++ b/cg_lims/EPPs/move/rerun_samples.py @@ -5,13 +5,12 @@ from typing import List import click -from genologics.entities import Artifact -from genologics.lims import Lims - from cg_lims import options from cg_lims.exceptions import DuplicateSampleError, LimsError, MissingArtifactError from cg_lims.get.artifacts import filter_artifacts, get_artifacts, get_latest_analyte from cg_lims.put.queue import queue_artifacts +from genologics.entities import Artifact +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/qc/models.py b/cg_lims/EPPs/qc/models.py index 755431a7..0218715b 100644 --- a/cg_lims/EPPs/qc/models.py +++ b/cg_lims/EPPs/qc/models.py @@ -1,5 +1,4 @@ from typing import Set, Tuple - SampleLane = Tuple[str, int] SampleLaneSet = Set[SampleLane] diff --git a/cg_lims/EPPs/qc/sequencing_artifact_manager.py b/cg_lims/EPPs/qc/sequencing_artifact_manager.py index 7e6d661e..3de351a6 100644 --- a/cg_lims/EPPs/qc/sequencing_artifact_manager.py +++ b/cg_lims/EPPs/qc/sequencing_artifact_manager.py @@ -2,16 +2,15 @@ from collections import defaultdict from typing import Dict, Optional -from genologics.entities import Artifact, Process -from genologics.lims import Lims from cg_lims.EPPs.qc.models import SampleLaneSet - from cg_lims.exceptions import LimsError from cg_lims.get.artifacts import get_lane_sample_artifacts from cg_lims.get.fields import get_artifact_sample_id, get_flow_cell_name from cg_lims.get.udfs import get_q30_threshold from cg_lims.set.qc import set_quality_control_flag from cg_lims.set.udfs import set_q30_score, set_reads_count +from genologics.entities import Artifact, Process +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/qc/sequencing_quality_control.py b/cg_lims/EPPs/qc/sequencing_quality_control.py index ba170be5..9b3f7c5f 100644 --- a/cg_lims/EPPs/qc/sequencing_quality_control.py +++ b/cg_lims/EPPs/qc/sequencing_quality_control.py @@ -1,11 +1,9 @@ +import logging import sys import click - -import logging - -from cg_lims.EPPs.qc.sequencing_quality_checker import SequencingQualityChecker from cg_lims.EPPs.qc.sequencing_artifact_manager import SequencingArtifactManager +from cg_lims.EPPs.qc.sequencing_quality_checker import SequencingQualityChecker LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/base.py b/cg_lims/EPPs/udf/base.py index 8ee3103c..d3274aa4 100644 --- a/cg_lims/EPPs/udf/base.py +++ b/cg_lims/EPPs/udf/base.py @@ -1,11 +1,11 @@ #!/usr/bin/env python import click from cg_lims.EPPs.udf.calculate import calculate +from cg_lims.EPPs.udf.check import check # commands from cg_lims.EPPs.udf.copy import copy from cg_lims.EPPs.udf.set import set -from cg_lims.EPPs.udf.check import check @click.group(invoke_without_command=True) diff --git a/cg_lims/EPPs/udf/calculate/base.py b/cg_lims/EPPs/udf/calculate/base.py index ea3d4e82..84f08253 100644 --- a/cg_lims/EPPs/udf/calculate/base.py +++ b/cg_lims/EPPs/udf/calculate/base.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import click - from cg_lims.EPPs.udf.calculate.calculate_amount_ng import calculate_amount_ng +from cg_lims.EPPs.udf.calculate.calculate_average_size_and_set_qc import ( + calculate_average_size_and_set_qc, +) from cg_lims.EPPs.udf.calculate.calculate_beads import calculate_beads from cg_lims.EPPs.udf.calculate.calculate_microbial_aliquot_volumes import ( calculate_microbial_aliquot_volumes, @@ -11,24 +13,17 @@ calculate_resuspension_buffer_volume, ) from cg_lims.EPPs.udf.calculate.calculate_water import volume_water -from cg_lims.EPPs.udf.calculate.calculate_water_volume_rna import ( - calculate_water_volume_rna, -) +from cg_lims.EPPs.udf.calculate.calculate_water_volume_rna import calculate_water_volume_rna from cg_lims.EPPs.udf.calculate.get_missing_reads import get_missing_reads from cg_lims.EPPs.udf.calculate.maf_calculate_volume import maf_calculate_volume from cg_lims.EPPs.udf.calculate.molar_concentration import molar_concentration +from cg_lims.EPPs.udf.calculate.novaseq_x_denaturation import novaseq_x_denaturation +from cg_lims.EPPs.udf.calculate.novaseq_x_volumes import novaseq_x_volumes +from cg_lims.EPPs.udf.calculate.pool_normalization import pool_normalization from cg_lims.EPPs.udf.calculate.sum_missing_reads_in_pool import missing_reads_in_pool from cg_lims.EPPs.udf.calculate.twist_aliquot_amount import twist_aliquot_amount from cg_lims.EPPs.udf.calculate.twist_aliquot_volume import twist_aliquot_volume -from cg_lims.EPPs.udf.calculate.twist_get_volumes_from_buffer import ( - get_volumes_from_buffer, -) -from cg_lims.EPPs.udf.calculate.calculate_average_size_and_set_qc import ( - calculate_average_size_and_set_qc, -) -from cg_lims.EPPs.udf.calculate.novaseq_x_volumes import novaseq_x_volumes -from cg_lims.EPPs.udf.calculate.pool_normalization import pool_normalization -from cg_lims.EPPs.udf.calculate.novaseq_x_denaturation import novaseq_x_denaturation +from cg_lims.EPPs.udf.calculate.twist_get_volumes_from_buffer import get_volumes_from_buffer # commands from cg_lims.EPPs.udf.calculate.twist_pool import twist_pool diff --git a/cg_lims/EPPs/udf/calculate/calculate_average_size_and_set_qc.py b/cg_lims/EPPs/udf/calculate/calculate_average_size_and_set_qc.py index 407231ff..4ede0397 100644 --- a/cg_lims/EPPs/udf/calculate/calculate_average_size_and_set_qc.py +++ b/cg_lims/EPPs/udf/calculate/calculate_average_size_and_set_qc.py @@ -1,15 +1,13 @@ import logging import sys -import click -import numpy as np - from typing import List -from genologics.entities import Artifact - +import click +import numpy as np from cg_lims import options -from cg_lims.get.artifacts import get_artifacts from cg_lims.exceptions import LimsError, MissingUDFsError +from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/calculate_beads.py b/cg_lims/EPPs/udf/calculate/calculate_beads.py index 226a9728..347ffbca 100644 --- a/cg_lims/EPPs/udf/calculate/calculate_beads.py +++ b/cg_lims/EPPs/udf/calculate/calculate_beads.py @@ -4,9 +4,9 @@ from typing import List import click -from genologics.entities import Artifact from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/calculate_microbial_aliquot_volumes.py b/cg_lims/EPPs/udf/calculate/calculate_microbial_aliquot_volumes.py index 58a69a9d..ae4eddf6 100644 --- a/cg_lims/EPPs/udf/calculate/calculate_microbial_aliquot_volumes.py +++ b/cg_lims/EPPs/udf/calculate/calculate_microbial_aliquot_volumes.py @@ -9,10 +9,9 @@ from typing import List import click -from genologics.entities import Artifact - from cg_lims.exceptions import HighConcentrationError, LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact FINAL_CONCENTRATION = 2 LOG = logging.getLogger(__name__) @@ -29,9 +28,7 @@ def calculate_volumes(artifacts: List[Artifact]) -> None: for artifact in artifacts: concentration = artifact.udf.get("Concentration") if concentration is None: - LOG.error( - f"Sample {artifact.samples[0].name} is missing udf 'Concentration'." - ) + LOG.error(f"Sample {artifact.samples[0].name} is missing udf 'Concentration'.") missing_udfs += 1 continue if artifact.samples[0].name.startswith("NTC-CG"): diff --git a/cg_lims/EPPs/udf/calculate/calculate_resuspension_buffer_volumes.py b/cg_lims/EPPs/udf/calculate/calculate_resuspension_buffer_volumes.py index e04e7b11..95c88b85 100644 --- a/cg_lims/EPPs/udf/calculate/calculate_resuspension_buffer_volumes.py +++ b/cg_lims/EPPs/udf/calculate/calculate_resuspension_buffer_volumes.py @@ -10,10 +10,9 @@ from typing import List import click -from genologics.entities import Artifact - from cg_lims.exceptions import InvalidValueError, LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact LOG = logging.getLogger(__name__) @@ -33,9 +32,7 @@ def calculate_rb_volume(artifacts: List[Artifact]): amount_needed = artifact.udf.get("Amount needed (ng)") allowed_amounts = [AMOUNT_NEEDED_LUCIGEN, AMOUNT_NEEDED_TRUSEQ, AMOUNT_NEEDED_TAGMENTATION] if concentration is None: - LOG.error( - f"Sample {artifact.id} is missing udf 'Concentration'." - ) + LOG.error(f"Sample {artifact.id} is missing udf 'Concentration'.") missing_udfs += 1 continue if amount_needed not in allowed_amounts: diff --git a/cg_lims/EPPs/udf/calculate/calculate_water_volume_rna.py b/cg_lims/EPPs/udf/calculate/calculate_water_volume_rna.py index daac42eb..f2d31887 100644 --- a/cg_lims/EPPs/udf/calculate/calculate_water_volume_rna.py +++ b/cg_lims/EPPs/udf/calculate/calculate_water_volume_rna.py @@ -6,10 +6,9 @@ from typing import List import click -from genologics.entities import Artifact - from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/constants.py b/cg_lims/EPPs/udf/calculate/constants.py index 6bb272e4..f25bf268 100644 --- a/cg_lims/EPPs/udf/calculate/constants.py +++ b/cg_lims/EPPs/udf/calculate/constants.py @@ -1,4 +1,4 @@ -from cg_lims.enums import IntEnum, FloatEnum, StrEnum +from cg_lims.enums import FloatEnum, IntEnum, StrEnum class FlowCellTypes(StrEnum): diff --git a/cg_lims/EPPs/udf/calculate/get_missing_reads.py b/cg_lims/EPPs/udf/calculate/get_missing_reads.py index 3e032846..255363d9 100644 --- a/cg_lims/EPPs/udf/calculate/get_missing_reads.py +++ b/cg_lims/EPPs/udf/calculate/get_missing_reads.py @@ -2,12 +2,11 @@ import sys import click -from genologics.entities import Artifact -from requests.exceptions import ConnectionError - from cg_lims.exceptions import LimsError, MissingCgFieldError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts from cg_lims.status_db_api import StatusDBAPI +from genologics.entities import Artifact +from requests.exceptions import ConnectionError LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/maf_calculate_volume.py b/cg_lims/EPPs/udf/calculate/maf_calculate_volume.py index 89362d60..7ac6d390 100644 --- a/cg_lims/EPPs/udf/calculate/maf_calculate_volume.py +++ b/cg_lims/EPPs/udf/calculate/maf_calculate_volume.py @@ -10,11 +10,10 @@ from typing import List, Optional import click -from genologics.entities import Artifact -from pydantic.v1 import BaseModel, validator - from cg_lims.exceptions import LimsError from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact +from pydantic.v1 import BaseModel, validator LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/molar_concentration.py b/cg_lims/EPPs/udf/calculate/molar_concentration.py index 923a548f..33676236 100644 --- a/cg_lims/EPPs/udf/calculate/molar_concentration.py +++ b/cg_lims/EPPs/udf/calculate/molar_concentration.py @@ -3,12 +3,11 @@ from typing import List, Optional import click -from genologics.entities import Artifact - +from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts -from cg_lims import options from cg_lims.set.qc import set_qc_fail +from genologics.entities import Artifact LOG = logging.getLogger(__name__) @@ -86,7 +85,7 @@ def molar_concentration( lower_threshold: Optional[float], upper_threshold: Optional[float], ) -> None: - """Script to calculate molar concentration given the weight concentration and fragment size. """ + """Script to calculate molar concentration given the weight concentration and fragment size.""" LOG.info(f"Running {ctx.command_path} with params: {ctx.params}") diff --git a/cg_lims/EPPs/udf/calculate/novaseq_x_denaturation.py b/cg_lims/EPPs/udf/calculate/novaseq_x_denaturation.py index 463a49a3..9fd30c1c 100644 --- a/cg_lims/EPPs/udf/calculate/novaseq_x_denaturation.py +++ b/cg_lims/EPPs/udf/calculate/novaseq_x_denaturation.py @@ -1,19 +1,18 @@ import logging import sys - -import click from typing import List, Optional -from genologics.entities import Artifact, Process -from cg_lims.exceptions import LimsError, MissingUDFsError -from cg_lims.get.artifacts import get_artifacts +import click from cg_lims.EPPs.udf.calculate.constants import ( - FlowCellTypes, - FlowCellSize, FlowCellLaneVolumes10B, FlowCellLaneVolumes15B, FlowCellLaneVolumes25B, + FlowCellSize, + FlowCellTypes, ) +from cg_lims.exceptions import LimsError, MissingUDFsError +from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact, Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/novaseq_x_volumes.py b/cg_lims/EPPs/udf/calculate/novaseq_x_volumes.py index 5bf02b52..b026b213 100644 --- a/cg_lims/EPPs/udf/calculate/novaseq_x_volumes.py +++ b/cg_lims/EPPs/udf/calculate/novaseq_x_volumes.py @@ -1,19 +1,18 @@ import logging import sys - -import click from typing import List -from genologics.entities import Artifact, Process -from cg_lims.exceptions import LimsError, MissingUDFsError, InvalidValueError -from cg_lims.get.artifacts import get_artifacts +import click from cg_lims.EPPs.udf.calculate.constants import ( - FlowCellTypes, - FlowCellSize, FlowCellLaneVolumes10B, FlowCellLaneVolumes15B, FlowCellLaneVolumes25B, + FlowCellSize, + FlowCellTypes, ) +from cg_lims.exceptions import InvalidValueError, LimsError, MissingUDFsError +from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact, Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/pool_normalization.py b/cg_lims/EPPs/udf/calculate/pool_normalization.py index 767cb1e2..204ad956 100644 --- a/cg_lims/EPPs/udf/calculate/pool_normalization.py +++ b/cg_lims/EPPs/udf/calculate/pool_normalization.py @@ -1,13 +1,11 @@ import logging import sys -from typing import List +from typing import List, Optional import click -from genologics.entities import Artifact, Process -from typing import Optional - -from cg_lims.exceptions import LimsError, InvalidValueError, MissingUDFsError +from cg_lims.exceptions import InvalidValueError, LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact, Process LOG = logging.getLogger(__name__) failed_samples = [] diff --git a/cg_lims/EPPs/udf/calculate/twist_aliquot_amount.py b/cg_lims/EPPs/udf/calculate/twist_aliquot_amount.py index 5492d118..be4e3aa6 100644 --- a/cg_lims/EPPs/udf/calculate/twist_aliquot_amount.py +++ b/cg_lims/EPPs/udf/calculate/twist_aliquot_amount.py @@ -3,11 +3,10 @@ from typing import List import click -from genologics.entities import Artifact - from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts from cg_lims.get.udfs import get_maximum_amount +from genologics.entities import Artifact LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/twist_aliquot_volume.py b/cg_lims/EPPs/udf/calculate/twist_aliquot_volume.py index 402b0fd8..60482c37 100644 --- a/cg_lims/EPPs/udf/calculate/twist_aliquot_volume.py +++ b/cg_lims/EPPs/udf/calculate/twist_aliquot_volume.py @@ -3,10 +3,9 @@ from typing import List import click -from genologics.entities import Artifact, Process - from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact, Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/twist_get_volumes_from_buffer.py b/cg_lims/EPPs/udf/calculate/twist_get_volumes_from_buffer.py index ed6cebd7..408c258c 100644 --- a/cg_lims/EPPs/udf/calculate/twist_get_volumes_from_buffer.py +++ b/cg_lims/EPPs/udf/calculate/twist_get_volumes_from_buffer.py @@ -3,9 +3,8 @@ from typing import List import click - from cg_lims import options -from cg_lims.get.artifacts import get_latest_analyte, get_artifacts +from cg_lims.get.artifacts import get_artifacts, get_latest_analyte LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/calculate/twist_qc_amount.py b/cg_lims/EPPs/udf/calculate/twist_qc_amount.py index c9ad392a..f3a35b29 100644 --- a/cg_lims/EPPs/udf/calculate/twist_qc_amount.py +++ b/cg_lims/EPPs/udf/calculate/twist_qc_amount.py @@ -3,12 +3,11 @@ from typing import List import click -from genologics.entities import Artifact - from cg_lims.exceptions import FailingQCError, LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts from cg_lims.get.samples import get_one_sample_from_artifact from cg_lims.get.udfs import get_maximum_amount +from genologics.entities import Artifact LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/check/check_artifact_udfs.py b/cg_lims/EPPs/udf/check/check_artifact_udfs.py index eba50690..56e7b00b 100644 --- a/cg_lims/EPPs/udf/check/check_artifact_udfs.py +++ b/cg_lims/EPPs/udf/check/check_artifact_udfs.py @@ -3,11 +3,12 @@ import logging import sys from typing import List + import click -from genologics.entities import Process, Artifact from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Artifact, Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/check/check_process_udfs.py b/cg_lims/EPPs/udf/check/check_process_udfs.py index 124afb86..e061f6b4 100644 --- a/cg_lims/EPPs/udf/check/check_process_udfs.py +++ b/cg_lims/EPPs/udf/check/check_process_udfs.py @@ -1,10 +1,11 @@ import logging import sys from typing import List + import click -from genologics.entities import Process from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError +from genologics.entities import Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/copy/aggregate_qc_flags_and_copy_fields.py b/cg_lims/EPPs/udf/copy/aggregate_qc_flags_and_copy_fields.py index 0bdda286..28d20e25 100644 --- a/cg_lims/EPPs/udf/copy/aggregate_qc_flags_and_copy_fields.py +++ b/cg_lims/EPPs/udf/copy/aggregate_qc_flags_and_copy_fields.py @@ -1,16 +1,15 @@ #!/usr/bin/env python import logging import sys +from typing import Any, Dict, List, Literal import click -from cg_lims.get.processes import get_latest_process -from genologics.entities import Process, Artifact -from genologics.lims import Lims - +from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts -from cg_lims import options -from typing import List, Dict, Literal, Any +from cg_lims.get.processes import get_latest_process +from genologics.entities import Artifact, Process +from genologics.lims import Lims LOG = logging.getLogger(__name__) @@ -41,9 +40,11 @@ def get_copy_tasks( return copy_tasks -def copy_udfs(input_artifacts: List[Artifact], copy_tasks: dict, lims: Lims, reception_control: List[str]): +def copy_udfs( + input_artifacts: List[Artifact], copy_tasks: dict, lims: Lims, reception_control: List[str] +): """Loop through all artifacts and copy udfs from the correct steps. QC flags are collected from the - reception control step if specified and no fitting source processes can be found.""" + reception control step if specified and no fitting source processes can be found.""" failed_udfs = [] process_types = [task["Source Step"] for task_number, task in copy_tasks.items()] process_types = list(set(process_types)) @@ -56,9 +57,13 @@ def copy_udfs(input_artifacts: List[Artifact], copy_tasks: dict, lims: Lims, rec source_steps = get_correct_steps_for_the_artifact( process_types=reception_control, artifact=artifact, lims=lims ) - current_copy_tasks = {"Copy task 1": {"Source Field": "", "Source Step": reception_control[0]}} - message = f"No fitting processes found for artifact {artifact.id}. " \ - f"Retrieving QC flags from {reception_control}." + current_copy_tasks = { + "Copy task 1": {"Source Field": "", "Source Step": reception_control[0]} + } + message = ( + f"No fitting processes found for artifact {artifact.id}. " + f"Retrieving QC flags from {reception_control}." + ) LOG.info(message) else: current_copy_tasks = copy_tasks @@ -113,7 +118,12 @@ def aggregate_qc_and_copy_fields(ctx, process_types: List[str]): try: copy_tasks = get_copy_tasks(process=process) artifacts = get_artifacts(process=process, input=True) - copy_udfs(input_artifacts=artifacts, copy_tasks=copy_tasks, lims=lims, reception_control=process_types) + copy_udfs( + input_artifacts=artifacts, + copy_tasks=copy_tasks, + lims=lims, + reception_control=process_types, + ) click.echo("Udfs have been set on all samples.") except LimsError as e: sys.exit(e.message) diff --git a/cg_lims/EPPs/udf/copy/artifact_to_artifact.py b/cg_lims/EPPs/udf/copy/artifact_to_artifact.py index c17a97fc..c10e953f 100644 --- a/cg_lims/EPPs/udf/copy/artifact_to_artifact.py +++ b/cg_lims/EPPs/udf/copy/artifact_to_artifact.py @@ -1,16 +1,14 @@ +import logging +import sys from typing import List, Optional, Tuple -from genologics.entities import Artifact -from genologics.lims import Lims -from cg_lims.get.artifacts import get_latest_analyte +import click from cg_lims import options -from cg_lims.exceptions import LimsError, MissingUDFsError, ArgumentError -from cg_lims.get.artifacts import get_artifacts +from cg_lims.exceptions import ArgumentError, LimsError, MissingUDFsError +from cg_lims.get.artifacts import get_artifacts, get_latest_analyte from cg_lims.set.udfs import copy_artifact_to_artifact - -import logging -import sys -import click +from genologics.entities import Artifact +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/copy/artifact_to_sample.py b/cg_lims/EPPs/udf/copy/artifact_to_sample.py index 29f5c457..94982716 100644 --- a/cg_lims/EPPs/udf/copy/artifact_to_sample.py +++ b/cg_lims/EPPs/udf/copy/artifact_to_sample.py @@ -2,7 +2,6 @@ import sys import click - from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts diff --git a/cg_lims/EPPs/udf/copy/base.py b/cg_lims/EPPs/udf/copy/base.py index 062b969b..7c968ccd 100644 --- a/cg_lims/EPPs/udf/copy/base.py +++ b/cg_lims/EPPs/udf/copy/base.py @@ -1,18 +1,18 @@ #!/usr/bin/env python import click +from cg_lims.EPPs.udf.copy.aggregate_qc_flags_and_copy_fields import aggregate_qc_and_copy_fields +from cg_lims.EPPs.udf.copy.artifact_to_artifact import artifact_to_artifact # commands from cg_lims.EPPs.udf.copy.artifact_to_sample import artifact_to_sample -from cg_lims.EPPs.udf.copy.sample_to_artifact import sample_to_artifact -from cg_lims.EPPs.udf.copy.process_to_sample import process_to_sample -from cg_lims.EPPs.udf.copy.reads_to_sequence import reads_to_sequence -from cg_lims.EPPs.udf.copy.artifact_to_artifact import artifact_to_artifact +from cg_lims.EPPs.udf.copy.measurement_to_analyte import measurement_to_analyte +from cg_lims.EPPs.udf.copy.original_well_to_sample import original_position_to_sample from cg_lims.EPPs.udf.copy.process_to_artifact import process_to_artifact +from cg_lims.EPPs.udf.copy.process_to_sample import process_to_sample from cg_lims.EPPs.udf.copy.qc_to_sample import qc_to_sample -from cg_lims.EPPs.udf.copy.original_well_to_sample import original_position_to_sample -from cg_lims.EPPs.udf.copy.aggregate_qc_flags_and_copy_fields import aggregate_qc_and_copy_fields -from cg_lims.EPPs.udf.copy.measurement_to_analyte import measurement_to_analyte +from cg_lims.EPPs.udf.copy.reads_to_sequence import reads_to_sequence +from cg_lims.EPPs.udf.copy.sample_to_artifact import sample_to_artifact @click.group(invoke_without_command=True) diff --git a/cg_lims/EPPs/udf/copy/measurement_to_analyte.py b/cg_lims/EPPs/udf/copy/measurement_to_analyte.py index 5c2a98b8..167bc642 100644 --- a/cg_lims/EPPs/udf/copy/measurement_to_analyte.py +++ b/cg_lims/EPPs/udf/copy/measurement_to_analyte.py @@ -1,14 +1,13 @@ +import logging +import sys from typing import List, Tuple -from genologics.entities import Artifact +import click from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts from cg_lims.set.udfs import copy_artifact_to_artifact - -import logging -import sys -import click +from genologics.entities import Artifact LOG = logging.getLogger(__name__) @@ -37,9 +36,7 @@ def copy_udfs_to_all_analytes( @click.command() -@options.artifact_udfs( - help="The name of the udf that you want to set" -) +@options.artifact_udfs(help="The name of the udf that you want to set") @click.pass_context def measurement_to_analyte( ctx, diff --git a/cg_lims/EPPs/udf/copy/original_well_to_sample.py b/cg_lims/EPPs/udf/copy/original_well_to_sample.py index cfee89ca..8580d7ae 100644 --- a/cg_lims/EPPs/udf/copy/original_well_to_sample.py +++ b/cg_lims/EPPs/udf/copy/original_well_to_sample.py @@ -1,10 +1,9 @@ import logging import sys -import click - +import click from cg_lims import options -from cg_lims.exceptions import LimsError, InvalidValueError +from cg_lims.exceptions import InvalidValueError, LimsError from cg_lims.get.artifacts import get_artifacts LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/copy/process_to_artifact.py b/cg_lims/EPPs/udf/copy/process_to_artifact.py index 53c19fb2..d86fdb96 100644 --- a/cg_lims/EPPs/udf/copy/process_to_artifact.py +++ b/cg_lims/EPPs/udf/copy/process_to_artifact.py @@ -1,16 +1,14 @@ +import logging +import sys from typing import List -from genologics.entities import Artifact -from genologics.lims import Lims -from cg_lims.get.artifacts import get_latest_analyte +import click from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError -from cg_lims.get.artifacts import get_artifacts +from cg_lims.get.artifacts import get_artifacts, get_latest_analyte from cg_lims.set.udfs import copy_udf_process_to_artifact - -import logging -import sys -import click +from genologics.entities import Artifact +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/copy/process_to_sample.py b/cg_lims/EPPs/udf/copy/process_to_sample.py index 624f428c..aee83f29 100644 --- a/cg_lims/EPPs/udf/copy/process_to_sample.py +++ b/cg_lims/EPPs/udf/copy/process_to_sample.py @@ -2,7 +2,6 @@ import sys import click - from cg_lims import options from cg_lims.get.samples import get_process_samples diff --git a/cg_lims/EPPs/udf/copy/qc_to_sample.py b/cg_lims/EPPs/udf/copy/qc_to_sample.py index 2b645e52..717f49f6 100644 --- a/cg_lims/EPPs/udf/copy/qc_to_sample.py +++ b/cg_lims/EPPs/udf/copy/qc_to_sample.py @@ -2,7 +2,6 @@ import sys import click - from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts diff --git a/cg_lims/EPPs/udf/copy/reads_to_sequence.py b/cg_lims/EPPs/udf/copy/reads_to_sequence.py index ad20719b..4d748b91 100644 --- a/cg_lims/EPPs/udf/copy/reads_to_sequence.py +++ b/cg_lims/EPPs/udf/copy/reads_to_sequence.py @@ -1,15 +1,12 @@ #!/usr/bin/env python -from typing import Tuple - -from genologics.entities import Process, Artifact -from genologics.lims import Lims - import logging import sys +from typing import Tuple import click - from cg_lims.exceptions import LimsError +from genologics.entities import Artifact, Process +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/copy/sample_to_artifact.py b/cg_lims/EPPs/udf/copy/sample_to_artifact.py index e3674cde..09797480 100644 --- a/cg_lims/EPPs/udf/copy/sample_to_artifact.py +++ b/cg_lims/EPPs/udf/copy/sample_to_artifact.py @@ -1,14 +1,12 @@ #!/usr/bin/env python -from cg_lims.get.udfs import get_udf_type - import logging import sys import click - from cg_lims import options from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.artifacts import get_artifacts +from cg_lims.get.udfs import get_udf_type LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/set/base.py b/cg_lims/EPPs/udf/set/base.py index 93eed7b4..021b070b 100644 --- a/cg_lims/EPPs/udf/set/base.py +++ b/cg_lims/EPPs/udf/set/base.py @@ -1,11 +1,10 @@ import click - -from cg_lims.EPPs.udf.set.set_samples_reads_missing import set_reads_missing_on_new_samples -from cg_lims.EPPs.udf.set.set_sample_date import set_sample_date -from cg_lims.EPPs.udf.set.set_method import method_document +from cg_lims.EPPs.udf.set.replace_flow_cell_output_path import replace_flow_cell_output_path from cg_lims.EPPs.udf.set.set_barcode import assign_barcode +from cg_lims.EPPs.udf.set.set_method import method_document +from cg_lims.EPPs.udf.set.set_sample_date import set_sample_date +from cg_lims.EPPs.udf.set.set_samples_reads_missing import set_reads_missing_on_new_samples from cg_lims.EPPs.udf.set.set_sequencing_settings import set_sequencing_settings -from cg_lims.EPPs.udf.set.replace_flow_cell_output_path import replace_flow_cell_output_path @click.group(invoke_without_command=True) diff --git a/cg_lims/EPPs/udf/set/replace_flow_cell_output_path.py b/cg_lims/EPPs/udf/set/replace_flow_cell_output_path.py index 2955a402..a9299e87 100644 --- a/cg_lims/EPPs/udf/set/replace_flow_cell_output_path.py +++ b/cg_lims/EPPs/udf/set/replace_flow_cell_output_path.py @@ -1,9 +1,9 @@ import logging import sys -import click -from genologics.lims import Process +import click from cg_lims.exceptions import LimsError, MissingUDFsError +from genologics.lims import Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/set/set_barcode.py b/cg_lims/EPPs/udf/set/set_barcode.py index 93a012b6..3f6838f6 100644 --- a/cg_lims/EPPs/udf/set/set_barcode.py +++ b/cg_lims/EPPs/udf/set/set_barcode.py @@ -1,13 +1,13 @@ import logging import sys -import click - from typing import List -from genologics.lims import Artifact + +import click from cg_lims import options -from cg_lims.exceptions import LimsError, InvalidValueError, MissingValueError +from cg_lims.exceptions import InvalidValueError, LimsError, MissingValueError from cg_lims.get.artifacts import get_artifacts from cg_lims.get.fields import get_barcode +from genologics.lims import Artifact LOG = logging.getLogger(__name__) @@ -18,16 +18,15 @@ def get_barcode_set_udf( container_type: str, measurement: bool, ): - """Assigning barcode to a barcode udf. - + - Assigned on container type if selected. - Gives warning if no samples assigned. - Checks if script failed and what the cause might be. - Informs user if sample doesn't have a defined barcode. """ - + assigned_artifacts = 0 failed_samples = [] @@ -35,7 +34,7 @@ def get_barcode_set_udf( if measurement: if len(artifact.samples) > 1: LOG.info(f"Sample {str(artifact.id)} is a pool, and will be excluded") - + else: measurement_artifact = artifact artifact = artifact.input_artifact_list()[0] @@ -65,7 +64,7 @@ def get_barcode_set_udf( measurement_artifact.udf[artifact_udf] = barcode measurement_artifact.put() assigned_artifacts += 1 - + else: artifact.udf[artifact_udf] = barcode artifact.put() @@ -79,9 +78,9 @@ def get_barcode_set_udf( if failed_samples: failed_message = ", ".join(map(str, failed_samples)) raise InvalidValueError( - f"Samples {failed_message}, are missing udf container or udf \"{artifact_udf}\"." + f'Samples {failed_message}, are missing udf container or udf "{artifact_udf}".' ) - + # Notifies that no sample got a barcode. elif not assigned_artifacts: raise MissingValueError(f"No barcode assigned. Check parameters.") diff --git a/cg_lims/EPPs/udf/set/set_method.py b/cg_lims/EPPs/udf/set/set_method.py index ce1a6c55..3f518856 100644 --- a/cg_lims/EPPs/udf/set/set_method.py +++ b/cg_lims/EPPs/udf/set/set_method.py @@ -5,12 +5,10 @@ from typing import List import click - import requests -from genologics.entities import Process - from cg_lims import options -from cg_lims.exceptions import LimsError, AtlasResponseFailedError +from cg_lims.exceptions import AtlasResponseFailedError, LimsError +from genologics.entities import Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/set/set_sample_date.py b/cg_lims/EPPs/udf/set/set_sample_date.py index 328a4fb5..7c155265 100644 --- a/cg_lims/EPPs/udf/set/set_sample_date.py +++ b/cg_lims/EPPs/udf/set/set_sample_date.py @@ -1,15 +1,14 @@ """Scripts to set the sample date udfs. """ import logging -from typing import Literal, List +from datetime import datetime +from typing import List, Literal import click -from genologics.entities import Sample, Process - from cg_lims import options -from cg_lims.get.samples import get_process_samples from cg_lims.exceptions import MissingUDFsError -from datetime import datetime +from cg_lims.get.samples import get_process_samples +from genologics.entities import Process, Sample LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/set/set_samples_reads_missing.py b/cg_lims/EPPs/udf/set/set_samples_reads_missing.py index 46d45eca..897f782c 100644 --- a/cg_lims/EPPs/udf/set/set_samples_reads_missing.py +++ b/cg_lims/EPPs/udf/set/set_samples_reads_missing.py @@ -4,12 +4,11 @@ from typing import List import click -from genologics.entities import Sample - from cg_lims.exceptions import LimsError, MissingUDFsError from cg_lims.get.samples import get_process_samples from cg_lims.get.udfs import get_udf from cg_lims.status_db_api import StatusDBAPI +from genologics.entities import Sample LOG = logging.getLogger(__name__) diff --git a/cg_lims/EPPs/udf/set/set_sequencing_settings.py b/cg_lims/EPPs/udf/set/set_sequencing_settings.py index 315750a5..ea534f29 100644 --- a/cg_lims/EPPs/udf/set/set_sequencing_settings.py +++ b/cg_lims/EPPs/udf/set/set_sequencing_settings.py @@ -1,14 +1,13 @@ import logging import sys -import click - from typing import List, Optional -from genologics.lims import Artifact, Process -from cg_lims.exceptions import LimsError, MissingUDFsError -from cg_lims.get.artifacts import get_artifacts +import click from cg_lims.EPPs.udf.calculate.constants import FlowCellTypes -from cg_lims.EPPs.udf.set.constants import DefaultReadLength, DefaultIndexLength +from cg_lims.EPPs.udf.set.constants import DefaultIndexLength, DefaultReadLength +from cg_lims.exceptions import LimsError, MissingUDFsError +from cg_lims.get.artifacts import get_artifacts +from genologics.lims import Artifact, Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/commands/base.py b/cg_lims/commands/base.py index 4b3dd689..286ba885 100644 --- a/cg_lims/commands/base.py +++ b/cg_lims/commands/base.py @@ -1,16 +1,16 @@ #!/usr/bin/env python from typing import Dict + import click import yaml -from genologics.lims import Lims - from cg_lims import options # commands from cg_lims.EPPs import epps -from cg_lims.token_manager import TokenManager from cg_lims.scripts.base import scripts from cg_lims.status_db_api import StatusDBAPI +from cg_lims.token_manager import TokenManager +from genologics.lims import Lims @click.group(invoke_without_command=True) diff --git a/cg_lims/files/manage_csv_files.py b/cg_lims/files/manage_csv_files.py index dbc9f39b..6db528cc 100644 --- a/cg_lims/files/manage_csv_files.py +++ b/cg_lims/files/manage_csv_files.py @@ -2,10 +2,11 @@ import string from pathlib import Path from typing import List -import pandas as pd +import pandas as pd from cg_lims.exceptions import CSVColumnError -pd.set_option('mode.chained_assignment', None) + +pd.set_option("mode.chained_assignment", None) def make_plate_file( @@ -47,7 +48,9 @@ def build_csv(rows: List[List[str]], file: Path, headers: List[str]) -> Path: return file -def sort_dataframe(csv_data_frame: pd.DataFrame, columns: List[str], well_columns: List[str] = []) -> pd.DataFrame: +def sort_dataframe( + csv_data_frame: pd.DataFrame, columns: List[str], well_columns: List[str] = [] +) -> pd.DataFrame: """This function sorts a csv dataframe object based on a list of given columns.""" temp_sort_columns = [] @@ -94,30 +97,31 @@ def sort_csv(file: Path, columns: List[str], well_columns: List[str] = []): """ csv_data_frame = pd.read_csv(file.absolute(), delimiter=",") - sorted_data = sort_dataframe(csv_data_frame=csv_data_frame, - columns=columns, - well_columns=well_columns) + sorted_data = sort_dataframe( + csv_data_frame=csv_data_frame, columns=columns, well_columns=well_columns + ) sorted_data.to_csv(file.absolute(), index=False) -def sort_csv_plate_and_tube(file: Path, - plate_columns: List[str], - tube_columns: List[str], - plate_well_columns: List[str] = [], - tube_well_columns: List[str] = [], - ) -> None: +def sort_csv_plate_and_tube( + file: Path, + plate_columns: List[str], + tube_columns: List[str], + plate_well_columns: List[str] = [], + tube_well_columns: List[str] = [], +) -> None: """This function performs csv sorting on files which contain samples from tube and plates.""" csv_data_frame = pd.read_csv(file.absolute(), delimiter=",") - plate_csv_data_frame = csv_data_frame.loc[csv_data_frame['Source Labware'] != 'Tube'] - tube_csv_data_frame = csv_data_frame.loc[csv_data_frame['Source Labware'] == 'Tube'] - sorted_plate_data_frame = sort_dataframe(csv_data_frame=plate_csv_data_frame, - columns=plate_columns, - well_columns=plate_well_columns) - sorted_tube_data_frame = sort_dataframe(csv_data_frame=tube_csv_data_frame, - columns=tube_columns, - well_columns=tube_well_columns) + plate_csv_data_frame = csv_data_frame.loc[csv_data_frame["Source Labware"] != "Tube"] + tube_csv_data_frame = csv_data_frame.loc[csv_data_frame["Source Labware"] == "Tube"] + sorted_plate_data_frame = sort_dataframe( + csv_data_frame=plate_csv_data_frame, columns=plate_columns, well_columns=plate_well_columns + ) + sorted_tube_data_frame = sort_dataframe( + csv_data_frame=tube_csv_data_frame, columns=tube_columns, well_columns=tube_well_columns + ) sorted_data = pd.concat([sorted_plate_data_frame, sorted_tube_data_frame]) sorted_data.to_csv(file.absolute(), index=False) diff --git a/cg_lims/get/artifacts.py b/cg_lims/get/artifacts.py index 1a335744..717b4be6 100644 --- a/cg_lims/get/artifacts.py +++ b/cg_lims/get/artifacts.py @@ -1,13 +1,12 @@ -from typing import Dict, List, Optional, Literal, Set, Tuple +import logging +from datetime import datetime +from enum import Enum +from typing import Dict, List, Literal, Optional, Set, Tuple +from cg_lims.exceptions import FileError, MissingArtifactError from genologics.entities import Artifact, Process, Sample from genologics.lims import Lims -from cg_lims.exceptions import FileError, MissingArtifactError -from datetime import datetime -import logging -from enum import Enum - LOG = logging.getLogger(__name__) diff --git a/cg_lims/get/samples.py b/cg_lims/get/samples.py index 828928ac..c1ce872f 100644 --- a/cg_lims/get/samples.py +++ b/cg_lims/get/samples.py @@ -1,9 +1,8 @@ +import logging from typing import List -from genologics.entities import Artifact, Process, Sample - from cg_lims.exceptions import MissingSampleError -import logging +from genologics.entities import Artifact, Process, Sample LOG = logging.getLogger(__name__) diff --git a/cg_lims/get/udfs.py b/cg_lims/get/udfs.py index ed5f9db5..465cac57 100644 --- a/cg_lims/get/udfs.py +++ b/cg_lims/get/udfs.py @@ -1,11 +1,11 @@ +import logging from datetime import date from enum import Enum from typing import Optional -from genologics.entities import Entity, Artifact -from genologics.lims import Lims from cg_lims.exceptions import MissingUDFsError -import logging +from genologics.entities import Artifact, Entity +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/models/api/master_steps/__init__.py b/cg_lims/models/api/master_steps/__init__.py index 26f21a34..f43e3594 100644 --- a/cg_lims/models/api/master_steps/__init__.py +++ b/cg_lims/models/api/master_steps/__init__.py @@ -1,9 +1,9 @@ -from .buffer_exchange_v2 import BufferExchange -from .pool_samples_twist_v2 import PoolsamplesforhybridizationTWIST -from .bead_purification_twist_v2 import BeadPurificationTWIST -from .hybridize_library_twist_v2 import HybridizeLibraryTWIST from .aliquot_samples_for_enzymatic_fragmentation_twist import ( AliquotsamplesforenzymaticfragmentationTWIST, ) +from .bead_purification_twist_v2 import BeadPurificationTWIST +from .buffer_exchange_v2 import BufferExchange from .capture_and_wash_twist_v2 import CaptureandWashTWIST +from .hybridize_library_twist_v2 import HybridizeLibraryTWIST from .kapa_library_preparation_twist_v1 import KAPALibraryPreparation +from .pool_samples_twist_v2 import PoolsamplesforhybridizationTWIST diff --git a/cg_lims/models/api/master_steps/aliquot_samples_for_enzymatic_fragmentation_twist.py b/cg_lims/models/api/master_steps/aliquot_samples_for_enzymatic_fragmentation_twist.py index df5ab0c6..82f6e4f8 100644 --- a/cg_lims/models/api/master_steps/aliquot_samples_for_enzymatic_fragmentation_twist.py +++ b/cg_lims/models/api/master_steps/aliquot_samples_for_enzymatic_fragmentation_twist.py @@ -1,15 +1,10 @@ from typing import Optional +from cg_lims.get.artifacts import get_latest_analyte +from cg_lims.models.api.master_steps.base_step import BaseStep, get_artifact_udf, get_process_udf from genologics.entities import Artifact, Process from pydantic.v1 import Field, validator -from cg_lims.models.api.master_steps.base_step import ( - get_artifact_udf, - BaseStep, - get_process_udf, -) -from cg_lims.get.artifacts import get_latest_analyte - class AliquotsamplesforenzymaticfragmentationTWIST(BaseStep): "Aliquot samples for enzymatic fragmentation TWIST" diff --git a/cg_lims/models/api/master_steps/bead_purification_twist_v2.py b/cg_lims/models/api/master_steps/bead_purification_twist_v2.py index 341632fb..e7b9e275 100644 --- a/cg_lims/models/api/master_steps/bead_purification_twist_v2.py +++ b/cg_lims/models/api/master_steps/bead_purification_twist_v2.py @@ -1,11 +1,10 @@ from typing import Optional +from cg_lims.get.artifacts import get_latest_analyte +from cg_lims.models.api.master_steps.base_step import BaseStep, get_artifact_udf from genologics.entities import Artifact from pydantic.v1 import Field, validator -from cg_lims.models.api.master_steps.base_step import get_artifact_udf, BaseStep -from cg_lims.get.artifacts import get_latest_analyte - class BeadPurificationTWIST(BaseStep): "Bead Purification TWIST v2" diff --git a/cg_lims/models/api/master_steps/buffer_exchange_v2.py b/cg_lims/models/api/master_steps/buffer_exchange_v2.py index abc496f4..cc1654de 100644 --- a/cg_lims/models/api/master_steps/buffer_exchange_v2.py +++ b/cg_lims/models/api/master_steps/buffer_exchange_v2.py @@ -1,11 +1,10 @@ from typing import Optional +from cg_lims.get.artifacts import get_latest_analyte +from cg_lims.models.api.master_steps.base_step import BaseStep, get_artifact_udf from genologics.entities import Artifact from pydantic.v1 import Field, validator -from cg_lims.models.api.master_steps.base_step import get_artifact_udf, BaseStep -from cg_lims.get.artifacts import get_latest_analyte - class BufferExchange(BaseStep): artifact: Optional[Artifact] diff --git a/cg_lims/models/api/master_steps/capture_and_wash_twist_v2.py b/cg_lims/models/api/master_steps/capture_and_wash_twist_v2.py index aaf7d45f..2c94a846 100644 --- a/cg_lims/models/api/master_steps/capture_and_wash_twist_v2.py +++ b/cg_lims/models/api/master_steps/capture_and_wash_twist_v2.py @@ -1,11 +1,10 @@ from typing import Optional +from cg_lims.get.artifacts import get_latest_analyte +from cg_lims.models.api.master_steps.base_step import BaseStep, get_process_udf from genologics.entities import Artifact, Process from pydantic.v1 import Field, validator -from cg_lims.models.api.master_steps.base_step import BaseStep, get_process_udf -from cg_lims.get.artifacts import get_latest_analyte - class CaptureandWashTWIST(BaseStep): "Capture and Wash TWIST v2" diff --git a/cg_lims/models/api/master_steps/hybridize_library_twist_v2.py b/cg_lims/models/api/master_steps/hybridize_library_twist_v2.py index 8daa117c..8c582393 100644 --- a/cg_lims/models/api/master_steps/hybridize_library_twist_v2.py +++ b/cg_lims/models/api/master_steps/hybridize_library_twist_v2.py @@ -1,15 +1,10 @@ from typing import Optional +from cg_lims.get.artifacts import get_latest_analyte +from cg_lims.models.api.master_steps.base_step import BaseStep, get_artifact_udf, get_process_udf from genologics.entities import Artifact, Process from pydantic.v1 import Field, validator -from cg_lims.models.api.master_steps.base_step import ( - get_artifact_udf, - BaseStep, - get_process_udf, -) -from cg_lims.get.artifacts import get_latest_analyte - class HybridizeLibraryTWIST(BaseStep): "Hybridize Library TWIST v2" diff --git a/cg_lims/models/api/master_steps/kapa_library_preparation_twist_v1.py b/cg_lims/models/api/master_steps/kapa_library_preparation_twist_v1.py index 71d46b05..db168d47 100644 --- a/cg_lims/models/api/master_steps/kapa_library_preparation_twist_v1.py +++ b/cg_lims/models/api/master_steps/kapa_library_preparation_twist_v1.py @@ -1,15 +1,10 @@ from typing import Optional +from cg_lims.get.artifacts import get_latest_analyte +from cg_lims.models.api.master_steps.base_step import BaseStep, get_artifact_udf, get_process_udf from genologics.entities import Artifact, Process from pydantic.v1 import Field, validator -from cg_lims.models.api.master_steps.base_step import ( - get_artifact_udf, - BaseStep, - get_process_udf, -) -from cg_lims.get.artifacts import get_latest_analyte - class KAPALibraryPreparation(BaseStep): "KAPA Library Preparation" diff --git a/cg_lims/models/api/master_steps/pool_samples_twist_v2.py b/cg_lims/models/api/master_steps/pool_samples_twist_v2.py index 132785fc..323ac1be 100644 --- a/cg_lims/models/api/master_steps/pool_samples_twist_v2.py +++ b/cg_lims/models/api/master_steps/pool_samples_twist_v2.py @@ -1,11 +1,10 @@ from typing import Optional +from cg_lims.get.artifacts import get_latest_analyte +from cg_lims.models.api.master_steps.base_step import BaseStep, get_artifact_name, get_artifact_udf from genologics.entities import Artifact, Process from pydantic.v1 import Field, validator -from cg_lims.models.api.master_steps.base_step import get_artifact_udf, get_artifact_name, BaseStep -from cg_lims.get.artifacts import get_latest_analyte - class PoolsamplesforhybridizationTWIST(BaseStep): "pool samples TWIST v2" diff --git a/cg_lims/models/api/sample.py b/cg_lims/models/api/sample.py index 32b7149b..4a8afd16 100644 --- a/cg_lims/models/api/sample.py +++ b/cg_lims/models/api/sample.py @@ -1,7 +1,8 @@ -from pydantic.v1 import BaseModel, Field, validator import datetime as dt -from typing import Optional import logging +from typing import Optional + +from pydantic.v1 import BaseModel, Field, validator LOG = logging.getLogger(__name__) diff --git a/cg_lims/models/arnold/base_step.py b/cg_lims/models/arnold/base_step.py index c5b146e8..b8ea34cd 100644 --- a/cg_lims/models/arnold/base_step.py +++ b/cg_lims/models/arnold/base_step.py @@ -1,7 +1,8 @@ import logging -from typing import Optional -from pydantic.v1 import Field, BaseModel, validator from datetime import date, datetime +from typing import Optional + +from pydantic.v1 import BaseModel, Field, validator LOG = logging.getLogger(__name__) diff --git a/cg_lims/models/arnold/flow_cell.py b/cg_lims/models/arnold/flow_cell.py index 6081c428..a18fc349 100644 --- a/cg_lims/models/arnold/flow_cell.py +++ b/cg_lims/models/arnold/flow_cell.py @@ -1,5 +1,5 @@ -from typing import Optional, List from datetime import date, datetime +from typing import List, Optional from pydantic.v1 import BaseModel, Field, validator diff --git a/cg_lims/models/arnold/prep/microbial_prep/__init__.py b/cg_lims/models/arnold/prep/microbial_prep/__init__.py index fa0958ae..2f5310ec 100644 --- a/cg_lims/models/arnold/prep/microbial_prep/__init__.py +++ b/cg_lims/models/arnold/prep/microbial_prep/__init__.py @@ -1,14 +1,14 @@ from typing import List +from cg_lims.models.arnold.base_step import BaseStep from genologics.lims import Lims -from .reception_control import get_sample_artifact_fields -from .microbial_library_prep_nextera import get_library_prep_nextera -from .normalization_of_microbial_samples import get_normalization_of_mictobial_samples from .buffer_exchange import get_buffer_exchange +from .microbial_library_prep_nextera import get_library_prep_nextera from .normailzation_of_microbial_samples_for_sequencing import get_normalization_of_samples +from .normalization_of_microbial_samples import get_normalization_of_mictobial_samples from .post_pcr_bead_purification import get_post_bead_pcr_purification -from cg_lims.models.arnold.base_step import BaseStep +from .reception_control import get_sample_artifact_fields def build_microbial_step_documents(sample_id: str, process_id: str, lims: Lims) -> List[BaseStep]: diff --git a/cg_lims/models/arnold/prep/microbial_prep/buffer_exchange.py b/cg_lims/models/arnold/prep/microbial_prep/buffer_exchange.py index f3a16d8a..0608ff9e 100644 --- a/cg_lims/models/arnold/prep/microbial_prep/buffer_exchange.py +++ b/cg_lims/models/arnold/prep/microbial_prep/buffer_exchange.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ArtifactUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/microbial_prep/microbial_library_prep_nextera.py b/cg_lims/models/arnold/prep/microbial_prep/microbial_library_prep_nextera.py index 1fcd021a..bf6ae287 100644 --- a/cg_lims/models/arnold/prep/microbial_prep/microbial_library_prep_nextera.py +++ b/cg_lims/models/arnold/prep/microbial_prep/microbial_library_prep_nextera.py @@ -1,10 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFS(BaseModel): diff --git a/cg_lims/models/arnold/prep/microbial_prep/normailzation_of_microbial_samples_for_sequencing.py b/cg_lims/models/arnold/prep/microbial_prep/normailzation_of_microbial_samples_for_sequencing.py index b17646d3..34274efe 100644 --- a/cg_lims/models/arnold/prep/microbial_prep/normailzation_of_microbial_samples_for_sequencing.py +++ b/cg_lims/models/arnold/prep/microbial_prep/normailzation_of_microbial_samples_for_sequencing.py @@ -1,10 +1,11 @@ import logging from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field + from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel LOG = logging.getLogger(__name__) diff --git a/cg_lims/models/arnold/prep/microbial_prep/normalization_of_microbial_samples.py b/cg_lims/models/arnold/prep/microbial_prep/normalization_of_microbial_samples.py index 08095f79..210c42c0 100644 --- a/cg_lims/models/arnold/prep/microbial_prep/normalization_of_microbial_samples.py +++ b/cg_lims/models/arnold/prep/microbial_prep/normalization_of_microbial_samples.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/microbial_prep/post_pcr_bead_purification.py b/cg_lims/models/arnold/prep/microbial_prep/post_pcr_bead_purification.py index 0998ce32..de4f9533 100644 --- a/cg_lims/models/arnold/prep/microbial_prep/post_pcr_bead_purification.py +++ b/cg_lims/models/arnold/prep/microbial_prep/post_pcr_bead_purification.py @@ -1,12 +1,11 @@ import logging from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel LOG = logging.getLogger(__name__) diff --git a/cg_lims/models/arnold/prep/microbial_prep/reception_control.py b/cg_lims/models/arnold/prep/microbial_prep/reception_control.py index e0425124..bfa25586 100644 --- a/cg_lims/models/arnold/prep/microbial_prep/reception_control.py +++ b/cg_lims/models/arnold/prep/microbial_prep/reception_control.py @@ -1,9 +1,10 @@ from typing import Optional + +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field -from cg_lims.objects import BaseAnalyte -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class SampleArtifactUDF(BaseModel): diff --git a/cg_lims/models/arnold/prep/rna/__init__.py b/cg_lims/models/arnold/prep/rna/__init__.py index 0dd4d856..6064ce45 100644 --- a/cg_lims/models/arnold/prep/rna/__init__.py +++ b/cg_lims/models/arnold/prep/rna/__init__.py @@ -1,12 +1,12 @@ from typing import List +from cg_lims.models.arnold.base_step import BaseStep from genologics.lims import Lims from .a_tailing_and_adapter_ligation import get_a_tailning_and_adapter_ligation from .aliquot_samples_for_fragmentation import get_aliquot_samples_for_enzymatic_fragmentation -from .reception_control import get_sample_artifact_fields from .normalization_of_samples_for_sequencing import get_normalization_of_samples -from cg_lims.models.arnold.base_step import BaseStep +from .reception_control import get_sample_artifact_fields def build_rna_documents(sample_id: str, process_id: str, lims: Lims) -> List[BaseStep]: diff --git a/cg_lims/models/arnold/prep/rna/a_tailing_and_adapter_ligation.py b/cg_lims/models/arnold/prep/rna/a_tailing_and_adapter_ligation.py index ec218838..14d46349 100644 --- a/cg_lims/models/arnold/prep/rna/a_tailing_and_adapter_ligation.py +++ b/cg_lims/models/arnold/prep/rna/a_tailing_and_adapter_ligation.py @@ -1,11 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field - -from cg_lims.objects import BaseAnalyte -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/rna/aliquot_samples_for_fragmentation.py b/cg_lims/models/arnold/prep/rna/aliquot_samples_for_fragmentation.py index 7421c1eb..39728fff 100644 --- a/cg_lims/models/arnold/prep/rna/aliquot_samples_for_fragmentation.py +++ b/cg_lims/models/arnold/prep/rna/aliquot_samples_for_fragmentation.py @@ -1,11 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field - -from cg_lims.objects import BaseAnalyte -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/rna/normalization_of_samples_for_sequencing.py b/cg_lims/models/arnold/prep/rna/normalization_of_samples_for_sequencing.py index 76343d5c..60cc453c 100644 --- a/cg_lims/models/arnold/prep/rna/normalization_of_samples_for_sequencing.py +++ b/cg_lims/models/arnold/prep/rna/normalization_of_samples_for_sequencing.py @@ -1,10 +1,11 @@ import logging from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field + from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel LOG = logging.getLogger(__name__) diff --git a/cg_lims/models/arnold/prep/rna/reception_control.py b/cg_lims/models/arnold/prep/rna/reception_control.py index de01cfe5..e1d9faee 100644 --- a/cg_lims/models/arnold/prep/rna/reception_control.py +++ b/cg_lims/models/arnold/prep/rna/reception_control.py @@ -1,10 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field -from cg_lims.objects import BaseAnalyte -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class SampleArtifactUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/sars_cov_2_prep/__init__.py b/cg_lims/models/arnold/prep/sars_cov_2_prep/__init__.py index 239c4595..7c47c258 100644 --- a/cg_lims/models/arnold/prep/sars_cov_2_prep/__init__.py +++ b/cg_lims/models/arnold/prep/sars_cov_2_prep/__init__.py @@ -1,10 +1,11 @@ from typing import List +from cg_lims.models.arnold.base_step import BaseStep from genologics.lims import Lims + from .library_preparation import get_library_prep_cov from .pooling_and_cleanup import get_pooling_and_cleanup from .reception_control import get_sample_artifact_fields -from cg_lims.models.arnold.base_step import BaseStep def build_sars_cov_2_documents(sample_id: str, process_id: str, lims: Lims) -> List[BaseStep]: diff --git a/cg_lims/models/arnold/prep/sars_cov_2_prep/library_preparation.py b/cg_lims/models/arnold/prep/sars_cov_2_prep/library_preparation.py index 416e907d..2e6214ed 100644 --- a/cg_lims/models/arnold/prep/sars_cov_2_prep/library_preparation.py +++ b/cg_lims/models/arnold/prep/sars_cov_2_prep/library_preparation.py @@ -1,11 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field - -from cg_lims.objects import BaseAnalyte -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/sars_cov_2_prep/pooling_and_cleanup.py b/cg_lims/models/arnold/prep/sars_cov_2_prep/pooling_and_cleanup.py index 94c9b9c3..2e633103 100644 --- a/cg_lims/models/arnold/prep/sars_cov_2_prep/pooling_and_cleanup.py +++ b/cg_lims/models/arnold/prep/sars_cov_2_prep/pooling_and_cleanup.py @@ -1,12 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field - -from cg_lims.objects import BaseAnalyte - -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/sars_cov_2_prep/reception_control.py b/cg_lims/models/arnold/prep/sars_cov_2_prep/reception_control.py index 95e6c962..09c1ff51 100644 --- a/cg_lims/models/arnold/prep/sars_cov_2_prep/reception_control.py +++ b/cg_lims/models/arnold/prep/sars_cov_2_prep/reception_control.py @@ -1,10 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field -from cg_lims.objects import BaseAnalyte -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class SampleArtifactUDF(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/__init__.py b/cg_lims/models/arnold/prep/twist/__init__.py index 7509feb6..7a4c01a3 100644 --- a/cg_lims/models/arnold/prep/twist/__init__.py +++ b/cg_lims/models/arnold/prep/twist/__init__.py @@ -1,20 +1,21 @@ from typing import List +from cg_lims.models.arnold.base_step import BaseStep from genologics.lims import Lims -from .buffer_exchange import get_buffer_exchange_twist -from .capture_and_wash_twist import get_capture_and_wash -from .pool_samples_twist import get_pool_samples_twist -from .hybridize_library_twist import get_hybridize_library_twist -from .bead_purification_twist import get_bead_purification_twist -from .kapa_library_preparation_twist import get_kapa_library_preparation_twist + from .aliquot_samples_for_enzymatic_fragmentation_twist import ( get_aliquot_samples_for_enzymatic_fragmentation, ) from .amplify_captured_libraries import get_amplify_captured_library_udfs +from .bead_purification_twist import get_bead_purification_twist +from .buffer_exchange import get_buffer_exchange_twist +from .capture_and_wash_twist import get_capture_and_wash from .enzymatic_fragmentation_twist import get_enzymatic_fragmentation -from .reception_control import get_sample_artifact_fields -from cg_lims.models.arnold.base_step import BaseStep +from .hybridize_library_twist import get_hybridize_library_twist +from .kapa_library_preparation_twist import get_kapa_library_preparation_twist from .normalization_of_samples_for_sequencing import get_normalization_of_samples +from .pool_samples_twist import get_pool_samples_twist +from .reception_control import get_sample_artifact_fields def build_twist_documents(sample_id: str, process_id: str, lims: Lims) -> List[BaseStep]: diff --git a/cg_lims/models/arnold/prep/twist/aliquot_samples_for_enzymatic_fragmentation_twist.py b/cg_lims/models/arnold/prep/twist/aliquot_samples_for_enzymatic_fragmentation_twist.py index f548bb40..49c46630 100644 --- a/cg_lims/models/arnold/prep/twist/aliquot_samples_for_enzymatic_fragmentation_twist.py +++ b/cg_lims/models/arnold/prep/twist/aliquot_samples_for_enzymatic_fragmentation_twist.py @@ -1,10 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel - -from cg_lims.objects import BaseAnalyte from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/amplify_captured_libraries.py b/cg_lims/models/arnold/prep/twist/amplify_captured_libraries.py index 162bf6bd..8829f27f 100644 --- a/cg_lims/models/arnold/prep/twist/amplify_captured_libraries.py +++ b/cg_lims/models/arnold/prep/twist/amplify_captured_libraries.py @@ -1,8 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel -from cg_lims.objects import BaseAnalyte + from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/bead_purification_twist.py b/cg_lims/models/arnold/prep/twist/bead_purification_twist.py index 0565efbb..04318973 100644 --- a/cg_lims/models/arnold/prep/twist/bead_purification_twist.py +++ b/cg_lims/models/arnold/prep/twist/bead_purification_twist.py @@ -1,9 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel -from cg_lims.objects import BaseAnalyte from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class ArtifactUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/buffer_exchange.py b/cg_lims/models/arnold/prep/twist/buffer_exchange.py index 13d69b40..0150e952 100644 --- a/cg_lims/models/arnold/prep/twist/buffer_exchange.py +++ b/cg_lims/models/arnold/prep/twist/buffer_exchange.py @@ -1,11 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel - -from cg_lims.objects import BaseAnalyte - from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class ArtifactUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/capture_and_wash_twist.py b/cg_lims/models/arnold/prep/twist/capture_and_wash_twist.py index 91279a36..5bac6b77 100644 --- a/cg_lims/models/arnold/prep/twist/capture_and_wash_twist.py +++ b/cg_lims/models/arnold/prep/twist/capture_and_wash_twist.py @@ -1,10 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel - -from cg_lims.objects import BaseAnalyte from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/enzymatic_fragmentation_twist.py b/cg_lims/models/arnold/prep/twist/enzymatic_fragmentation_twist.py index f1fc2778..a118d726 100644 --- a/cg_lims/models/arnold/prep/twist/enzymatic_fragmentation_twist.py +++ b/cg_lims/models/arnold/prep/twist/enzymatic_fragmentation_twist.py @@ -1,10 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel - -from cg_lims.objects import BaseAnalyte from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class ProcessUdfs(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/hybridize_library_twist.py b/cg_lims/models/arnold/prep/twist/hybridize_library_twist.py index cb34be79..f12d9307 100644 --- a/cg_lims/models/arnold/prep/twist/hybridize_library_twist.py +++ b/cg_lims/models/arnold/prep/twist/hybridize_library_twist.py @@ -1,9 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel -from cg_lims.objects import BaseAnalyte from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class ArtifactUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/kapa_library_preparation_twist.py b/cg_lims/models/arnold/prep/twist/kapa_library_preparation_twist.py index d2dba15f..eace0965 100644 --- a/cg_lims/models/arnold/prep/twist/kapa_library_preparation_twist.py +++ b/cg_lims/models/arnold/prep/twist/kapa_library_preparation_twist.py @@ -1,9 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class ArtifactUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/normalization_of_samples_for_sequencing.py b/cg_lims/models/arnold/prep/twist/normalization_of_samples_for_sequencing.py index 9700965e..4abe3a69 100644 --- a/cg_lims/models/arnold/prep/twist/normalization_of_samples_for_sequencing.py +++ b/cg_lims/models/arnold/prep/twist/normalization_of_samples_for_sequencing.py @@ -1,10 +1,11 @@ import logging from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field + from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel LOG = logging.getLogger(__name__) diff --git a/cg_lims/models/arnold/prep/twist/pool_samples_twist.py b/cg_lims/models/arnold/prep/twist/pool_samples_twist.py index b33c6a24..64a30a85 100644 --- a/cg_lims/models/arnold/prep/twist/pool_samples_twist.py +++ b/cg_lims/models/arnold/prep/twist/pool_samples_twist.py @@ -1,9 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel -from cg_lims.objects import BaseAnalyte from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class ArtifactUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/twist/reception_control.py b/cg_lims/models/arnold/prep/twist/reception_control.py index 42ac0e4e..9392dfef 100644 --- a/cg_lims/models/arnold/prep/twist/reception_control.py +++ b/cg_lims/models/arnold/prep/twist/reception_control.py @@ -1,11 +1,9 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1 import Field, BaseModel - -from cg_lims.objects import BaseAnalyte - from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import BaseModel, Field class SampleArtifactUDF(BaseModel): diff --git a/cg_lims/models/arnold/prep/wgs/__init__.py b/cg_lims/models/arnold/prep/wgs/__init__.py index 93af6557..77fc2dfd 100644 --- a/cg_lims/models/arnold/prep/wgs/__init__.py +++ b/cg_lims/models/arnold/prep/wgs/__init__.py @@ -1,12 +1,12 @@ from typing import List +from cg_lims.models.arnold.base_step import BaseStep from genologics.lims import Lims -from .fragment_dna_truseq_dna import get_fragemnt_dna_truseq from .aliquot_sampels_for_covaris import get_aliquot_samples_for_covaris -from .reception_control import get_sample_artifact_fields from .endrepair_size_selection_a_tailing_adapter_ligation import get_end_repair -from cg_lims.models.arnold.base_step import BaseStep +from .fragment_dna_truseq_dna import get_fragemnt_dna_truseq +from .reception_control import get_sample_artifact_fields def build_wgs_documents(sample_id: str, process_id: str, lims: Lims) -> List[BaseStep]: diff --git a/cg_lims/models/arnold/prep/wgs/aliquot_sampels_for_covaris.py b/cg_lims/models/arnold/prep/wgs/aliquot_sampels_for_covaris.py index 23f9076e..723ebade 100644 --- a/cg_lims/models/arnold/prep/wgs/aliquot_sampels_for_covaris.py +++ b/cg_lims/models/arnold/prep/wgs/aliquot_sampels_for_covaris.py @@ -1,10 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field -from cg_lims.objects import BaseAnalyte -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class ArtifactUDF(BaseModel): diff --git a/cg_lims/models/arnold/prep/wgs/endrepair_size_selection_a_tailing_adapter_ligation.py b/cg_lims/models/arnold/prep/wgs/endrepair_size_selection_a_tailing_adapter_ligation.py index 19ab9afd..0c80ccba 100644 --- a/cg_lims/models/arnold/prep/wgs/endrepair_size_selection_a_tailing_adapter_ligation.py +++ b/cg_lims/models/arnold/prep/wgs/endrepair_size_selection_a_tailing_adapter_ligation.py @@ -1,11 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field - -from cg_lims.objects import BaseAnalyte -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/prep/wgs/fragment_dna_truseq_dna.py b/cg_lims/models/arnold/prep/wgs/fragment_dna_truseq_dna.py index 36cfb3c2..ec58db15 100644 --- a/cg_lims/models/arnold/prep/wgs/fragment_dna_truseq_dna.py +++ b/cg_lims/models/arnold/prep/wgs/fragment_dna_truseq_dna.py @@ -1,11 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field - -from cg_lims.objects import BaseAnalyte -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class ProcessUDFS(BaseModel): diff --git a/cg_lims/models/arnold/prep/wgs/reception_control.py b/cg_lims/models/arnold/prep/wgs/reception_control.py index 07434c07..c41b77da 100644 --- a/cg_lims/models/arnold/prep/wgs/reception_control.py +++ b/cg_lims/models/arnold/prep/wgs/reception_control.py @@ -1,12 +1,10 @@ from typing import Optional +from cg_lims.models.arnold.base_step import BaseStep +from cg_lims.objects import BaseAnalyte from genologics.lims import Lims -from pydantic.v1.main import BaseModel from pydantic.v1 import Field - -from cg_lims.objects import BaseAnalyte - -from cg_lims.models.arnold.base_step import BaseStep +from pydantic.v1.main import BaseModel class SampleArtifactUDF(BaseModel): diff --git a/cg_lims/models/arnold/sample.py b/cg_lims/models/arnold/sample.py index 4c378cd7..38532ad0 100644 --- a/cg_lims/models/arnold/sample.py +++ b/cg_lims/models/arnold/sample.py @@ -1,8 +1,9 @@ import datetime +from datetime import date, datetime from typing import Optional + from pydantic.v1 import Field, validator from pydantic.v1.main import BaseModel -from datetime import date, datetime def get_number_of_days(first_date: str, second_date: str) -> Optional[int]: diff --git a/cg_lims/models/arnold/sequencing/novaseq_6000/__init__.py b/cg_lims/models/arnold/sequencing/novaseq_6000/__init__.py index 7017b5d0..378fe066 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_6000/__init__.py +++ b/cg_lims/models/arnold/sequencing/novaseq_6000/__init__.py @@ -1,14 +1,14 @@ from typing import List +from cg_lims.models.arnold.base_step import BaseStep from genologics.lims import Lims +from .bcl_conversion_and_demultiplexing import get_bcl_conversion_and_demultiplexing from .define_run_format import get_define_run_format from .standard_make_pool_and_denature import get_standard_make_pool_and_denature from .standard_prepare_for_sequencing import get_standard_prepare_for_sequencing from .xp_denature_and_examp import get_xp_denature_and_examp from .xp_load_to_flowcell import get_xp_load_to_flowcell -from .bcl_conversion_and_demultiplexing import get_bcl_conversion_and_demultiplexing -from cg_lims.models.arnold.base_step import BaseStep def build_novaseq_6000_step_documents( diff --git a/cg_lims/models/arnold/sequencing/novaseq_6000/bcl_conversion_and_demultiplexing.py b/cg_lims/models/arnold/sequencing/novaseq_6000/bcl_conversion_and_demultiplexing.py index 45091b11..93997bfa 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_6000/bcl_conversion_and_demultiplexing.py +++ b/cg_lims/models/arnold/sequencing/novaseq_6000/bcl_conversion_and_demultiplexing.py @@ -1,12 +1,11 @@ from statistics import mean -from typing import Optional, List - -from genologics.lims import Lims, Process, Artifact -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field +from typing import List, Optional from cg_lims.get.artifacts import get_artifacts from cg_lims.models.arnold.base_step import BaseStep +from genologics.lims import Artifact, Lims, Process +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/sequencing/novaseq_6000/define_run_format.py b/cg_lims/models/arnold/sequencing/novaseq_6000/define_run_format.py index 653e27b1..6a29eb6b 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_6000/define_run_format.py +++ b/cg_lims/models/arnold/sequencing/novaseq_6000/define_run_format.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/sequencing/novaseq_6000/standard_make_pool_and_denature.py b/cg_lims/models/arnold/sequencing/novaseq_6000/standard_make_pool_and_denature.py index af2c7402..3cbe858b 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_6000/standard_make_pool_and_denature.py +++ b/cg_lims/models/arnold/sequencing/novaseq_6000/standard_make_pool_and_denature.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/sequencing/novaseq_6000/standard_prepare_for_sequencing.py b/cg_lims/models/arnold/sequencing/novaseq_6000/standard_prepare_for_sequencing.py index 030ef371..3e5c61cd 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_6000/standard_prepare_for_sequencing.py +++ b/cg_lims/models/arnold/sequencing/novaseq_6000/standard_prepare_for_sequencing.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/sequencing/novaseq_6000/xp_denature_and_examp.py b/cg_lims/models/arnold/sequencing/novaseq_6000/xp_denature_and_examp.py index 31a812ba..d78faff3 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_6000/xp_denature_and_examp.py +++ b/cg_lims/models/arnold/sequencing/novaseq_6000/xp_denature_and_examp.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/sequencing/novaseq_6000/xp_load_to_flowcell.py b/cg_lims/models/arnold/sequencing/novaseq_6000/xp_load_to_flowcell.py index ad9fbddc..8f8b3068 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_6000/xp_load_to_flowcell.py +++ b/cg_lims/models/arnold/sequencing/novaseq_6000/xp_load_to_flowcell.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/sequencing/novaseq_x/__init__.py b/cg_lims/models/arnold/sequencing/novaseq_x/__init__.py index 6354544e..8feff6b6 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_x/__init__.py +++ b/cg_lims/models/arnold/sequencing/novaseq_x/__init__.py @@ -1,12 +1,12 @@ from typing import List +from cg_lims.models.arnold.base_step import BaseStep from genologics.lims import Lims +from .bcl_conversion_and_demultiplexing import get_bcl_conversion_and_demultiplexing from .define_run_format import get_define_run_format from .make_pool_and_denature import get_make_pool_and_denature from .prepare_for_sequencing import get_prepare_for_sequencing -from .bcl_conversion_and_demultiplexing import get_bcl_conversion_and_demultiplexing -from cg_lims.models.arnold.base_step import BaseStep def build_novaseq_x_step_documents(sample_id: str, process_id: str, lims: Lims) -> List[BaseStep]: diff --git a/cg_lims/models/arnold/sequencing/novaseq_x/bcl_conversion_and_demultiplexing.py b/cg_lims/models/arnold/sequencing/novaseq_x/bcl_conversion_and_demultiplexing.py index 8307f558..1ef90bb6 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_x/bcl_conversion_and_demultiplexing.py +++ b/cg_lims/models/arnold/sequencing/novaseq_x/bcl_conversion_and_demultiplexing.py @@ -1,12 +1,11 @@ from statistics import mean -from typing import Optional, List - -from genologics.lims import Lims, Process, Artifact -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field +from typing import List, Optional from cg_lims.get.artifacts import get_artifacts from cg_lims.models.arnold.base_step import BaseStep +from genologics.lims import Artifact, Lims, Process +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/sequencing/novaseq_x/define_run_format.py b/cg_lims/models/arnold/sequencing/novaseq_x/define_run_format.py index c0bec062..b097cb6c 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_x/define_run_format.py +++ b/cg_lims/models/arnold/sequencing/novaseq_x/define_run_format.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/sequencing/novaseq_x/make_pool_and_denature.py b/cg_lims/models/arnold/sequencing/novaseq_x/make_pool_and_denature.py index 59a43e6a..6413e5b1 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_x/make_pool_and_denature.py +++ b/cg_lims/models/arnold/sequencing/novaseq_x/make_pool_and_denature.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/models/arnold/sequencing/novaseq_x/prepare_for_sequencing.py b/cg_lims/models/arnold/sequencing/novaseq_x/prepare_for_sequencing.py index db2b9b24..1a2a9dd7 100644 --- a/cg_lims/models/arnold/sequencing/novaseq_x/prepare_for_sequencing.py +++ b/cg_lims/models/arnold/sequencing/novaseq_x/prepare_for_sequencing.py @@ -1,11 +1,10 @@ from typing import Optional -from genologics.lims import Lims -from pydantic.v1.main import BaseModel -from pydantic.v1 import Field - from cg_lims.models.arnold.base_step import BaseStep from cg_lims.objects import BaseAnalyte +from genologics.lims import Lims +from pydantic.v1 import Field +from pydantic.v1.main import BaseModel class ProcessUDFs(BaseModel): diff --git a/cg_lims/objects.py b/cg_lims/objects.py index 5db22943..128d075e 100644 --- a/cg_lims/objects.py +++ b/cg_lims/objects.py @@ -1,21 +1,18 @@ """Base cg_lims calss definitions """ +import logging from typing import Optional -from genologics.entities import Artifact, Sample, Process +from genologics.entities import Artifact, Process, Sample from genologics.lims import Lims from cg_lims.exceptions import ( - MissingUDFsError, - ZeroReadsError, MissingArtifactError, MissingProcessError, + MissingUDFsError, + ZeroReadsError, ) -from cg_lims.get.artifacts import ( - get_sample_artifact, - get_latest_analyte, -) -import logging +from cg_lims.get.artifacts import get_latest_analyte, get_sample_artifact LOG = logging.getLogger(__name__) diff --git a/cg_lims/put/queue.py b/cg_lims/put/queue.py index 75c6351f..9906f947 100644 --- a/cg_lims/put/queue.py +++ b/cg_lims/put/queue.py @@ -1,12 +1,11 @@ import logging from typing import List +from cg_lims.get.ids import unique_list_of_ids from genologics.config import BASEURI from genologics.entities import Artifact from genologics.lims import Lims -from cg_lims.get.ids import unique_list_of_ids - LOG = logging.getLogger(__name__) from cg_lims.exceptions import MissingArtifactError, QueueArtifactsError diff --git a/cg_lims/scripts/base.py b/cg_lims/scripts/base.py index d13ab393..197d6ac0 100644 --- a/cg_lims/scripts/base.py +++ b/cg_lims/scripts/base.py @@ -7,9 +7,9 @@ # commands from .check_config import check_config -from .prepare_fixture import make_fixure -from .one_time_scripts.base import one_time from .fetch_sample_info import fetch_sample_info +from .one_time_scripts.base import one_time +from .prepare_fixture import make_fixure @click.group(invoke_without_command=True) diff --git a/cg_lims/scripts/check_config.py b/cg_lims/scripts/check_config.py index 22145bc5..c706754f 100644 --- a/cg_lims/scripts/check_config.py +++ b/cg_lims/scripts/check_config.py @@ -1,8 +1,8 @@ -import click -from genologics.lims import Lims +import logging +import click from cg_lims import options -import logging +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/scripts/fetch_sample_info.py b/cg_lims/scripts/fetch_sample_info.py index af2d573e..eb8869d9 100644 --- a/cg_lims/scripts/fetch_sample_info.py +++ b/cg_lims/scripts/fetch_sample_info.py @@ -1,12 +1,12 @@ -import click import csv import logging -from genologics.lims import Lims -from genologics.entities import Sample +from typing import List +import click from cg_lims.exceptions import LimsError from cg_lims.get.artifacts import get_sample_artifact -from typing import List +from genologics.entities import Sample +from genologics.lims import Lims LOG = logging.getLogger(__name__) @@ -19,7 +19,9 @@ def check_cancelled_status(sample: Sample) -> bool: return True -def get_samples_from_source(source_types: List[str], skip_cancelled: bool, lims: Lims) -> List[Sample]: +def get_samples_from_source( + source_types: List[str], skip_cancelled: bool, lims: Lims +) -> List[Sample]: samples_from_sources = [] for source in source_types: udf_dict = {"Source": source} @@ -34,21 +36,22 @@ def get_samples_from_source(source_types: List[str], skip_cancelled: bool, lims: samples_from_sources.append(sample) message = f"Found {len(found_samples)} sample(s) of source type '{source}'." if skip_cancelled: - message = message + f" Skipped {cancelled_samples} of them because of cancellation status." + message = ( + message + f" Skipped {cancelled_samples} of them because of cancellation status." + ) LOG.info(message) click.echo(message) return samples_from_sources def print_fetched_samples( - samples: List[Sample], - udf_name: str, - max_amount: str, - min_amount: str, - file_path: str, - lims: Lims, + samples: List[Sample], + udf_name: str, + max_amount: str, + min_amount: str, + file_path: str, + lims: Lims, ) -> None: - sample_rows = [] missing_udf = 0 outside_threshold = 0 @@ -74,8 +77,10 @@ def print_fetched_samples( else: headers = ["Sample ID", udf_name, "Source"] if outside_threshold > 0 or missing_udf > 0: - message = f"Removed a total of {outside_threshold} sample(s) that did not fulfill threshold requirements" \ - f" and {missing_udf} because of missing UDF values." + message = ( + f"Removed a total of {outside_threshold} sample(s) that did not fulfill threshold requirements" + f" and {missing_udf} because of missing UDF values." + ) LOG.info(message) click.echo(message) with open(f"{file_path}.csv", "w", newline="\n") as new_csv: @@ -109,8 +114,8 @@ def print_fetched_samples( "-u", required=False, help="Fetch samples depending on a specific UDF value. " - "Use in conjecture with max and/or min value options. " - "At the moment only works on Sample Artifact UDFs.", + "Use in conjecture with max and/or min value options. " + "At the moment only works on Sample Artifact UDFs.", ) @click.option( "--file-name", @@ -126,13 +131,13 @@ def print_fetched_samples( ) @click.pass_context def fetch_sample_info( - ctx, - source_type: List[str], - max_udf_amount: str, - min_udf_amount: str, - udf_name: str, - file_name: str, - skip_cancelled: bool = False, + ctx, + source_type: List[str], + max_udf_amount: str, + min_udf_amount: str, + udf_name: str, + file_name: str, + skip_cancelled: bool = False, ): LOG.info(f"Running {ctx.command_path} with params: {ctx.params}") diff --git a/cg_lims/scripts/one_time_scripts/add_sample_meta_data.py b/cg_lims/scripts/one_time_scripts/add_sample_meta_data.py index 8f17f17f..e05c57b5 100644 --- a/cg_lims/scripts/one_time_scripts/add_sample_meta_data.py +++ b/cg_lims/scripts/one_time_scripts/add_sample_meta_data.py @@ -8,11 +8,10 @@ import coloredlogs import pandas as pd import yaml -from genologics.entities import Sample -from genologics.lims import Lims - from cg_lims import options from cg_lims.exceptions import LimsError, MissingSampleError +from genologics.entities import Sample +from genologics.lims import Lims LEVELS = ["DEBUG", "INFO", "WARNING", "ERROR"] LOG = logging.getLogger(__name__) @@ -136,14 +135,10 @@ def set_sample_meta_data( """Script to set Covid meta data on sample udf.""" with open(config) as file: config_data = yaml.load(file, Loader=yaml.FullLoader) - lims = Lims( - config_data["BASEURI"], config_data["USERNAME"], config_data["PASSWORD"] - ) + lims = Lims(config_data["BASEURI"], config_data["USERNAME"], config_data["PASSWORD"]) log_path = pathlib.Path(log) log_level = getattr(logging, log_level.upper()) - logging.basicConfig( - filename=str(log_path.absolute()), filemode="w", level=log_level - ) + logging.basicConfig(filename=str(log_path.absolute()), filemode="w", level=log_level) LOG.info(f"Running {context.command_path} with params: {context.params}") coloredlogs.install(level=log_level, fmt=LOG_FORMAT) meta_data: pd.DataFrame = pd.read_csv(data_file, sep=";") diff --git a/cg_lims/scripts/one_time_scripts/base.py b/cg_lims/scripts/one_time_scripts/base.py index 9f3fd9ed..556a5f5c 100644 --- a/cg_lims/scripts/one_time_scripts/base.py +++ b/cg_lims/scripts/one_time_scripts/base.py @@ -2,9 +2,9 @@ import click -from .load_arnold_steps import update_arnold_preps, update_arnold_runs -from .load_arnold_flowcells import update_arnold_flow_cells from .fetch_tga_samples import fetch_tga_samples +from .load_arnold_flowcells import update_arnold_flow_cells +from .load_arnold_steps import update_arnold_preps, update_arnold_runs @click.group(invoke_without_command=True) diff --git a/cg_lims/scripts/one_time_scripts/fetch_tga_samples.py b/cg_lims/scripts/one_time_scripts/fetch_tga_samples.py index bfaa1f9f..86eb981f 100644 --- a/cg_lims/scripts/one_time_scripts/fetch_tga_samples.py +++ b/cg_lims/scripts/one_time_scripts/fetch_tga_samples.py @@ -1,11 +1,11 @@ +import datetime import logging -import click from typing import List, Optional -from genologics.lims import Lims -from genologics.entities import Sample -import datetime +import click from cg_lims import options +from genologics.entities import Sample +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/scripts/one_time_scripts/load_arnold_flowcells.py b/cg_lims/scripts/one_time_scripts/load_arnold_flowcells.py index 3d100b27..2c85dcc7 100644 --- a/cg_lims/scripts/one_time_scripts/load_arnold_flowcells.py +++ b/cg_lims/scripts/one_time_scripts/load_arnold_flowcells.py @@ -2,14 +2,13 @@ from typing import List import click -from genologics.lims import Lims import requests -from requests import Response - from cg_lims import options from cg_lims.EPPs.arnold.flow_cell import build_flow_cell_document from cg_lims.get.artifacts import OutputGenerationType, OutputType, get_output_artifacts from cg_lims.models.arnold.flow_cell import FlowCell +from genologics.lims import Lims +from requests import Response LOG = logging.getLogger(__name__) diff --git a/cg_lims/scripts/one_time_scripts/load_arnold_steps.py b/cg_lims/scripts/one_time_scripts/load_arnold_steps.py index 0cb8e9c2..cad5532a 100644 --- a/cg_lims/scripts/one_time_scripts/load_arnold_steps.py +++ b/cg_lims/scripts/one_time_scripts/load_arnold_steps.py @@ -1,15 +1,14 @@ +import json import logging from typing import List, Literal import click -from genologics.lims import Lims import requests -from requests import Response -import json - from cg_lims import options from cg_lims.EPPs.arnold import prep, sequencing from cg_lims.models.arnold.base_step import BaseStep +from genologics.lims import Lims +from requests import Response LOG = logging.getLogger(__name__) diff --git a/cg_lims/scripts/one_time_scripts/process_to_artifact.py b/cg_lims/scripts/one_time_scripts/process_to_artifact.py index 193ac004..a8b15ca1 100644 --- a/cg_lims/scripts/one_time_scripts/process_to_artifact.py +++ b/cg_lims/scripts/one_time_scripts/process_to_artifact.py @@ -1,10 +1,10 @@ import logging -import click import pathlib -import yaml -from genologics.lims import Lims +import click +import yaml from cg_lims import options +from genologics.lims import Lims LOG = logging.getLogger(__name__) diff --git a/cg_lims/set/qc.py b/cg_lims/set/qc.py index 00ca1411..5699384e 100644 --- a/cg_lims/set/qc.py +++ b/cg_lims/set/qc.py @@ -1,6 +1,7 @@ +from enum import Enum from typing import Literal + from genologics.entities import Artifact -from enum import Enum class QualityCheck(str, Enum): diff --git a/cg_lims/set/udfs.py b/cg_lims/set/udfs.py index 15600492..ff5e06fd 100644 --- a/cg_lims/set/udfs.py +++ b/cg_lims/set/udfs.py @@ -1,11 +1,9 @@ import logging - from typing import List, Tuple -from genologics.entities import Artifact, Process - from cg_lims.exceptions import MissingUDFsError from cg_lims.get.udfs import UserDefinedFields +from genologics.entities import Artifact, Process LOG = logging.getLogger(__name__) diff --git a/cg_lims/status_db_api.py b/cg_lims/status_db_api.py index 08400b0a..9d3a421b 100644 --- a/cg_lims/status_db_api.py +++ b/cg_lims/status_db_api.py @@ -1,10 +1,10 @@ import json import logging from typing import Any, Dict, List + import requests from requests import Response - from cg_lims.exceptions import ( CgAPIClientConnectionError, CgAPIClientDecodeError, @@ -12,9 +12,8 @@ CgAPIClientTimeoutError, LimsError, ) -from cg_lims.token_manager import TokenManager from cg_lims.models.sample_lane_sequencing_metrics import SampleLaneSequencingMetrics - +from cg_lims.token_manager import TokenManager LOG = logging.getLogger(__name__) diff --git a/cg_lims/token_manager.py b/cg_lims/token_manager.py index 4f1dd026..c5df16c5 100644 --- a/cg_lims/token_manager.py +++ b/cg_lims/token_manager.py @@ -1,6 +1,7 @@ import logging -from google.oauth2 import service_account + import google.auth.transport.requests +from google.oauth2 import service_account LOG = logging.getLogger(__name__) diff --git a/setup.py b/setup.py index 6ce7c4fb..a4135b2e 100644 --- a/setup.py +++ b/setup.py @@ -33,5 +33,5 @@ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], - python_requires=">=3.6", # genologics # requires python < 3.9 - AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren' + python_requires=">=3.6", # genologics # requires python < 3.9 - AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren' ) diff --git a/tests/EPPs/arnold/test_arnold_covid_prep.py b/tests/EPPs/arnold/test_arnold_covid_prep.py index c147dac8..c883d05f 100644 --- a/tests/EPPs/arnold/test_arnold_covid_prep.py +++ b/tests/EPPs/arnold/test_arnold_covid_prep.py @@ -1,12 +1,7 @@ -from genologics.entities import Process - from cg_lims.EPPs.arnold.prep import build_step_documents from cg_lims.models.arnold.base_step import BaseStep - -from tests.conftest import ( - server, -) - +from genologics.entities import Process +from tests.conftest import server COVID_STEP_TYPES = {"library_prep", "reception_control", "pooling_and_cleanup"} diff --git a/tests/EPPs/arnold/test_arnold_load_flowcell.py b/tests/EPPs/arnold/test_arnold_load_flowcell.py index a16a5a0b..b2521cfa 100644 --- a/tests/EPPs/arnold/test_arnold_load_flowcell.py +++ b/tests/EPPs/arnold/test_arnold_load_flowcell.py @@ -1,9 +1,7 @@ -from genologics.entities import Process - from cg_lims.EPPs.arnold.flow_cell import build_flow_cell_document from cg_lims.get.artifacts import OutputGenerationType, OutputType, get_output_artifacts from cg_lims.models.arnold.flow_cell import FlowCell - +from genologics.entities import Process from tests.conftest import server diff --git a/tests/EPPs/arnold/test_arnold_microbial_prep.py b/tests/EPPs/arnold/test_arnold_microbial_prep.py index 568dbe2b..15734760 100644 --- a/tests/EPPs/arnold/test_arnold_microbial_prep.py +++ b/tests/EPPs/arnold/test_arnold_microbial_prep.py @@ -1,12 +1,7 @@ -from genologics.entities import Process - from cg_lims.EPPs.arnold.prep import build_step_documents from cg_lims.models.arnold.base_step import BaseStep - -from tests.conftest import ( - server, -) - +from genologics.entities import Process +from tests.conftest import server MICROBIAL_STEP_TYPES = { "buffer_exchange", diff --git a/tests/EPPs/arnold/test_arnold_novaseq_standard.py b/tests/EPPs/arnold/test_arnold_novaseq_standard.py index 3553c2cb..9282a669 100644 --- a/tests/EPPs/arnold/test_arnold_novaseq_standard.py +++ b/tests/EPPs/arnold/test_arnold_novaseq_standard.py @@ -1,12 +1,7 @@ -from genologics.entities import Process - from cg_lims.EPPs.arnold.sequencing import build_step_documents from cg_lims.models.arnold.base_step import BaseStep - -from tests.conftest import ( - server, -) - +from genologics.entities import Process +from tests.conftest import server NOVA_SEQ_STANDARD_STEP_TYPES = { "bcl_conversion_and_demultiplexing", diff --git a/tests/EPPs/arnold/test_arnold_twist_prep.py b/tests/EPPs/arnold/test_arnold_twist_prep.py index 2dece1b8..7aa2da93 100644 --- a/tests/EPPs/arnold/test_arnold_twist_prep.py +++ b/tests/EPPs/arnold/test_arnold_twist_prep.py @@ -1,12 +1,7 @@ -from genologics.entities import Process - from cg_lims.EPPs.arnold.prep import build_step_documents from cg_lims.models.arnold.base_step import BaseStep - -from tests.conftest import ( - server, -) - +from genologics.entities import Process +from tests.conftest import server TWIST_STEP_TYPES = { "enzymatic_fragmentation", diff --git a/tests/EPPs/arnold/test_arnold_wgs_prep.py b/tests/EPPs/arnold/test_arnold_wgs_prep.py index 97bdb0dc..87fcc5d4 100644 --- a/tests/EPPs/arnold/test_arnold_wgs_prep.py +++ b/tests/EPPs/arnold/test_arnold_wgs_prep.py @@ -1,12 +1,7 @@ -from genologics.entities import Process - from cg_lims.EPPs.arnold.prep import build_step_documents from cg_lims.models.arnold.base_step import BaseStep - -from tests.conftest import ( - server, -) - +from genologics.entities import Process +from tests.conftest import server WGS_STEP_TYPES = { "reception_control", diff --git a/tests/EPPs/files/test_barcode_tubes.py b/tests/EPPs/files/test_barcode_tubes.py index a500b7aa..4e76f16d 100644 --- a/tests/EPPs/files/test_barcode_tubes.py +++ b/tests/EPPs/files/test_barcode_tubes.py @@ -1,10 +1,10 @@ -from tests.conftest import server from pathlib import Path -from cg_lims.exceptions import InvalidValueError, MissingValueError -import pytest -from genologics.entities import Artifact +import pytest from cg_lims.EPPs.files.barcode_tubes import get_data_and_write +from cg_lims.exceptions import InvalidValueError, MissingValueError +from genologics.entities import Artifact +from tests.conftest import server def test_with_diff_containers(barcode_tubes_csv, lims): @@ -47,10 +47,7 @@ def test_MissingValueError(lims): get_data_and_write(artifacts, file=file) # Then InvalidValueError exception should be raised, and no file created. - assert( - f"Missing samples with container type \"Tube\"." - in error_message.value.message - ) + assert f'Missing samples with container type "Tube".' in error_message.value.message assert file.exists() is False @@ -68,8 +65,5 @@ def test_InvalidValueError(lims): get_data_and_write(artifacts, file=file) # Then InvalidValueError exception should be raised, and no file created. - assert( - f"The following samples are missing a container: S1 S1" - in error_message.value.message - ) + assert f"The following samples are missing a container: S1 S1" in error_message.value.message assert file.exists() is False diff --git a/tests/EPPs/files/test_buffer_exchange_twist_file.py b/tests/EPPs/files/test_buffer_exchange_twist_file.py index d452ccc3..419c3aba 100644 --- a/tests/EPPs/files/test_buffer_exchange_twist_file.py +++ b/tests/EPPs/files/test_buffer_exchange_twist_file.py @@ -1,12 +1,10 @@ -from tests.conftest import server from pathlib import Path -from genologics.entities import Artifact - import pytest - from cg_lims.EPPs.files.hamilton.buffer_exchange_twist_file import get_file_data_and_write from cg_lims.exceptions import MissingUDFsError +from genologics.entities import Artifact +from tests.conftest import server def test_get_file_data_and_write(lims, hamilton_buffer_exchange): diff --git a/tests/EPPs/files/test_hamilton_normalization_file.py b/tests/EPPs/files/test_hamilton_normalization_file.py index a41e13ad..e79e0efb 100644 --- a/tests/EPPs/files/test_hamilton_normalization_file.py +++ b/tests/EPPs/files/test_hamilton_normalization_file.py @@ -1,10 +1,10 @@ -from tests.conftest import server from pathlib import Path -import pytest -from genologics.entities import Artifact +import pytest from cg_lims.EPPs.files.hamilton.normalization_file import get_file_data_and_write from cg_lims.exceptions import MissingUDFsError +from genologics.entities import Artifact +from tests.conftest import server def test_make_hamilton_normalization_file(hamilton_normalization_csv, lims): diff --git a/tests/EPPs/files/test_make_kapa_csv.py b/tests/EPPs/files/test_make_kapa_csv.py index 773e7999..ba5d5dff 100644 --- a/tests/EPPs/files/test_make_kapa_csv.py +++ b/tests/EPPs/files/test_make_kapa_csv.py @@ -1,12 +1,10 @@ -from tests.conftest import server from pathlib import Path -from genologics.entities import Artifact - import pytest - from cg_lims.EPPs.files.hamilton.make_kapa_csv import get_file_data_and_write from cg_lims.exceptions import MissingArtifactError, MissingUDFsError +from genologics.entities import Artifact +from tests.conftest import server def test_get_file_data_and_write_kapa_library_preparation(kapa_library_preparation_file, lims): diff --git a/tests/EPPs/files/test_sars_cov2_prep_file.py b/tests/EPPs/files/test_sars_cov2_prep_file.py index 57f419ef..f66aebd0 100644 --- a/tests/EPPs/files/test_sars_cov2_prep_file.py +++ b/tests/EPPs/files/test_sars_cov2_prep_file.py @@ -1,10 +1,9 @@ -from genologics.entities import Process - -from cg_lims.get.artifacts import get_artifacts -from tests.conftest import server from pathlib import Path from cg_lims.EPPs.files.hamilton.sars_cov2_prep_file import get_file_data_and_write +from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Process +from tests.conftest import server def test_make_hamilton_sars_cov2_pooling_file(hamilton_sars_cov2_pooling_file, lims): diff --git a/tests/EPPs/qc/test_sequencing_artifact_manager.py b/tests/EPPs/qc/test_sequencing_artifact_manager.py index 3537d49d..6ea6e78a 100644 --- a/tests/EPPs/qc/test_sequencing_artifact_manager.py +++ b/tests/EPPs/qc/test_sequencing_artifact_manager.py @@ -1,5 +1,3 @@ -from genologics.entities import Process -from genologics.lims import Lims from cg_lims.EPPs.qc.sequencing_artifact_manager import ( SampleLaneArtifacts, SequencingArtifactManager, @@ -8,6 +6,8 @@ from cg_lims.get.fields import get_artifact_sample_id from cg_lims.set.qc import QualityCheck from cg_lims.set.udfs import UserDefinedFields +from genologics.entities import Process +from genologics.lims import Lims def test_sample_artifacts_add_and_get(lims_process_with_novaseq_data: Process): diff --git a/tests/EPPs/qc/test_sequencing_quality_checker.py b/tests/EPPs/qc/test_sequencing_quality_checker.py index 79222d95..95a11e43 100644 --- a/tests/EPPs/qc/test_sequencing_quality_checker.py +++ b/tests/EPPs/qc/test_sequencing_quality_checker.py @@ -1,8 +1,7 @@ from typing import List -from mock import Mock - from cg_lims.EPPs.qc.sequencing_quality_checker import SequencingQualityChecker +from mock import Mock def test_quality_control_of_flow_cell_with_all_passing( diff --git a/tests/EPPs/udf/calculate/test_calculate_average_size_and_set_qc.py b/tests/EPPs/udf/calculate/test_calculate_average_size_and_set_qc.py index 2ba7c3fb..02071a7c 100644 --- a/tests/EPPs/udf/calculate/test_calculate_average_size_and_set_qc.py +++ b/tests/EPPs/udf/calculate/test_calculate_average_size_and_set_qc.py @@ -1,11 +1,10 @@ import pytest -from genologics.entities import Process - from cg_lims.EPPs.udf.calculate.calculate_average_size_and_set_qc import ( calculate_average_size, set_average_and_qc, ) from cg_lims.exceptions import MissingUDFsError +from genologics.entities import Process from tests.conftest import server diff --git a/tests/EPPs/udf/calculate/test_calculate_beads.py b/tests/EPPs/udf/calculate/test_calculate_beads.py index a138025d..b98be2ec 100644 --- a/tests/EPPs/udf/calculate/test_calculate_beads.py +++ b/tests/EPPs/udf/calculate/test_calculate_beads.py @@ -1,6 +1,5 @@ import mock import pytest - from cg_lims.EPPs.udf.calculate.calculate_beads import ( calculate_beads_volume, calculate_elution_volume, diff --git a/tests/EPPs/udf/calculate/test_calculate_microbial_aliquot_volumes.py b/tests/EPPs/udf/calculate/test_calculate_microbial_aliquot_volumes.py index 85fc9d29..37573d40 100644 --- a/tests/EPPs/udf/calculate/test_calculate_microbial_aliquot_volumes.py +++ b/tests/EPPs/udf/calculate/test_calculate_microbial_aliquot_volumes.py @@ -1,12 +1,9 @@ """Unit tests for cg_lims.EPPs.udf.calculate.calculate_microbial_aliquot_volumes""" import pytest -from genologics.entities import Artifact - -from cg_lims.EPPs.udf.calculate.calculate_microbial_aliquot_volumes import ( - calculate_volumes, -) +from cg_lims.EPPs.udf.calculate.calculate_microbial_aliquot_volumes import calculate_volumes from cg_lims.exceptions import HighConcentrationError, MissingUDFsError +from genologics.entities import Artifact QC_FAILED = "FAILED" QC_PASSED = "PASSED" diff --git a/tests/EPPs/udf/calculate/test_calculate_resuspension_buffer_volumes.py b/tests/EPPs/udf/calculate/test_calculate_resuspension_buffer_volumes.py index b53a74d9..3487d7dc 100644 --- a/tests/EPPs/udf/calculate/test_calculate_resuspension_buffer_volumes.py +++ b/tests/EPPs/udf/calculate/test_calculate_resuspension_buffer_volumes.py @@ -1,10 +1,7 @@ import pytest -from genologics.entities import Artifact - -from cg_lims.EPPs.udf.calculate.calculate_resuspension_buffer_volumes import ( - calculate_rb_volume, -) +from cg_lims.EPPs.udf.calculate.calculate_resuspension_buffer_volumes import calculate_rb_volume from cg_lims.exceptions import InvalidValueError, MissingUDFsError +from genologics.entities import Artifact def test_calculate_rb_volume_missing_concentration(artifact_1: Artifact): diff --git a/tests/EPPs/udf/calculate/test_calculate_water_volume_rna.py b/tests/EPPs/udf/calculate/test_calculate_water_volume_rna.py index 0ba5d0b1..51da5bc9 100644 --- a/tests/EPPs/udf/calculate/test_calculate_water_volume_rna.py +++ b/tests/EPPs/udf/calculate/test_calculate_water_volume_rna.py @@ -1,9 +1,8 @@ import pytest -from genologics.entities import Artifact -from cg_lims.EPPs.udf.calculate.calculate_water_volume_rna import ( - calculate_sample_and_water_volumes, -) +from cg_lims.EPPs.udf.calculate.calculate_water_volume_rna import calculate_sample_and_water_volumes from cg_lims.exceptions import MissingUDFsError +from genologics.entities import Artifact + def test_calculate_water_volume_rna_missing_concentration(artifact_1: Artifact): # GIVEN a list of artifacts with one artifact missing the udf 'Concentration' @@ -20,15 +19,14 @@ def test_calculate_water_volume_rna_missing_concentration(artifact_1: Artifact): in error_message.value.message ) + @pytest.mark.parametrize( "concentration", [ 100, ], ) -def test_calculate_water_volume_rna_amount_needed_missing( - concentration, artifact_1: Artifact -): +def test_calculate_water_volume_rna_amount_needed_missing(concentration, artifact_1: Artifact): # GIVEN a list of artifacts with one artifact having no 'Amount Needed (ng)' udf artifact_1.udf["Concentration"] = int(concentration) del artifact_1.udf["Amount needed (ng)"] @@ -44,6 +42,7 @@ def test_calculate_water_volume_rna_amount_needed_missing( in error_message.value.message ) + @pytest.mark.parametrize( "concentration, amount_needed, expected_water_volume, expected_sample_volume", [ diff --git a/tests/EPPs/udf/calculate/test_find_reads_to_sequence.py b/tests/EPPs/udf/calculate/test_find_reads_to_sequence.py index 87da6b64..8be6cc52 100644 --- a/tests/EPPs/udf/calculate/test_find_reads_to_sequence.py +++ b/tests/EPPs/udf/calculate/test_find_reads_to_sequence.py @@ -1,11 +1,10 @@ -from genologics.entities import Process from cg_lims.EPPs.udf.copy.reads_to_sequence import find_reads_to_sequence from cg_lims.get.artifacts import get_artifacts from cg_lims.get.samples import get_process_samples +from genologics.entities import Process from tests.conftest import server - def test_find_reads_to_sequence(lims): # GIVEN: A process with 5 input artifacts, where one of the input artifacts has the # udf 'Missing reads Pool (M)' set to 190. @@ -27,10 +26,10 @@ def test_find_reads_to_sequence(lims): assert passed_artifacts == 5 assert failed_artifacts == 0 for artifact in output_artifacts: - if artifact.id == '2-1454725': - assert artifact.udf['Reads to sequence (M)'] == '190' + if artifact.id == "2-1454725": + assert artifact.udf["Reads to sequence (M)"] == "190" else: - assert artifact.udf['Reads to sequence (M)'] == '6' + assert artifact.udf["Reads to sequence (M)"] == "6" def test_find_reads_to_sequence_missing_udfs(lims): @@ -40,7 +39,7 @@ def test_find_reads_to_sequence_missing_udfs(lims): server("find_reads_to_sequence") process = Process(lims, id="24-196211") - samples=get_process_samples(process=process) + samples = get_process_samples(process=process) for sample in samples: sample.udf.clear() sample.put() diff --git a/tests/EPPs/udf/calculate/test_maf_calculate_volume.py b/tests/EPPs/udf/calculate/test_maf_calculate_volume.py index 265f64ed..1bc1d972 100644 --- a/tests/EPPs/udf/calculate/test_maf_calculate_volume.py +++ b/tests/EPPs/udf/calculate/test_maf_calculate_volume.py @@ -2,15 +2,14 @@ import logging import pytest -from genologics.entities import Artifact -from pydantic.v1 import ValidationError - from cg_lims.EPPs.udf.calculate.maf_calculate_volume import ( QC_FAILED, QC_PASSED, MafVolumes, calculate_volume, ) +from genologics.entities import Artifact +from pydantic.v1 import ValidationError from tests.conftest import server LOG = logging.getLogger(__name__) diff --git a/tests/EPPs/udf/calculate/test_sum_missing_reads_in_pool.py b/tests/EPPs/udf/calculate/test_sum_missing_reads_in_pool.py index 3a1ae31d..9c8efcd3 100644 --- a/tests/EPPs/udf/calculate/test_sum_missing_reads_in_pool.py +++ b/tests/EPPs/udf/calculate/test_sum_missing_reads_in_pool.py @@ -1,10 +1,9 @@ -from genologics.entities import Process from cg_lims.EPPs.udf.calculate.sum_missing_reads_in_pool import sum_reads_in_pool from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Process from tests.conftest import server - def test_sum_reads_pool(lims): # GIVEN: A process with pools, where the samples of each pool have the udf 'Reads missing (M)' set. @@ -18,8 +17,9 @@ def test_sum_reads_pool(lims): # THEN all pools passed and each pool udf: 'Missing reads Pool (M)' is the sum of ther sample reads. assert failed_artifacts == 0 for artifact in artifacts: - assert artifact.udf.get('Missing reads Pool (M)') == sum(sample.udf.get("Reads missing (M)") for sample in artifact.samples) - + assert artifact.udf.get("Missing reads Pool (M)") == sum( + sample.udf.get("Reads missing (M)") for sample in artifact.samples + ) def test_sum_reads_pool_missing_udf(lims): diff --git a/tests/EPPs/udf/calculate/test_twist_qc_amount.py b/tests/EPPs/udf/calculate/test_twist_qc_amount.py index 1d42f606..ef601dc7 100644 --- a/tests/EPPs/udf/calculate/test_twist_qc_amount.py +++ b/tests/EPPs/udf/calculate/test_twist_qc_amount.py @@ -1,20 +1,21 @@ +import pytest +from cg_lims.EPPs.udf.calculate.twist_qc_amount import calculate_amount_and_set_qc from cg_lims.exceptions import FailingQCError, MissingUDFsError from genologics.entities import Artifact, Sample from genologics.lims import Lims -from cg_lims.EPPs.udf.calculate.twist_qc_amount import calculate_amount_and_set_qc from tests.conftest import server -import pytest - -@pytest.mark.parametrize("volume,concentration,source", - [(3, 1, "blood"), (10, 0.1, "cfDNA"), (50, 300, "blood"), (300, 2, "blood"), - (10, 10, "blood")]) -def test_calculate_amount_and_set_qc_failing(volume: int, concentration: float, source: int, artifact_1: Artifact, - sample_1: Sample): +@pytest.mark.parametrize( + "volume,concentration,source", + [(3, 1, "blood"), (10, 0.1, "cfDNA"), (50, 300, "blood"), (300, 2, "blood"), (10, 10, "blood")], +) +def test_calculate_amount_and_set_qc_failing( + volume: int, concentration: float, source: int, artifact_1: Artifact, sample_1: Sample +): # GIVEN: A sample with udf Source: , # and a related Artifact with udfs: Concentration: and Volume (ul): - server('flat_tests') + server("flat_tests") artifact_1.udf["Volume (ul)"] = volume artifact_1.udf["Concentration"] = concentration artifact_1.qc_flag == "UNKNOWN" @@ -30,11 +31,12 @@ def test_calculate_amount_and_set_qc_failing(volume: int, concentration: float, @pytest.mark.parametrize("volume,concentration,source", [(35, 10, "cfDNA"), (50, 50, "blood")]) -def test_calculate_amount_and_set_qc_passing(volume: int, concentration: float, source: int, artifact_1: Artifact, - sample_1: Sample): +def test_calculate_amount_and_set_qc_passing( + volume: int, concentration: float, source: int, artifact_1: Artifact, sample_1: Sample +): # GIVEN: A sample with udf Source: , # and a related Artifact with udfs: Concentration: and Volume (ul): - server('flat_tests') + server("flat_tests") artifact_1.udf["Volume (ul)"] = volume artifact_1.udf["Concentration"] = concentration artifact_1.qc_flag == "UNKNOWN" @@ -50,9 +52,11 @@ def test_calculate_amount_and_set_qc_passing(volume: int, concentration: float, assert artifact_1.qc_flag == "PASSED" -def test_calculate_amount_and_set_qc_missing_udf(lims: Lims, artifact_1: Artifact, artifact_2: Artifact): +def test_calculate_amount_and_set_qc_missing_udf( + lims: Lims, artifact_1: Artifact, artifact_2: Artifact +): # GIVEN: A list of two artifacts with missing udfs Volume (ul) or Concentration - server('flat_tests') + server("flat_tests") artifact_1.udf["Volume (ul)"] = 35 artifact_1.put() artifact_2.udf["Concentration"] = 1 diff --git a/tests/EPPs/udf/check/test_check_artifact_udfs.py b/tests/EPPs/udf/check/test_check_artifact_udfs.py index 9604478f..e7905f01 100644 --- a/tests/EPPs/udf/check/test_check_artifact_udfs.py +++ b/tests/EPPs/udf/check/test_check_artifact_udfs.py @@ -1,12 +1,10 @@ -from tests.conftest import server import logging -from genologics.entities import Artifact - import pytest - from cg_lims.EPPs.udf.check.check_artifact_udfs import check_udfs from cg_lims.exceptions import MissingUDFsError +from genologics.entities import Artifact +from tests.conftest import server def test_check_udfs_missing_udfs(lims): diff --git a/tests/EPPs/udf/copy/test_aggregate_qc_flags_and_copy_fields.py b/tests/EPPs/udf/copy/test_aggregate_qc_flags_and_copy_fields.py index d017ddd7..6ef96f7b 100644 --- a/tests/EPPs/udf/copy/test_aggregate_qc_flags_and_copy_fields.py +++ b/tests/EPPs/udf/copy/test_aggregate_qc_flags_and_copy_fields.py @@ -1,8 +1,7 @@ import pytest -from genologics.entities import Process - from cg_lims.EPPs.udf.copy.aggregate_qc_flags_and_copy_fields import get_copy_tasks from cg_lims.exceptions import MissingUDFsError +from genologics.entities import Process from tests.conftest import server diff --git a/tests/EPPs/udf/copy/test_artifact_to_artifact.py b/tests/EPPs/udf/copy/test_artifact_to_artifact.py index 4fe45004..4e1ca384 100644 --- a/tests/EPPs/udf/copy/test_artifact_to_artifact.py +++ b/tests/EPPs/udf/copy/test_artifact_to_artifact.py @@ -1,9 +1,8 @@ import pytest -from genologics.entities import Artifact, Process - from cg_lims.EPPs.udf.copy.artifact_to_artifact import copy_udfs_to_all_artifacts -from cg_lims.get.artifacts import get_artifacts, get_latest_analyte from cg_lims.exceptions import MissingUDFsError +from cg_lims.get.artifacts import get_artifacts, get_latest_analyte +from genologics.entities import Artifact, Process from tests.conftest import server @@ -54,10 +53,12 @@ def test_copy_udf_process_type(lims): # THEN the correct source UDFs are copied over for artifact in artifacts: sample_id = artifact.samples[0].id - source_artifact = get_latest_analyte(lims, - sample_id=sample_id, - process_types=["Aliquot Samples for Covaris"], - sample_artifact=False) + source_artifact = get_latest_analyte( + lims, + sample_id=sample_id, + process_types=["Aliquot Samples for Covaris"], + sample_artifact=False, + ) assert artifact.udf["Concentration"] == source_artifact.udf["Concentration"] @@ -110,7 +111,7 @@ def test_copy_qc_flag(lims): process = Process(lims, id="24-240276") artifacts = get_artifacts(process=process, input=True) source_artifact = Artifact(lims, id="ACC8454A1PA1") - source_artifact.qc_flag = 'FAILED' + source_artifact.qc_flag = "FAILED" source_artifact.put() # WHEN running get_copy_tasks with qc_flag set to true @@ -137,7 +138,7 @@ def test_copy_qc_flag_fail(lims): server("wgs_prep") process = Process(lims, id="24-240276") artifacts = get_artifacts(process=process, input=True) - artifacts[0].qc_flag = 'FAILED' + artifacts[0].qc_flag = "FAILED" artifacts[0].put() # WHEN running get_copy_tasks @@ -153,7 +154,7 @@ def test_copy_qc_flag_fail(lims): ) # THEN failed qc flags are not overwritten - assert artifacts[0].qc_flag == 'FAILED' + assert artifacts[0].qc_flag == "FAILED" for artifact in artifacts[1:5]: sample_id = artifact.samples[0].id source_artifact = Artifact(lims, id=f"{sample_id}PA1") diff --git a/tests/EPPs/udf/copy/test_measurement_to_analyte.py b/tests/EPPs/udf/copy/test_measurement_to_analyte.py index 59d43cc4..99438e67 100644 --- a/tests/EPPs/udf/copy/test_measurement_to_analyte.py +++ b/tests/EPPs/udf/copy/test_measurement_to_analyte.py @@ -1,9 +1,8 @@ import pytest -from genologics.entities import Process - from cg_lims.EPPs.udf.copy.measurement_to_analyte import copy_udfs_to_all_analytes -from cg_lims.get.artifacts import get_artifacts from cg_lims.exceptions import MissingUDFsError +from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Process from tests.conftest import server diff --git a/tests/EPPs/udf/copy/test_original_position.py b/tests/EPPs/udf/copy/test_original_position.py index 5f361dfe..9bbf7581 100644 --- a/tests/EPPs/udf/copy/test_original_position.py +++ b/tests/EPPs/udf/copy/test_original_position.py @@ -1,8 +1,9 @@ -from genologics.entities import Artifact +import pytest from cg_lims.EPPs.udf.copy.original_well_to_sample import original_well_to_sample -from tests.conftest import server from cg_lims.exceptions import InvalidValueError -import pytest +from genologics.entities import Artifact +from tests.conftest import server + def test_assign_position(lims): # GIVEN artifacts with container, position and without parent steps. @@ -18,36 +19,39 @@ def test_assign_position(lims): assert sample.udf["Original Well"] == artifact.location[1] assert sample.udf["Original Container"] == artifact.location[0].name + def test_replace(lims): # GIVEN artifacts with container, position and without parent steps. # And sample with already has assigned 'Original Well' and 'Original Container'. server("reception_control_twist") artifact = [Artifact(lims=lims, id="ACC9476A23PA1")] sample = artifact[0].samples[0] - sample.udf['Original Well'] = "foo" - sample.udf['Original Container'] = "bar" + sample.udf["Original Well"] = "foo" + sample.udf["Original Container"] = "bar" sample.put() # When running function original_well_to_sample. if artifact[0].location[1] != None and artifact[0].location[0].name != None: original_well_to_sample(artifact) - + # THEN the corresponding sample will have the matching 'Original Well' and 'Original Container'. assert sample.udf["Original Well"] == artifact[0].location[1] assert sample.udf["Original Container"] == artifact[0].location[0].name + def test_missing_value(lims): # GIVEN that is missing location udf server("reception_control_twist") artifact = [Artifact(lims=lims, id="ACC9476A3PA1")] - - if artifact[0].location[0] != None : + + if artifact[0].location[0] != None: exit() - + # WHEN running function original_well_to_sample # THEN MissingUDFsError should be triggered. with pytest.raises(InvalidValueError) as error_message: - original_well_to_sample(artifact) + original_well_to_sample(artifact) + def test_exceptions_with_parent(lims): # GIVEN artifacts with parent steps. @@ -57,12 +61,13 @@ def test_exceptions_with_parent(lims): for artifact in artifacts: if artifact.parent_process == None: exit() - + # WHEN running function original_well_to_sample. # THEN InvalidValueError should be raised. with pytest.raises(InvalidValueError) as error_message: original_well_to_sample(artifacts=artifacts) + def test_exceptions_pool(lims): # GIVEN artifacts with multiple samples, a pool. server("missing_reads_pool") @@ -71,7 +76,7 @@ def test_exceptions_pool(lims): for artifact in artifacts: if len(artifact.samples) == 1: exit() - + # WHEN running function original_well_to_sample. # THEN InvalidValueError should be raised. with pytest.raises(InvalidValueError) as error_message: diff --git a/tests/EPPs/udf/set/test_qc_to_sample.py b/tests/EPPs/udf/set/test_qc_to_sample.py index 4a4b8496..8ce2ad5e 100644 --- a/tests/EPPs/udf/set/test_qc_to_sample.py +++ b/tests/EPPs/udf/set/test_qc_to_sample.py @@ -1,11 +1,9 @@ import pytest -from genologics.entities import Process - -from cg_lims.exceptions import MissingUDFsError from cg_lims.EPPs.udf.copy.qc_to_sample import artifacts_to_sample -from tests.conftest import server - +from cg_lims.exceptions import MissingUDFsError from cg_lims.get.artifacts import get_artifacts +from genologics.entities import Process +from tests.conftest import server def test_udf_Passed_Initial_QC(lims): diff --git a/tests/EPPs/udf/set/test_set_barcode.py b/tests/EPPs/udf/set/test_set_barcode.py index 8ef8dea7..494fe54c 100644 --- a/tests/EPPs/udf/set/test_set_barcode.py +++ b/tests/EPPs/udf/set/test_set_barcode.py @@ -1,10 +1,9 @@ import pytest - -from genologics.entities import Artifact, Process -from cg_lims.exceptions import InvalidValueError, MissingValueError from cg_lims.EPPs.udf.set.set_barcode import get_barcode_set_udf -from cg_lims.get.fields import get_barcode +from cg_lims.exceptions import InvalidValueError, MissingValueError from cg_lims.get.artifacts import get_artifacts +from cg_lims.get.fields import get_barcode +from genologics.entities import Artifact, Process from tests.conftest import server @@ -13,8 +12,8 @@ def test_tube_barcode(lims): # and ACC9621A7PA1 have container type "Tube" and are the # only ones to be have assigned a barcode udf. - barcode_udf = 'Output Container Barcode' - container = 'Tube' + barcode_udf = "Output Container Barcode" + container = "Tube" server("hamilton_normalization_file") artifacts = [ Artifact(lims, id="ACC9553A3PA1"), @@ -27,7 +26,9 @@ def test_tube_barcode(lims): del artifact.udf[barcode_udf] # WHEN running get_barcode_set_udf - get_barcode_set_udf(artifacts=artifacts, artifact_udf=barcode_udf, container_type=container, measurement=False) + get_barcode_set_udf( + artifacts=artifacts, artifact_udf=barcode_udf, container_type=container, measurement=False + ) # THEN only tubes should get barcodes and be correct. for artifact in artifacts: @@ -43,10 +44,10 @@ def test_plate_barcode(lims): # GIVEN four artifacts, only two of them ACC9551A97PA1 # and ACC9551A105PA1 have container type '96 well plate' and are the # only ones to be included in the final file. None of them - # have barcode_udf. + # have barcode_udf. - barcode_udf = 'Output Container Barcode' - container = 'Some container name' + barcode_udf = "Output Container Barcode" + container = "Some container name" server("hamilton_normalization_file") artifacts = [ Artifact(lims, id="ACC9553A3PA1"), @@ -57,34 +58,38 @@ def test_plate_barcode(lims): # WHEN running get_barcode_set_udf with pytest.raises(MissingValueError) as error_message: - get_barcode_set_udf(artifacts=artifacts, artifact_udf=barcode_udf, container_type=container, measurement=False) + get_barcode_set_udf( + artifacts=artifacts, + artifact_udf=barcode_udf, + container_type=container, + measurement=False, + ) # THEN InvalidValueError exception should be raised. # Because plate barcode has no specific barcode. - assert( - f"No barcode assigned." - in error_message.value.message - ) + assert f"No barcode assigned." in error_message.value.message def test_pool_barcode(lims): # GIVEN artifacts with multiple samples - a pool - # and container type 'Tube'. server("pool_samples_TWIST") - barcode_udf = 'Output Container Barcode' - container = 'Tube' + barcode_udf = "Output Container Barcode" + container = "Tube" process = Process(lims, id="122-202801") artifacts = get_artifacts(process=process, input=False) - + for artifact in artifacts: if len(artifact.samples) == 1: exit() # WHEN running function get_barcode_set_udf. - get_barcode_set_udf(artifacts=artifacts, artifact_udf=barcode_udf, container_type=container, measurement=False) + get_barcode_set_udf( + artifacts=artifacts, artifact_udf=barcode_udf, container_type=container, measurement=False + ) # THEN correct barcode should be assigned. - for artifact in artifacts: + for artifact in artifacts: barcode = get_barcode(artifact) assert artifact.udf[barcode_udf] == barcode @@ -95,7 +100,7 @@ def test_no_container_type(lims): # the other two (ACC9551A97PA1 and ACC9551A105PA1) # belong to a "96 well plate" container - barcode_udf = 'Output Container Barcode' + barcode_udf = "Output Container Barcode" server("hamilton_normalization_file") artifacts = [ Artifact(lims, id="ACC9553A3PA1"), @@ -108,7 +113,9 @@ def test_no_container_type(lims): del artifact.udf[barcode_udf] # WHEN running get_barcode_set_udf - get_barcode_set_udf(artifacts=artifacts, artifact_udf=barcode_udf, container_type="", measurement=False) + get_barcode_set_udf( + artifacts=artifacts, artifact_udf=barcode_udf, container_type="", measurement=False + ) # THEN all artifacts should get barcodes and be correct. for artifact in artifacts: @@ -119,26 +126,28 @@ def test_no_container_type(lims): def test_invalid_value(lims): # GIVEN artifacts missing container type. server("missing_reads_pool") - barcode_udf = 'Output Container Barcode' + barcode_udf = "Output Container Barcode" container = "Tube" artifact = [Artifact(lims, id="2-1439512")] # WHEN running function get_barcode_set_udf. with pytest.raises(InvalidValueError) as error_message: - get_barcode_set_udf(artifacts=artifact, artifact_udf=barcode_udf, container_type=container, measurement=False) + get_barcode_set_udf( + artifacts=artifact, + artifact_udf=barcode_udf, + container_type=container, + measurement=False, + ) # THEN InvalidValueError should be triggered. - assert ( - f"Samples ACC7239A44, are missing udf container or udf " - in error_message.value.message - ) + assert f"Samples ACC7239A44, are missing udf container or udf " in error_message.value.message def test_missing_value(lims): # GIVEN two artifacts, with container "Tube" # and container set to "No_tubes". - barcode_udf = 'Output Container Barcode' - container = 'No_tubes' + barcode_udf = "Output Container Barcode" + container = "No_tubes" server("hamilton_normalization_file") artifacts = [ Artifact(lims, id="ACC9553A3PA1"), @@ -150,23 +159,25 @@ def test_missing_value(lims): # WHEN running function get_barcode_set_udf. with pytest.raises(MissingValueError) as error_message: - get_barcode_set_udf(artifacts=artifacts, artifact_udf=barcode_udf, container_type=container, measurement=False) - - # THEN no barcodes should be assigned and barcode_udf should not + get_barcode_set_udf( + artifacts=artifacts, + artifact_udf=barcode_udf, + container_type=container, + measurement=False, + ) + + # THEN no barcodes should be assigned and barcode_udf should not # exists. - assert ( - f"No barcode assigned. Check parameters." - in error_message.value.message - ) - + assert f"No barcode assigned. Check parameters." in error_message.value.message + with pytest.raises(KeyError): artifact.udf[barcode_udf] def test_container_on_measurement(lims): # GIVEN measurements with different containers. - barcode_udf = 'Output Container Barcode' - container = 'Tube' + barcode_udf = "Output Container Barcode" + container = "Tube" server("reception_control_wgs") process = Process(lims, id="24-349794") measurements = get_artifacts(process=process, measurement=True) @@ -178,14 +189,16 @@ def test_container_on_measurement(lims): continue # WHEN running get_barcode_set_udf - get_barcode_set_udf(artifacts=measurements, artifact_udf=barcode_udf, container_type=container, measurement=True) + get_barcode_set_udf( + artifacts=measurements, artifact_udf=barcode_udf, container_type=container, measurement=True + ) # THEN barcodes should be assigned on measurement level only to samples with correct container. for measurement in measurements: if measurement.samples[0].artifact.container.type.name != container: with pytest.raises(KeyError): measurement.udf[barcode_udf] - + else: barcode = get_barcode(measurement.samples[0].artifact) assert measurement.udf[barcode_udf] == barcode @@ -193,8 +206,8 @@ def test_container_on_measurement(lims): def test_missing_value_on_measurement(lims): # GIVEN measurements with different containers. - barcode_udf = 'Output Container Barcode' - container = 'foobar' + barcode_udf = "Output Container Barcode" + container = "foobar" server("reception_control_wgs") process = Process(lims, id="24-349794") measurements = get_artifacts(process=process, measurement=True) @@ -207,14 +220,16 @@ def test_missing_value_on_measurement(lims): # WHEN running function get_barcode_set_udf. with pytest.raises(MissingValueError) as error_message: - get_barcode_set_udf(artifacts=measurements, artifact_udf=barcode_udf, container_type=container, measurement=True) - - # THEN no barcodes should be assigned and barcode_udf should not + get_barcode_set_udf( + artifacts=measurements, + artifact_udf=barcode_udf, + container_type=container, + measurement=True, + ) + + # THEN no barcodes should be assigned and barcode_udf should not # exists. - assert ( - f"No barcode assigned. Check parameters." - in error_message.value.message - ) - + assert f"No barcode assigned. Check parameters." in error_message.value.message + with pytest.raises(KeyError): measurement.udf[barcode_udf] diff --git a/tests/EPPs/udf/set/test_set_dates.py b/tests/EPPs/udf/set/test_set_dates.py index 56bbe5f1..786a60ac 100644 --- a/tests/EPPs/udf/set/test_set_dates.py +++ b/tests/EPPs/udf/set/test_set_dates.py @@ -1,14 +1,8 @@ -from genologics.entities import Sample, Process - -from cg_lims.EPPs.udf.set.set_sample_date import ( - set_prepared, - set_sequenced, - set_delivered, -) from datetime import datetime as dt -from tests.conftest import ( - server, -) + +from cg_lims.EPPs.udf.set.set_sample_date import set_delivered, set_prepared, set_sequenced +from genologics.entities import Process, Sample +from tests.conftest import server def test_set_prepared(lims): diff --git a/tests/EPPs/udf/set/test_set_method.py b/tests/EPPs/udf/set/test_set_method.py index 00bde5ca..1a02626a 100644 --- a/tests/EPPs/udf/set/test_set_method.py +++ b/tests/EPPs/udf/set/test_set_method.py @@ -1,14 +1,10 @@ import pytest -from genologics.entities import Process - +import requests +import responses from cg_lims.EPPs.udf.set.set_method import get_path from cg_lims.exceptions import AtlasResponseFailedError -from tests.conftest import ( - server, -) - -import responses -import requests +from genologics.entities import Process +from tests.conftest import server @pytest.fixture() diff --git a/tests/EPPs/udf/set/test_set_samples_reads_missing.py b/tests/EPPs/udf/set/test_set_samples_reads_missing.py index fe1cdf04..9b34c010 100644 --- a/tests/EPPs/udf/set/test_set_samples_reads_missing.py +++ b/tests/EPPs/udf/set/test_set_samples_reads_missing.py @@ -1,13 +1,12 @@ import mock import pytest -from genologics.entities import Sample - from cg_lims.EPPs.udf.set.set_samples_reads_missing import ( get_target_amount, set_reads_missing, set_reads_missing_on_sample, ) from cg_lims.exceptions import LimsError, MissingUDFsError +from genologics.entities import Sample from tests.conftest import server diff --git a/tests/commands/test_base.py b/tests/commands/test_base.py index 3656d0fe..6cf16019 100644 --- a/tests/commands/test_base.py +++ b/tests/commands/test_base.py @@ -1,8 +1,7 @@ from pathlib import Path -from click.testing import CliRunner - from cg_lims.commands.base import cli +from click.testing import CliRunner def test_cli_existing_log_file(config): diff --git a/tests/conftest.py b/tests/conftest.py index fc6e2e9d..f3540332 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,26 +1,20 @@ import datetime as dt -from typing import Callable, Dict, List - -from genologics.lims import Lims -from genologics.entities import Artifact, Process, Sample -from pathlib import Path -from mock import MagicMock, Mock - -import pytest -from click.testing import CliRunner - import threading import time +from pathlib import Path +from typing import Callable, Dict, List +import pytest from cg_lims.EPPs.qc.sequencing_artifact_manager import SequencingArtifactManager from cg_lims.EPPs.qc.sequencing_quality_checker import SequencingQualityChecker from cg_lims.models.sample_lane_sequencing_metrics import SampleLaneSequencingMetrics - -from cg_lims.token_manager import TokenManager from cg_lims.status_db_api import StatusDBAPI - - +from cg_lims.token_manager import TokenManager +from click.testing import CliRunner +from genologics.entities import Artifact, Process, Sample +from genologics.lims import Lims from limsmock.server import run_server +from mock import MagicMock, Mock from tests.fixtures.flowcell_document import FLOW_CELL_DOCUMENT diff --git a/tests/get/test_artifacts.py b/tests/get/test_artifacts.py index a0867c6a..56ab21e9 100644 --- a/tests/get/test_artifacts.py +++ b/tests/get/test_artifacts.py @@ -1,11 +1,9 @@ -from genologics.entities import Process -from genologics.lims import Lims -from tests.conftest import server - import pytest - from cg_lims.exceptions import MissingArtifactError from cg_lims.get.artifacts import get_artifacts, get_lane_sample_artifacts, get_latest_analyte +from genologics.entities import Process +from genologics.lims import Lims +from tests.conftest import server def test_get_latest_artifact(lims: Lims): diff --git a/tests/get/test_udfs.py b/tests/get/test_udfs.py index 5efcfa81..08b46bd3 100644 --- a/tests/get/test_udfs.py +++ b/tests/get/test_udfs.py @@ -1,8 +1,7 @@ import pytest -from genologics.entities import Sample - from cg_lims.exceptions import MissingUDFsError from cg_lims.get.udfs import get_udf +from genologics.entities import Sample from tests.conftest import server @@ -29,6 +28,5 @@ def test_get_udf_missing_udf(sample_1: Sample): # THEN the correct exception should be raised assert ( - f"UDF Sequencing Analysis not found on sample {sample_1.id}" - in error_message.value.message + f"UDF Sequencing Analysis not found on sample {sample_1.id}" in error_message.value.message ) diff --git a/tests/test_status_db_api_client.py b/tests/test_status_db_api_client.py index 7b71e444..1465031d 100644 --- a/tests/test_status_db_api_client.py +++ b/tests/test_status_db_api_client.py @@ -1,8 +1,8 @@ from typing import Dict, List -from mock import Mock from cg_lims.models.sample_lane_sequencing_metrics import SampleLaneSequencingMetrics from cg_lims.status_db_api import StatusDBAPI +from mock import Mock def test_get_sequencing_metrics_for_flow_cell(