From f15e835ca23571cfd4d463f07d4a0b288f907b9f Mon Sep 17 00:00:00 2001 From: kedhammar Date: Thu, 12 Sep 2024 13:49:05 +0200 Subject: [PATCH] try mypy fix --- scripts/generate_aviti_run_manifest.py | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/scripts/generate_aviti_run_manifest.py b/scripts/generate_aviti_run_manifest.py index 8992dba3..afd1ef02 100644 --- a/scripts/generate_aviti_run_manifest.py +++ b/scripts/generate_aviti_run_manifest.py @@ -81,25 +81,27 @@ def idxs_from_label(label: str) -> list[str | tuple[str, str]]: """ # Initialize result - idxs = [] + idxs: list[str | tuple[str, str]] = [] # Expand 10X single indexes if TENX_SINGLE_PAT.findall(label): - match = TENX_SINGLE_PAT.findall(label)[0] + match: str = TENX_SINGLE_PAT.findall(label)[0] for tenXidx in Chromium_10X_indexes[match]: idxs.append(tenXidx) # Case of 10X dual indexes elif TENX_DUAL_PAT.findall(label): - match = TENX_DUAL_PAT.findall(label)[0] - i7_idx = Chromium_10X_indexes[match][0] - i5_idx = Chromium_10X_indexes[match][1] - idxs.append((i7_idx, revcomp(i5_idx))) + match: str = TENX_DUAL_PAT.findall(label)[0] + i7_idx: str = Chromium_10X_indexes[match][0] + i5_idx: str = Chromium_10X_indexes[match][1] + pair: tuple[str, str] = (i7_idx, revcomp(i5_idx)) + idxs.append(pair) # Case of SS3 indexes elif SMARTSEQ_PAT.findall(label): - match = SMARTSEQ_PAT.findall(label)[0] + match: str = SMARTSEQ_PAT.findall(label)[0] for i7_idx in SMARTSEQ3_INDEXES[match][0]: for i5_idx in SMARTSEQ3_INDEXES[match][1]: - idxs.append((i7_idx, revcomp(i5_idx))) + pair: tuple[str, str] = (i7_idx, revcomp(i5_idx)) + idxs.append(pair) # NoIndex cases elif label.replace(",", "").upper() == "NOINDEX" or ( label.replace(",", "").upper() == "" @@ -107,12 +109,14 @@ def idxs_from_label(label: str) -> list[str | tuple[str, str]]: raise AssertionError("NoIndex cases not allowed.") # Ordinary indexes elif IDX_PAT.findall(label): - match = IDX_PAT.findall(label)[0] + match: str = IDX_PAT.findall(label)[0] if "-" in match: - idx1, idx2 = match.split("-") - idxs.append((idx1, revcomp(idx2))) + idx1: str = match.split("-")[0] + idx2: str = match.split("-")[1] + pair: tuple[str, str] = (idx1, idx2) + idxs.append(pair) else: - idx1 = match + idx1: str = match idxs.append(idx1) else: raise AssertionError(f"Could not parse index from '{label}'.")