Skip to content

Commit

Permalink
Format the entire repo with Black and iSort (#469)(patch)
Browse files Browse the repository at this point in the history
### Fixed
- the formatting of all the Python files in the repository
  • Loading branch information
Karl-Svard authored Jan 18, 2024
1 parent e2ae193 commit 44165ca
Show file tree
Hide file tree
Showing 179 changed files with 725 additions and 871 deletions.
3 changes: 1 addition & 2 deletions cg_lims/EPPs/arnold/base.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 2 additions & 5 deletions cg_lims/EPPs/arnold/flow_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
12 changes: 5 additions & 7 deletions cg_lims/EPPs/arnold/prep.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down
6 changes: 3 additions & 3 deletions cg_lims/EPPs/arnold/sample.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down
8 changes: 3 additions & 5 deletions cg_lims/EPPs/arnold/sequencing.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down
7 changes: 3 additions & 4 deletions cg_lims/EPPs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
58 changes: 27 additions & 31 deletions cg_lims/EPPs/files/barcode_tubes.py
Original file line number Diff line number Diff line change
@@ -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."""
Expand All @@ -31,59 +31,55 @@ 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()
@options.file_placeholder(help="Barcode Tubes")
@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"""

Expand Down
8 changes: 4 additions & 4 deletions cg_lims/EPPs/files/base.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down
3 changes: 1 addition & 2 deletions cg_lims/EPPs/files/csv_for_kapa_truble_shooting/models.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
9 changes: 4 additions & 5 deletions cg_lims/EPPs/files/file_to_udf.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down Expand Up @@ -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()
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions cg_lims/EPPs/files/hamilton/base.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 2 additions & 3 deletions cg_lims/EPPs/files/hamilton/buffer_exchange_twist_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
3 changes: 1 addition & 2 deletions cg_lims/EPPs/files/hamilton/make_kapa_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
3 changes: 1 addition & 2 deletions cg_lims/EPPs/files/hamilton/normalization_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
Loading

0 comments on commit 44165ca

Please sign in to comment.