Skip to content

Commit

Permalink
fix: support int | str group ids
Browse files Browse the repository at this point in the history
  • Loading branch information
igboyes committed Oct 12, 2023
1 parent 3f4681d commit 2703f46
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Test
run: docker build --target=test .
release:
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Install semantic-release
run: npm i [email protected] [email protected]
- name: Release
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Update pyproject.toml version
run: sed -i 's/0\.0\.0/${{ github.event.release.tag_name }}/' pyproject.toml
- name: Login to Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GH_USERNAME }}
Expand All @@ -36,7 +36,8 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
target: "base"
labels: ${{ steps.meta.outputs.labels }}

3 changes: 1 addition & 2 deletions fixtures.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from pathlib import Path
from types import SimpleNamespace
from typing import List

from pyfixtures import fixture
from virtool_workflow.data_model.indexes import WFIndex


@fixture
def index(indexes: List[WFIndex]):
def index(indexes: list[WFIndex]):
return indexes[0]


Expand Down
8 changes: 4 additions & 4 deletions pathoscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import rust_utils
from functools import cached_property
from pathlib import Path
from typing import Any, Dict, Generator, List
from typing import Any, Generator


class SamLine:
Expand Down Expand Up @@ -36,7 +36,7 @@ def read_length(self) -> int:
return len(self.fields[9])

@cached_property
def fields(self) -> List[Any]:
def fields(self) -> list[Any]:
"""
The SAM fields
"""
Expand Down Expand Up @@ -135,7 +135,7 @@ def rescale_samscore(u, nu, max_score, min_score):
return u, nu


def find_sam_align_score(fields: List[Any]) -> float:
def find_sam_align_score(fields: list[Any]) -> float:
"""
Find the Bowtie2 alignment score for the given split line (``fields``).
Expand Down Expand Up @@ -494,7 +494,7 @@ def write_report(
return results


def calculate_coverage(sam_path: Path, ref_lengths: Dict[str, int]):
def calculate_coverage(sam_path: Path, ref_lengths: list[str, int]):
coverage_dict = {}
pos_length_list = []

Expand Down
67 changes: 52 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ license = "MIT"

[tool.poetry.dependencies]
python = "~3.10"
virtool-workflow = "^5.3.1"
virtool-workflow = "^5.4.2"
rust = "^0.1.1"

[tool.poetry.group.dev.dependencies]
black = "^23.1.0"
pre-commit = "^3.0.4"
pydantic-factories = "^1.15.0"
pytest = "^6.2.0"
pytest-aiohttp = "^0.3.0"
pytest-asyncio = "^0.15.1"
pytest-datafiles = "^2.0"
syrupy = "^1.7.4"
pytest-mock = "^3.7.0"
pytest-regressions = "^2.2.0"
pydantic-factories = "^1.15.0"
pre-commit = "^3.0.4"
black = "^23.1.0"
syrupy = "^1.7.4"

[tool.pytest.ini_options]
markers = ["datafiles: load datafiles", "asyncio_mode: auto"]
Expand Down
32 changes: 16 additions & 16 deletions workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import shlex
import shutil
from collections import defaultdict
from logging import getLogger
from pathlib import Path
from types import SimpleNamespace
from typing import Any, Dict, List, TextIO, Set
from typing import Any, TextIO

import rust_utils
import aiofiles
import aiofiles.os
import rust_utils
from structlog import get_logger
from virtool_workflow import hooks, step
from virtool_workflow.data_model.analysis import WFAnalysis
from virtool_workflow.data_model.indexes import WFIndex
Expand All @@ -20,7 +20,7 @@
from pathoscope import run as run_pathoscope
from pathoscope import write_report

logger = getLogger("pathoscope")
logger = get_logger("pathoscope")

BAD_FIRST_SAM_CHARACTERS = {"\n", "@", "#"}

Expand All @@ -41,7 +41,7 @@ def read_fastq_grouped_lines(fastq_file: TextIO):


def subtract_fastq(
current_fastq_path: Path, new_fastq_path: Path, subtracted_reads: Set[str]
current_fastq_path: Path, new_fastq_path: Path, subtracted_reads: set[str]
):
with open(current_fastq_path, "r") as current_fastq_file, open(
new_fastq_path, "w"
Expand Down Expand Up @@ -116,7 +116,7 @@ async def stdout_handler(line: bytes):
stdout_handler=stdout_handler,
)

logger.info("Found %i potential OTUs.", len(intermediate.to_otus))
logger.info("Found potential OTUs", count=len(intermediate.to_otus))


@step
Expand Down Expand Up @@ -221,9 +221,9 @@ async def eliminate_subtraction(
isolate_fastq_path: Path,
isolate_sam_path: Path,
proc: int,
results: Dict[str, Any],
results: dict[str, Any],
run_subprocess: RunSubprocess,
subtractions: List[WFSubtraction],
subtractions: list[WFSubtraction],
subtracted_sam_path: Path,
work_path: Path,
):
Expand Down Expand Up @@ -322,10 +322,10 @@ async def eliminate_subtraction(
await asyncio.to_thread(shutil.copyfile, new_fastq_path, current_fastq_path)

logger.info(
"Subtracted reads that mapped better to a subtraction subtraction_id=%s subtraction_name=%s count=%i",
subtraction.id,
subtraction.name,
subtracted_count,
"Some reads mapped better to a subtraction and were removed",
id=subtraction.id,
name=subtraction.name,
count=subtracted_count,
)

results["subtracted_count"] = subtracted_count
Expand All @@ -350,9 +350,9 @@ async def reassignment(
reassigned_path = work_path / "reassigned.sam"

logger.info(
"Running Pathoscope subtracted_sam_path=%s reassigned_path=%s",
subtracted_sam_path,
reassigned_path,
"Running Pathoscope",
subtracted_path=subtracted_sam_path,
reassigned_path=reassigned_path,
)

(
Expand All @@ -376,7 +376,7 @@ async def reassignment(

report_path = work_path / "report.tsv"

logger.info("Writing report report_path=%s", report_path)
logger.info("Writing report", path=report_path)

report = await asyncio.to_thread(
write_report,
Expand Down

0 comments on commit 2703f46

Please sign in to comment.