Skip to content

Commit 8b3b9c5

Browse files
Mike LeeMike Lee
authored andcommitted
minor updates to bit-assemble, bit-gen-reads, and bit-cov-analyzer; see changelog
1 parent e5251cd commit 8b3b9c5

8 files changed

Lines changed: 40 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
1414
-->
1515

16+
## v1.13.15 (13-Mar-2026)
17+
18+
### Changed
19+
- `bit-assemble`
20+
- the threads parameter is now passed to bbnorm and fastp (if run) in addition to the assemblers
21+
- `bit-gen-reads`
22+
- `--type long` will no longer preferentially start reads at position 0 if the requested read size is larger than the contig; now it will start randomly and just produce a read that ends where the contig ends (unless `--circularize` is added)
23+
- `bit-cov-analyzer`
24+
- no longer writes out individual window stats by default (to save spacetime), it needs to be turned on with the `--write-window-stats` now if wanted
25+
26+
---
27+
1628
## v1.13.14 (13-Mar-2026)
1729

1830
### Fixed

bit/cli/assemble.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ def build_parser():
6262
type=Path,
6363
default=Path("assembly"),
6464
)
65+
general.add_argument(
66+
"-t",
67+
"--threads",
68+
metavar="<INT>",
69+
help=wrap_help("Number of threads/cpus to pass to QC and assembly commands (default: 1; may be multiplied by number of snakemake jobs)"),
70+
default=1,
71+
type=int,
72+
)
6573
general.add_argument(
6674
"--run-fastp",
6775
action="store_true",
@@ -82,14 +90,6 @@ def build_parser():
8290
help=wrap_help("Assembler to use (default: megahit)"),
8391
default="megahit",
8492
)
85-
assembly.add_argument(
86-
"-t",
87-
"--threads",
88-
metavar="<INT>",
89-
help=wrap_help("Number of threads/cpus to pass as an assembler parameter (default: 1; may be multiplied by number of snakemake jobs)"),
90-
default=1,
91-
type=int,
92-
)
9393
assembly.add_argument(
9494
"--min-contig-len",
9595
metavar="<INT>",

bit/cli/cov_analyzer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def main():
124124
default=100,
125125
)
126126
optional.add_argument(
127-
"--no-window-stats",
128-
help='Add this flag to skip writing out individual window stats (saves spacetime)',
127+
"--write-window-stats",
128+
help='Add this flag to also write out individual window stats (saves spacetime by not doing so)',
129129
action="store_true",
130130
)
131131

@@ -153,7 +153,7 @@ def main():
153153
step_size = args.step_size,
154154
allowed_gap = args.allowed_gap,
155155
buffer = args.buffer,
156-
no_window_stats = args.no_window_stats,
156+
write_window_stats = args.write_window_stats,
157157
log_file = f"{args.output_dir}/runlog.txt",
158158
full_cmd_executed = full_cmd_executed
159159
)

bit/modules/cov_analyzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def run_cov_analyzer(
3030
step_size: int,
3131
allowed_gap: int,
3232
buffer: int,
33-
no_window_stats: bool,
33+
write_window_stats: bool,
3434
log_file = str,
3535
full_cmd_executed: str = None
3636
):
@@ -65,7 +65,7 @@ def run_cov_analyzer(
6565
low_merged_regions = annotate_zero_cov_bases(low_merged_regions, bam_file)
6666

6767
generate_outputs(reference_fasta, high_merged_regions, low_merged_regions,
68-
cov_df, cov_stats, buffer, output_dir, contig_lengths, no_window_stats,
68+
cov_df, cov_stats, buffer, output_dir, contig_lengths, write_window_stats,
6969
log_file)
7070

7171

@@ -345,12 +345,12 @@ def annotate_zero_cov_bases(merged_regions, bam_file):
345345

346346

347347
def generate_outputs(reference_fasta, high_merged_regions, low_merged_regions,
348-
cov_df, cov_stats, buffer, output_dir, contig_lengths, no_window_stats,
348+
cov_df, cov_stats, buffer, output_dir, contig_lengths, write_window_stats,
349349
log_file):
350350

351351
print()
352352
write_window_cov_stats(cov_stats, output_dir, contig_lengths, log_file)
353-
if not no_window_stats:
353+
if write_window_stats:
354354
write_windows_table(cov_stats, output_dir, log_file)
355355
write_window_plot_cov_histogram(cov_df, output_dir, log_file)
356356

bit/modules/gen_reads.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ def extract_subsequence(sequence, seq_length, subseq_len, circularize):
7272
subseq = sequence[start:end]
7373
else:
7474
subseq = sequence[start:] + sequence[: end - seq_length]
75+
elif subseq_len >= seq_length:
76+
# when the requested length meets or exceeds the contig length,
77+
# pick any start position and truncate at the contig end
78+
start = random.randint(0, seq_length - 1)
79+
subseq = sequence[start:]
7580
else:
7681
start = random.randint(0, seq_length - subseq_len)
7782
subseq = sequence[start:start + subseq_len]

bit/smk/assemble.smk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ if run_fastp:
4747
params:
4848
output_dir=output_dir + "/{sample}/filtered-reads",
4949
html=output_dir + "/{sample}/filtered-reads/{sample}-fastp.html",
50-
json=output_dir + "/{sample}/filtered-reads/{sample}-fastp.json"
50+
json=output_dir + "/{sample}/filtered-reads/{sample}-fastp.json",
51+
threads=threads
5152
log:
5253
log_files_dir + "/{sample}-fastp.log"
5354
shell:
@@ -56,7 +57,7 @@ if run_fastp:
5657
5758
fastp -i {input.R1} -I {input.R2} -o {output.R1} -O {output.R2} \
5859
--html {params.html} --json {params.json} \
59-
--thread 8 --detect_adapter_for_pe > {log} 2>&1
60+
--thread {params.threads} --detect_adapter_for_pe > {log} 2>&1
6061
"""
6162
else:
6263
post_fastp_reads_dict = reads_dict
@@ -81,15 +82,16 @@ if run_bbnorm:
8182
R2=output_dir + "/{sample}/bbnormd-reads/{sample}-bbnormd-R2.fastq.gz"
8283
params:
8384
output_dir=output_dir + "/{sample}/bbnormd-reads",
84-
target="100"
85+
target="100",
86+
threads=threads,
8587
log:
8688
log_files_dir + "/{sample}-bbnorm.log"
8789
shell:
8890
"""
8991
mkdir -p {params.output_dir}
9092
9193
bbnorm.sh in={input.R1} in2={input.R2} out={output.R1} out2={output.R2} \
92-
threads=8 target={params.target} > {log} 2>&1
94+
threads={params.threads} target={params.target} > {log} 2>&1
9395
"""
9496
else:
9597
post_bbnorm_reads_dict = post_fastp_reads_dict

bit/tests/test_cov_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def fake_run_mosdepth(bam_file, window_bed_path, output_dir):
135135
step_size=50,
136136
allowed_gap=0,
137137
buffer=10,
138-
no_window_stats=False,
138+
write_window_stats=True,
139139
log_file=None,
140140
full_cmd_executed="pytest-run",
141141
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "bit"
7-
version = "1.13.14"
7+
version = "1.13.15"
88
description = "A set of bioinformatics scripts and workflows"
99
readme = "README.md"
1010
license = { text = "GPLv3" }

0 commit comments

Comments
 (0)