Skip to content

Commit 8142ad7

Browse files
committed
refactor: use early continue
Removes an extra indentation
1 parent 1f2c011 commit 8142ad7

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

main/como/rnaseq_preprocess.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -331,23 +331,21 @@ async def _create_config_df(
331331
if len(run_number) > 0:
332332
if run_number[0] != "r1":
333333
continue
334-
else:
335-
label_glob = study_number + rep_number + "r*"
336-
runs = [run for run in gene_counts_files if re.search(label_glob, run.as_posix())]
337-
multi_flag = 1
338-
frag_files = []
339-
340-
for r in runs:
341-
r_label = re.findall(r"r\d{1,3}", r.as_posix())[0]
342-
R_label = re.findall(r"R\d{1,3}", r.as_posix())[0] # noqa: N806
343-
frag_filename = "".join([context_name, "_", study_number, R_label, r_label, "_fragment_size.txt"])
344-
frag_files.append(como_input_dir / context_name / "fragmentSizes" / study_number / frag_filename)
345-
346-
context_path = como_input_dir / context_name
347-
layout_files: list[Path] = list((context_path / "layouts").rglob(f"{context_name}_{label}_layout.txt"))
348-
strand_files: list[Path] = list((context_path / "strandedness").rglob(f"{context_name}_{label}_strandedness.txt")) # fmt: skip # noqa: E501
349-
frag_files: list[Path] = list((context_path / "fragmentSizes").rglob(f"{context_name}_{label}_fragment_size.txt")) # fmt: skip # noqa: E501
350-
prep_files: list[Path] = list((context_path / "prepMethods").rglob(f"{context_name}_{label}_prep_method.txt"))
334+
label_glob = f"{study_number}{rep_number}r*" # S__R__r*
335+
runs = [run for run in gene_counts_files if re.search(label_glob, run.as_posix())]
336+
multi_flag = 1
337+
frag_files = []
338+
339+
for run in runs:
340+
run_number = re.findall(r"R\d{1,3}", run.as_posix())[0]
341+
replicate = re.findall(r"r\d{1,3}", run.as_posix())[0]
342+
frag_filename = "".join([context_name, "_", study_number, run_number, replicate, "_fragment_size.txt"])
343+
frag_files.append(como_context_dir / fragment_sizes_dirname / study_number / frag_filename)
344+
345+
layout_files: list[Path] = list(layout_dir.rglob(f"{context_name}_{label}_layout.txt"))
346+
strand_files: list[Path] = list(strandedness_dir.rglob(f"{context_name}_{label}_strandedness.txt"))
347+
frag_files: list[Path] = list(fragment_sizes_dir.rglob(f"{context_name}_{label}_fragment_size.txt"))
348+
prep_files: list[Path] = list(prep_method_dir.rglob(f"{context_name}_{label}_prep_method.txt"))
351349

352350
layout = "UNKNOWN"
353351
if len(layout_files) == 0:

0 commit comments

Comments
 (0)