Skip to content

Commit

Permalink
chore: Update ruff to 0.9 (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
tedil authored Jan 16, 2025
1 parent dbeb3ed commit 689696e
Show file tree
Hide file tree
Showing 28 changed files with 129 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: v0.8.2
rev: v0.9.1
hooks:
- id: ruff
args: [ --fix ]
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies:
- coveralls ~=4.0.1
- pytabix >=0.1.0,<1
# formatting, linting, dev
- ruff ~=0.4.8
- ruff >=0.9.0,<1
- snakefmt ~=0.8.5
- pre-commit ~=3.7.1
# docs
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test = [
]
dev = [
# ruff code linter + formatter
"ruff >=0.8.2,<1",
"ruff >=0.9.0,<1",
# "snakefmt" code formatter and checker.
"snakefmt >=0.10.2,<1",
"pre-commit >=4.0.1,<5"
Expand Down
2 changes: 1 addition & 1 deletion snappy_pipeline/apps/snappy_snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def main(argv=None):
)
group = parser.add_argument_group(
"Snakemake Verbosity / Debugging",
"Arguments from Snakemake that are useful for debugging, such as " "increasing verbosity",
"Arguments from Snakemake that are useful for debugging, such as increasing verbosity",
)
group.add_argument(
"-p", "--printshellcmds", action="store_true", default=False, help="Print shell commands"
Expand Down
3 changes: 1 addition & 2 deletions snappy_pipeline/apps/snappy_start_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ def main(argv=None):
default=True,
action="store_false",
help=(
"Do not check config.yaml for existing configuration or change it (IOW: "
"leave it alone)"
"Do not check config.yaml for existing configuration or change it (IOW: leave it alone)"
),
)

Expand Down
3 changes: 1 addition & 2 deletions snappy_pipeline/apps/snappy_start_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ def main(argv=None):
default=True,
action="store_false",
help=(
"Do not check config.yaml for existing configuration or change it (IOW: "
"leave it alone)"
"Do not check config.yaml for existing configuration or change it (IOW: leave it alone)"
),
)

Expand Down
4 changes: 2 additions & 2 deletions snappy_pipeline/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def camel_to_snake(name: str) -> str:
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", name).lower()

name = camel_to_snake(cls.__name__)
config_str = "step_config:\n" f"{' ' * INDENTATION}{name}:\n" f"{''.join(config_str)}"
config_str = f"step_config:\n{' ' * INDENTATION}{name}:\n{''.join(config_str)}"

return config_str

Expand Down Expand Up @@ -173,7 +173,7 @@ def option_str(option: tuple[str, typing.Any]) -> str:
else:
return f"{repr(value)}"

comment.append(f"Options: " f"{', '.join(map(option_str, options))}")
comment.append(f"Options: {', '.join(map(option_str, options))}")

comment = "; ".join(comment)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class GeneExpressionQuantificationStepPart(BaseStepPart):
def __init__(self, parent):
super().__init__(parent)
self.base_path_out = (
"work/{{mapper}}.{tool}.{{library_name}}/out/" "{{mapper}}.{tool}.{{library_name}}{ext}"
"work/{{mapper}}.{tool}.{{library_name}}/out/{{mapper}}.{tool}.{{library_name}}{ext}"
)

def get_input_files(self, action):
Expand All @@ -238,7 +238,7 @@ def input_function(wildcards):
ngs_mapping = self.parent.sub_workflows["ngs_mapping"]
# Get names of primary libraries of the selected cancer bio sample and the
# corresponding primary normal sample
base_path = "output/{mapper}.{library_name}/out/" "{mapper}.{library_name}".format(
base_path = "output/{mapper}.{library_name}/out/{mapper}.{library_name}".format(
**wildcards
)
return {
Expand Down
3 changes: 1 addition & 2 deletions snappy_pipeline/workflows/gene_expression_report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class GeneExpressionReportStepPart(BaseStepPart):
def __init__(self, parent):
super().__init__(parent)
self.base_path_out = (
"work/{{mapper}}.{{tool}}.{{ngs_library}}/out/"
"{{mapper}}.{{tool}}.{{ngs_library}}{ext}"
"work/{{mapper}}.{{tool}}.{{ngs_library}}/out/{{mapper}}.{{tool}}.{{ngs_library}}{ext}"
)
# Build shortcut from cancer bio sample name to matched cancer sample
self.tumor_ngs_library_to_sample_pair = OrderedDict()
Expand Down
4 changes: 2 additions & 2 deletions snappy_pipeline/workflows/ngs_mapping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def _get_output_files_run_work(self):
yield ext[1:].replace(".", "_"), self.base_path_out.format(mapper=self.name, ext=ext)
for ext in (".bamstats.txt", ".flagstats.txt", ".idxstats.txt"):
path = (
"work/{mapper}.{{library_name}}/report/bam_qc/" "{mapper}.{{library_name}}.bam{ext}"
"work/{mapper}.{{library_name}}/report/bam_qc/{mapper}.{{library_name}}.bam{ext}"
).format(mapper=self.name, ext=ext)
yield "report_" + ".".join(ext.split(".")[1:3]).replace(".", "_"), path
for ext in (
Expand All @@ -662,7 +662,7 @@ def _get_output_files_run_work(self):
".idxstats.txt.md5",
):
path = (
"work/{mapper}.{{library_name}}/report/bam_qc/" "{mapper}.{{library_name}}.bam{ext}"
"work/{mapper}.{{library_name}}/report/bam_qc/{mapper}.{{library_name}}.bam{ext}"
).format(mapper=self.name, ext=ext)
yield "report_" + ".".join(ext.split(".")[1:3]).replace(".", "_") + "_md5", path

Expand Down
3 changes: 1 addition & 2 deletions snappy_pipeline/workflows/repeat_expansion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ def check_config(self):
self.ensure_w_config(
config_keys=("static_data_config", "reference", "path"),
msg=(
"Path to reference FASTA not configured but required "
"for repeat expansion analysis."
"Path to reference FASTA not configured but required for repeat expansion analysis."
),
)
2 changes: 1 addition & 1 deletion snappy_pipeline/workflows/somatic_msi_calling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def input_function(wildcards):
)
)
tumor_base_path = (
"output/{mapper}.{tumor_library}/out/" "{mapper}.{tumor_library}"
"output/{mapper}.{tumor_library}/out/{mapper}.{tumor_library}"
).format(**wildcards)
return {
"normal_bam": ngs_mapping(normal_base_path + ".bam"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ def input_function(wildcards):
normal_library=self.get_normal_lib_name(wildcards), **wildcards
)
)
tumor_base_path = (
"output/{mapper}.{library_name}/out/" "{mapper}.{library_name}"
).format(**wildcards)
tumor_base_path = ("output/{mapper}.{library_name}/out/{mapper}.{library_name}").format(
**wildcards
)
yield "normal_bam", ngs_mapping(normal_base_path + ".bam")
yield "normal_bai", ngs_mapping(normal_base_path + ".bam.bai")
yield "tumor_bam", ngs_mapping(tumor_base_path + ".bam")
Expand Down Expand Up @@ -780,10 +780,7 @@ def _get_output_files_export():
("vcf_tbi", "vcf.gz.tbi"),
)
output_files = {}
tpl = (
"work/{{mapper}}.cnvkit.{{library_name}}/out/"
"{{mapper}}.cnvkit.{{library_name}}.{ext}"
)
tpl = "work/{{mapper}}.cnvkit.{{library_name}}/out/{{mapper}}.cnvkit.{{library_name}}.{ext}"
for export, ext in exports:
output_files[export] = tpl.format(export=export, ext=ext)
output_files[export + "_md5"] = output_files[export] + ".md5"
Expand Down Expand Up @@ -867,9 +864,9 @@ def input_function_run(wildcards):
normal_library=self.get_normal_lib_name(wildcards), **wildcards
)
)
tumor_base_path = (
"output/{mapper}.{library_name}/out/" "{mapper}.{library_name}"
).format(**wildcards)
tumor_base_path = ("output/{mapper}.{library_name}/out/{mapper}.{library_name}").format(
**wildcards
)
return {
"normal_bam": ngs_mapping(normal_base_path + ".bam"),
"normal_bai": ngs_mapping(normal_base_path + ".bam.bai"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ def get_input_files(self, action):
# Validate action
self._validate_action(action)
tpl = (
"output/{mapper}.{var_caller}.{tumor_library}/out/"
"{mapper}.{var_caller}.{tumor_library}"
"output/{mapper}.{var_caller}.{tumor_library}/out/{mapper}.{var_caller}.{tumor_library}"
)
key_ext = {"vcf": ".vcf.gz", "vcf_tbi": ".vcf.gz.tbi"}
variant_calling = self.parent.sub_workflows["somatic_variant_calling"]
Expand Down
13 changes: 6 additions & 7 deletions snappy_pipeline/workflows/somatic_variant_calling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def input_function(wildcards):
# Get names of primary libraries of the selected cancer bio sample and the
# corresponding primary normal sample
tumor_base_path = (
"output/{mapper}.{tumor_library}/out/" "{mapper}.{tumor_library}"
"output/{mapper}.{tumor_library}/out/{mapper}.{tumor_library}"
).format(**wildcards)
input_files = {
"tumor_bam": ngs_mapping(tumor_base_path + ".bam"),
Expand Down Expand Up @@ -410,9 +410,9 @@ def _get_input_files_run(self, wildcards):
ngs_mapping = self.parent.sub_workflows["ngs_mapping"]
# Get names of primary libraries of the selected cancer bio sample and the
# corresponding primary normal sample
tumor_base_path = (
"output/{mapper}.{tumor_library}/out/" "{mapper}.{tumor_library}"
).format(**wildcards)
tumor_base_path = ("output/{mapper}.{tumor_library}/out/{mapper}.{tumor_library}").format(
**wildcards
)
input_files = {
"tumor_bam": ngs_mapping(tumor_base_path + ".bam"),
"tumor_bai": ngs_mapping(tumor_base_path + ".bam.bai"),
Expand Down Expand Up @@ -737,7 +737,7 @@ def __init__(self, parent):
if self.__class__.name is None:
raise RuntimeError("Step name not given, override in sub class")
self.base_path_out = (
"work/{{mapper}}.{name}.{{donor_name}}/out/" "{{mapper}}.{name}.{{donor_name}}{ext}"
"work/{{mapper}}.{name}.{{donor_name}}/out/{{mapper}}.{name}.{{donor_name}}{ext}"
)
# Build shortcut from donor name to donor.
self.donor_by_name = OrderedDict()
Expand Down Expand Up @@ -783,8 +783,7 @@ def _get_log_file(self, action):
"""Return dict of log files."""
_ = action
prefix = (
"work/{{mapper}}.{var_caller}.{{donor_name}}/log/"
"{{mapper}}.{var_caller}.{{donor_name}}"
"work/{{mapper}}.{var_caller}.{{donor_name}}/log/{{mapper}}.{var_caller}.{{donor_name}}"
).format(var_caller=self.__class__.name)
key_ext = (
("log", ".log"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def get_input_files(self, action):
name_pattern += ".{annotator}"

# VCF file and index
tpl = f"output/{name_pattern}." "{tumor_library}/" f"out/{name_pattern}." "{tumor_library}"
tpl = f"output/{name_pattern}.{{tumor_library}}/out/{name_pattern}.{{tumor_library}}"
key_ext = {"vcf": ".vcf.gz", "vcf_tbi": ".vcf.gz.tbi"}
somatic_variant = self.parent.sub_workflows["somatic_variant"]
for key, ext in key_ext.items():
Expand Down
7 changes: 2 additions & 5 deletions snappy_pipeline/workflows/somatic_wgs_cnv_calling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def input_function(wildcards):
)
)
cancer_base_path = (
"output/{mapper}.{cancer_library}/out/" "{mapper}.{cancer_library}"
"output/{mapper}.{cancer_library}/out/{mapper}.{cancer_library}"
).format(**wildcards)
yield "normal_bam", ngs_mapping(normal_base_path + ".bam")
yield "normal_bai", ngs_mapping(normal_base_path + ".bam.bai")
Expand Down Expand Up @@ -564,10 +564,7 @@ def _get_output_files_plot(self):
def _get_output_files_export():
exports = (("bed", "bed"), ("seg", "seg"), ("vcf", "vcf.gz"), ("tbi", "vcf.gz.tbi"))
output_files = {}
tpl = (
"work/{{mapper}}.cnvkit.{{library_name}}/out/"
"{{mapper}}.cnvkit.{{library_name}}.{ext}"
)
tpl = "work/{{mapper}}.cnvkit.{{library_name}}/out/{{mapper}}.cnvkit.{{library_name}}.{ext}"
for export, ext in exports:
output_files[export] = tpl.format(export=export, ext=ext)
output_files[export + "_md5"] = output_files[export] + ".md5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def input_function(wildcards):
)
)
cancer_base_path = (
"output/{mapper}.{cancer_library}/out/" "{mapper}.{cancer_library}"
"output/{mapper}.{cancer_library}/out/{mapper}.{cancer_library}"
).format(**wildcards)
return {
"normal_bam": ngs_mapping(normal_base_path + ".bam"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ def input_function(wildcards):
yield "ped", real_path
# BAM and BAI file of the offspring
ngs_mapping = self.parent.sub_workflows["ngs_mapping"]
path_bam = (
"output/{mapper}.{index_library}/out/{mapper}." "{index_library}.bam"
).format(**wildcards)
path_bam = ("output/{mapper}.{index_library}/out/{mapper}.{index_library}.bam").format(
**wildcards
)
yield "bam", ngs_mapping(path_bam)
yield "bai", ngs_mapping(path_bam + ".bai")
# Input file comes from previous step.
Expand Down
4 changes: 2 additions & 2 deletions snappy_pipeline/workflows/variant_filtration/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ def ensure_filter_combinations_are_valid(self):
score: set[str] = set(self.score_thresholds.keys()) | {"all_scores"}
het_comp: set[str] = {"passthrough", "intervals500", "tads", "gene"}
pattern: str = r".".join(
f'({"|".join(p)})' for p in [thresholds, inherit, freq, region, score, het_comp]
f"({'|'.join(p)})" for p in [thresholds, inherit, freq, region, score, het_comp]
)
pattern: re.Pattern[str] = re.compile(pattern)
for combination in self.filter_combinations:
if pattern.fullmatch(combination) is None:
raise ValueError(
f"Invalid combination: {combination}, " f"must match pattern {pattern.pattern}"
f"Invalid combination: {combination}, must match pattern {pattern.pattern}"
)

return self
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ def _get_log_file_merge_vcf(self):
@dictify
def _get_log_file_annotate(self):
prefix = (
"work/varfish_annotated.{index_ngs_library}/log/"
"varfish_annotated.{index_ngs_library}"
"work/varfish_annotated.{index_ngs_library}/log/varfish_annotated.{index_ngs_library}"
)
key_ext = (
("log", ".log"),
Expand Down
3 changes: 1 addition & 2 deletions snappy_pipeline/workflows/wgs_sv_export_external/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ def _get_log_file_merge_vcf(self):
@dictify
def _get_log_file_annotate(self):
prefix = (
"work/varfish_annotated.{index_ngs_library}/log/"
"varfish_annotated.{index_ngs_library}"
"work/varfish_annotated.{index_ngs_library}/log/varfish_annotated.{index_ngs_library}"
)
key_ext = (
("log", ".log"),
Expand Down
2 changes: 1 addition & 1 deletion snappy_wrappers/tools/ped_to_vcf_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def run(args):
def main(argv=None):
"""Program entry point for parsing the command line."""
parser = argparse.ArgumentParser(
description=("Parse PED file and transform pedigree information into" "VCF header format")
description=("Parse PED file and transform pedigree information into VCF header format")
)
parser.add_argument(
"--ped-file",
Expand Down
3 changes: 1 addition & 2 deletions snappy_wrappers/tools/vcf_filter_denovo.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,7 @@ def main(argv=None):
# Setup command line parser
parser = argparse.ArgumentParser(
description=(
"Annotate VCF file with various of soft filters for sequence variant de "
"novo filtration"
"Annotate VCF file with various of soft filters for sequence variant de novo filtration"
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run(args):
file=args.out_file,
)
for i, genome in enumerate(genomes):
tpl = "{}\t{}\t{}\t{:0.2f}\t{}\t{:0.2f}\t{}\t{:0.2f}\t" "{}\t{:0.2f}\t{}\t{:0.2f}"
tpl = "{}\t{}\t{}\t{:0.2f}\t{}\t{:0.2f}\t{}\t{:0.2f}\t{}\t{:0.2f}\t{}\t{:0.2f}"
print(
tpl.format(
genome,
Expand Down
Loading

0 comments on commit 689696e

Please sign in to comment.