Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff format #461

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion VERSIONLOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# TACA Version Log

## 20241216.1
## 20250122.1

Ruff formatting.

## 20241216.2

Do not run ToulligQC if its output directory can be found.

Expand Down
8 changes: 4 additions & 4 deletions taca/cleanup/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,13 @@ def _def_get_size_unit(s):
gb = mb * 1000
tb = gb * 1000
if s > tb:
s = f"~{int(s/tb)}tb"
s = f"~{int(s / tb)}tb"
elif s > gb:
s = f"~{int(s/gb)}gb"
s = f"~{int(s / gb)}gb"
elif s > mb:
s = f"~{int(s/mb)}mb"
s = f"~{int(s / mb)}mb"
elif s > kb:
s = f"~{int(s/kb)}kb"
s = f"~{int(s / kb)}kb"
elif s > 0:
s = f"~{int(s)}b"
return str(s)
Expand Down
8 changes: 4 additions & 4 deletions taca/element/Element_Runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@ def make_demux_manifests(

# Get '[SAMPLES]' section
split_contents = manifest_contents.split("[SAMPLES]")
assert (
len(split_contents) == 2
), f"Could not split sample rows out of manifest {manifest_contents}"
assert len(split_contents) == 2, (
f"Could not split sample rows out of manifest {manifest_contents}"
)
sample_section = split_contents[1].strip().split("\n")

# Split into header and rows
Expand Down Expand Up @@ -560,7 +560,7 @@ def make_demux_manifests(
"[RUNVALUES]",
"KeyName, Value",
f"manifest_file, {file_name}",
f"manifest_group, {n+1}/{len(grouped_df)}",
f"manifest_group, {n + 1}/{len(grouped_df)}",
f"built_from, {manifest_to_split}",
]
)
Expand Down
12 changes: 6 additions & 6 deletions taca/nanopore/ONT_run_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def __init__(self, run_abspath: str):
None # This will be defined upon instantiation of a child class
)

assert re.match(
ONT_RUN_PATTERN, self.run_name
), f"Run {self.run_name} doesn't look like a run dir"
assert re.match(ONT_RUN_PATTERN, self.run_name), (
f"Run {self.run_name} doesn't look like a run dir"
)

# Parse MinKNOW sample and experiment name
with open(self.get_file("/run_path.txt")) as stream:
Expand Down Expand Up @@ -143,9 +143,9 @@ def touch_db_entry(self):
pore_count_history_file = os.path.join(
self.run_abspath, "pore_count_history.csv"
)
assert os.path.isfile(
pore_count_history_file
), f"Couldn't find {pore_count_history_file}"
assert os.path.isfile(pore_count_history_file), (
f"Couldn't find {pore_count_history_file}"
)

self.db.create_ongoing_run(self, run_path_file, pore_count_history_file)
logger.info(
Expand Down
2 changes: 1 addition & 1 deletion taca/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def query_yes_no(question, default="yes", force=False):
elif choice in valid:
return valid[choice]
else:
sys.stdout.write('Please respond with "yes" or "no" ' '(or "y" or "n").\n')
sys.stdout.write('Please respond with "yes" or "no" (or "y" or "n").\n')


def return_unique(seq):
Expand Down
3 changes: 1 addition & 2 deletions taca/utils/statusdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ def merge_dicts(d1, d2):
pass # same leaf value
else:
logger.debug(
f"Values for key {key} in d1 and d2 differ, "
"using the value of d1"
f"Values for key {key} in d1 and d2 differ, using the value of d1"
)
else:
d1[key] = d2[key]
Expand Down
2 changes: 1 addition & 1 deletion taca/utils/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def transfer(self):
# If we are not overwriting, return False
if not self.overwrite:
logger.debug(
f'target "{self.dest_path}" exists and will not be ' "overwritten"
f'target "{self.dest_path}" exists and will not be overwritten'
)
return False
# If the target is a mount, let's not mess with it
Expand Down
2 changes: 1 addition & 1 deletion tests/nanopore/test_ONT_run_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def create_ONT_run_dir(
"unknown_positive",
"zero",
]:
f.write(f"{state},{i},{i*100}\n")
f.write(f"{state},{i},{i * 100}\n")

if sync_finished:
open(f"{run_path}/.sync_finished", "w").close()
Expand Down
4 changes: 2 additions & 2 deletions tests/nanopore/test_instrument_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,15 @@ def test_dump_pore_count_history(setup_test_fixture):

# Nothing to add, no file
tmp = tempfile.TemporaryDirectory()
run_path = tmp.name + f"/experiment/sample/{DUMMY_RUN_NAME.replace('TEST','FLG')}"
run_path = tmp.name + f"/experiment/sample/{DUMMY_RUN_NAME.replace('TEST', 'FLG')}"
os.makedirs(run_path)
new_file = instrument_transfer.dump_pore_count_history(run_path, pore_counts)
assert open(new_file).read() == ""
tmp.cleanup()

# Nothing to add, file is present
tmp = tempfile.TemporaryDirectory()
run_path = tmp.name + f"/experiment/sample/{DUMMY_RUN_NAME.replace('TEST','FLG')}"
run_path = tmp.name + f"/experiment/sample/{DUMMY_RUN_NAME.replace('TEST', 'FLG')}"
os.makedirs(run_path)
open(run_path + "/pore_count_history.csv", "w").write("test")
new_file = instrument_transfer.dump_pore_count_history(run_path, pore_counts)
Expand Down
Loading