Skip to content

Commit

Permalink
Merge pull request #17 from rouskinlab/0.21.0
Browse files Browse the repository at this point in the history
0.21.0
  • Loading branch information
matthewfallan authored Oct 11, 2024
2 parents ad32e97 + 455101f commit d21c3b0
Show file tree
Hide file tree
Showing 182 changed files with 58,552 additions and 3,048 deletions.
2 changes: 1 addition & 1 deletion make_conda_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def calc_github_file_sha256():
url = find_github_file()
response = urlopen(url)
if response.status != 200:
raise URLError(f"{url} returned status {response.status}")
raise URLError(f"{url} returned status {response.command}")
return sha256(response.read()).hexdigest()


Expand Down
9 changes: 2 additions & 7 deletions meta/license.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
"""
Add a summary of the license to the end of each source file.
"""


import os
from logging import DEBUG, basicConfig, getLogger

# This module lies outside the SEISMIC-RNA package, so it needs to use
# the Logger from Python's standard library, not from SEISMIC-RNA.
basicConfig(level=DEBUG)
logger = getLogger(__name__)

Expand Down
15 changes: 7 additions & 8 deletions src/seismicrna/align/fqunit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from functools import cached_property
from itertools import chain
from logging import getLogger
from pathlib import Path
from subprocess import CompletedProcess

Expand All @@ -10,8 +9,7 @@
ShellCommand,
args_to_cmd,
cmds_to_pipe)

logger = getLogger(__name__)
from ..core.logs import logger

FQ_LINES_PER_READ = 4
PHRED_ENCS = {33, 64}
Expand Down Expand Up @@ -126,9 +124,10 @@ def __init__(self, *,
self.phred_enc = phred_enc
self.one_ref = one_ref
self.sample, self.ref, self.exts = self.get_sample_ref_exts()
logger.debug(f"Instantiated a {type(self).__name__} with "
+ ", ".join(f"{k} = {v}" for k, v in self.paths.items())
+ f", phred_enc = {phred_enc}, one_ref = {one_ref}")
logger.detail(
f"Instantiated a {type(self).__name__} with paths={self.paths}, "
f"phred_enc={phred_enc}, one_ref={one_ref}"
)

@cached_property
def phred_arg(self):
Expand Down Expand Up @@ -231,7 +230,7 @@ def _from_files(cls, /, *,
try:
yield cls(phred_enc=phred_enc, one_ref=one_ref, **{key: fq})
except Exception as error:
logger.error(f"Failed to load FASTQ file {fq}: {error}")
logger.error(error)

@classmethod
def _from_mates(cls, /, *,
Expand Down Expand Up @@ -276,7 +275,7 @@ def by_tag(fqs_: list[Path], segs: list[path.Segment]):
try:
yield cls(phred_enc=phred_enc, one_ref=one_ref, **fq_args)
except Exception as error:
logger.error(f"Failed to load FASTQ pair {fq_args}: {error}")
logger.error(error)

@classmethod
def from_paths(cls, /, *, phred_enc: int, **fastq_args: list[Path]):
Expand Down
97 changes: 48 additions & 49 deletions src/seismicrna/align/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from logging import getLogger
from pathlib import Path

from click import command
Expand Down Expand Up @@ -66,10 +65,8 @@
require_dependency)
from ..core.run import run_func

logger = getLogger(__name__)


@run_func(logger.critical,
@run_func(CMD_ALIGN,
with_tmp=True,
pass_keep_tmp=True,
extra_defaults=extra_defaults)
Expand Down Expand Up @@ -149,51 +146,53 @@ def run(fasta: str, *,
dmfastqx=list(map(Path, dmfastqx)),
phred_enc=phred_enc))
# Generate and return a BAM file for every FASTQ-reference pair.
return align_samples(fq_units=fq_units,
fasta=Path(fasta),
out_dir=Path(out_dir),
tmp_dir=tmp_dir,
keep_tmp=keep_tmp,
force=force,
max_procs=max_procs,
parallel=parallel,
fastp=fastp,
fastp_5=fastp_5,
fastp_3=fastp_3,
fastp_w=fastp_w,
fastp_m=fastp_m,
fastp_poly_g=fastp_poly_g,
fastp_poly_g_min_len=fastp_poly_g_min_len,
fastp_poly_x=fastp_poly_x,
fastp_poly_x_min_len=fastp_poly_x_min_len,
fastp_adapter_trimming=fastp_adapter_trimming,
fastp_adapter_1=fastp_adapter_1,
fastp_adapter_2=fastp_adapter_2,
fastp_adapter_fasta=optional_path(fastp_adapter_fasta),
fastp_detect_adapter_for_pe=fastp_detect_adapter_for_pe,
fastp_min_length=fastp_min_length,
bt2_local=bt2_local,
bt2_discordant=bt2_discordant,
bt2_mixed=bt2_mixed,
bt2_dovetail=bt2_dovetail,
bt2_contain=bt2_contain,
bt2_un=bt2_un,
bt2_score_min_e2e=bt2_score_min_e2e,
bt2_score_min_loc=bt2_score_min_loc,
bt2_i=bt2_i,
bt2_x=bt2_x,
bt2_gbar=bt2_gbar,
bt2_l=bt2_l,
bt2_s=bt2_s,
bt2_d=bt2_d,
bt2_r=bt2_r,
bt2_dpad=bt2_dpad,
bt2_orient=bt2_orient,
min_mapq=min_mapq,
min_reads=min_reads,
sep_strands=sep_strands,
f1r2_fwd=f1r2_fwd,
rev_label=rev_label)
return align_samples(
fq_units=fq_units,
fasta=Path(fasta),
out_dir=Path(out_dir),
tmp_dir=tmp_dir,
keep_tmp=keep_tmp,
force=force,
max_procs=max_procs,
parallel=parallel,
fastp=fastp,
fastp_5=fastp_5,
fastp_3=fastp_3,
fastp_w=fastp_w,
fastp_m=fastp_m,
fastp_poly_g=fastp_poly_g,
fastp_poly_g_min_len=fastp_poly_g_min_len,
fastp_poly_x=fastp_poly_x,
fastp_poly_x_min_len=fastp_poly_x_min_len,
fastp_adapter_trimming=fastp_adapter_trimming,
fastp_adapter_1=fastp_adapter_1,
fastp_adapter_2=fastp_adapter_2,
fastp_adapter_fasta=optional_path(fastp_adapter_fasta),
fastp_detect_adapter_for_pe=fastp_detect_adapter_for_pe,
fastp_min_length=fastp_min_length,
bt2_local=bt2_local,
bt2_discordant=bt2_discordant,
bt2_mixed=bt2_mixed,
bt2_dovetail=bt2_dovetail,
bt2_contain=bt2_contain,
bt2_un=bt2_un,
bt2_score_min_e2e=bt2_score_min_e2e,
bt2_score_min_loc=bt2_score_min_loc,
bt2_i=bt2_i,
bt2_x=bt2_x,
bt2_gbar=bt2_gbar,
bt2_l=bt2_l,
bt2_s=bt2_s,
bt2_d=bt2_d,
bt2_r=bt2_r,
bt2_dpad=bt2_dpad,
bt2_orient=bt2_orient,
min_mapq=min_mapq,
min_reads=min_reads,
sep_strands=sep_strands,
f1r2_fwd=f1r2_fwd,
rev_label=rev_label
)


# Parameters for command line interface
Expand Down
5 changes: 1 addition & 4 deletions src/seismicrna/align/split.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from logging import getLogger
from pathlib import Path

from click import command
Expand Down Expand Up @@ -50,8 +49,6 @@
from ..core.tmp import release_to_out
from ..core.write import need_write

logger = getLogger(__name__)


def split_xam_file(xam_file: Path,
out_dir: Path,
Expand Down Expand Up @@ -98,7 +95,7 @@ def split_xam_file(xam_file: Path,
return result_dir


@run_func(logger.critical, with_tmp=True, pass_keep_tmp=True)
@run_func(CMD_SPLITBAM, with_tmp=True, pass_keep_tmp=True)
def run(fasta: str, *,
# Inputs
input_path: tuple[str, ...],
Expand Down
6 changes: 3 additions & 3 deletions src/seismicrna/align/tests/write_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest as ut

from seismicrna.align.write import calc_flags_sep_strands
from seismicrna.core.logs import set_config, restore_config
from seismicrna.core.logs import Level, set_config, restore_config
from seismicrna.core.ngs import (FLAG_PAIRED,
FLAG_PROPER,
FLAG_FIRST,
Expand All @@ -25,7 +25,7 @@ def test_f1r2_paired_unmixed(self):

@restore_config
def test_f1r2_paired_mixed(self):
set_config(verbose=0, quiet=1)
set_config(verbosity=Level.ERROR)
expect = (([FLAG_FIRST | FLAG_PAIRED | FLAG_PROPER,
FLAG_SECOND | FLAG_REVERSE | FLAG_PAIRED | FLAG_PROPER],
[FLAG_SECOND | FLAG_REVERSE,
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_f2r1_paired_unmixed(self):

@restore_config
def test_f2r1_paired_mixed(self):
set_config(verbose=0, quiet=1)
set_config(verbosity=Level.ERROR)
expect = (([FLAG_FIRST | FLAG_REVERSE | FLAG_PAIRED | FLAG_PROPER,
FLAG_SECOND | FLAG_PAIRED | FLAG_PROPER],
[FLAG_SECOND,
Expand Down
Loading

0 comments on commit d21c3b0

Please sign in to comment.