Skip to content

Commit a0ded9e

Browse files
authored
Merge pull request #566 from BU-ISCIII/develop
Develop merge for 2.2.12 release
2 parents c7301a3 + 52811b0 commit a0ded9e

File tree

6 files changed

+74
-21
lines changed

6 files changed

+74
-21
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.2.12] - 2025-07-18 : https://github.com/BU-ISCIII/buisciii-tools/releases/tag/2.2.12
8+
9+
### Credits
10+
11+
- [Victor Lopez](https://github.com/victor5lm)
12+
13+
### Template fixes and updates
14+
15+
- Fixed IRMA's 99-stats lablog to take host reads from samtools stats instead of kraken [#564](https://github.com/BU-ISCIII/buisciii-tools/pull/564).
16+
- Fixed sgene_metrics.sh to handle warnings properly [#565](https://github.com/BU-ISCIII/buisciii-tools/pull/565).
17+
18+
### Modules
19+
20+
- Fixed finish module so that the clean module is run correctly [#564](https://github.com/BU-ISCIII/buisciii-tools/pull/564).
21+
- Fixed bioinfo_doc module so that a text file can properly be used for email notes [#564](https://github.com/BU-ISCIII/buisciii-tools/pull/564).
22+
23+
#### Added enhancements
24+
25+
#### Fixes
26+
27+
#### Changed
28+
29+
#### Removed
30+
31+
### Requirements
32+
733
## [2.2.11] - 2025-07-11 : https://github.com/BU-ISCIII/buisciii-tools/releases/tag/2.2.11
834

935
### Credits

buisciii/__main__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def run_buisciii():
5757
)
5858

5959
# stderr.print("[green] `._,._,'\n", highlight=False)
60-
__version__ = "2.2.11"
60+
__version__ = "2.2.12"
6161
stderr.print(
6262
"[grey39] BU-ISCIII-tools version {}".format(__version__), highlight=False
6363
)
@@ -419,10 +419,15 @@ def finish(ctx, resolution, path, ask_path, sftp_folder, tmp_dir):
419419
"""
420420
Service cleaning, remove big files, rename folders before copy and copy resolution FOLDER to sftp.
421421
"""
422-
print("Starting cleaning scratch directory: " + tmp_dir)
422+
423+
clean_tmp_dir = tmp_dir
424+
if tmp_dir == "/scratch/bi/":
425+
clean_tmp_dir = "/data/ucct/bi/scratch_tmp/bi"
426+
427+
print("Starting cleaning scratch directory: " + clean_tmp_dir)
423428
clean_scratch = buisciii.clean.CleanUp(
424429
resolution,
425-
tmp_dir,
430+
clean_tmp_dir,
426431
ask_path,
427432
"clean",
428433
ctx.obj["api_user"],

buisciii/bioinfo_doc.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def create_structure(self):
256256
if os.path.exists(self.service_folder):
257257
log.info("Already creted the service folder for %s", self.service_folder)
258258
stderr.print(
259-
"[green] Skiping folder creation for service "
259+
"[green] Skipping folder creation for service "
260260
+ self.service_folder
261261
+ ". Trying with subfolders"
262262
)
@@ -267,7 +267,7 @@ def create_structure(self):
267267
self.service_folder,
268268
)
269269
stderr.print(
270-
"[green] Skiping folder creation for service "
270+
"[green] Skipping folder creation for service "
271271
+ self.service_folder
272272
+ "/"
273273
+ folder
@@ -547,7 +547,7 @@ def copy_images(self):
547547
"images",
548548
)
549549
if not os.path.exists(file_path):
550-
stderr.print("[green] Coping images folder temporarylly to " + file_path)
550+
stderr.print("[green] Copying images folder temporarily to " + file_path)
551551
images_folder = os.path.join(
552552
os.path.dirname(os.path.realpath(__file__)), "assets/reports/md/images"
553553
)
@@ -678,11 +678,13 @@ def email_creation(self):
678678
stderr.print(
679679
"No more attempts. Email notes will be given by prompt"
680680
)
681-
email_data["email_notes"] = (
682-
buisciii.utils.ask_for_some_text(
683-
msg="Write email notes"
684-
).replace("\n", "<br />")
685-
)
681+
email_data["email_notes"] = None
682+
else:
683+
email_data["email_notes"] = None
684+
685+
if email_data["email_notes"]:
686+
with open(os.path.expanduser(email_data["email_notes"])) as f:
687+
email_data["email_notes"] = f.read().replace("\n", "<br />")
686688
else:
687689
email_data["email_notes"] = buisciii.utils.ask_for_some_text(
688690
msg="Write email notes"

buisciii/templates/IRMA/ANALYSIS/ANALYSIS01_IRMA/99-stats/lablog

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,11 @@ echo "
159159
pc_genome_greater_10x=\$(printf \"%s\\n\" \"\${pc10x[@]}\" | sort -n | awk '{sum+=\$1} END {printf \"%.2f\", (NR ? sum/NR : 0)}')
160160
virus_sequence=\$(awk -v sample=\"\${in}\" '\$1 == sample {ref = ref ? ref \",\" \$4 : \$4} END {if (ref) print ref}' ../06-variant-calling/sample_type_ref.txt)
161161
total_reads=\$(grep \"\\\"total_reads\\\"\" ../02-preprocessing/\${in}/\${in}_fastp.json | head -n1 | cut -d \":\" -f2 | sed \"s/,//g\")
162-
reads_hostR1=\$(cat ../../*_TAXPROFILER/kraken2/*/\${in}_*.kraken2.report.txt | grep \"Homo sapiens\" | awk '{print \$2}')
163-
reads_host_x2=\$((reads_hostR1 * 2))
164-
pc_reads_host=\$(awk -v v1=\$total_reads -v v2=\$reads_host_x2 'BEGIN {printf \"%.2f\", (v2*100)/v1}')
162+
reads_host=\$(awk -v sample=\"\${in}_run1\" '\$1 == sample {print int(\$2)}' ../../*_TAXPROFILER/multiqc/multiqc_data/samtools_alignment_plot.txt)
163+
pc_reads_host=\$(awk -v v1=\$total_reads -v v2=\$reads_host 'BEGIN {printf \"%.2f\", (v2*100)/v1}')
165164
reads_virus=\$(awk -F\"\t\" -v id=\"\$in\" '\$1 == id {print \$3}' ../04-irma/irma_stats_flu.txt)
166165
pc_reads_virus=\$(awk -v v1=\$reads_virus -v v2=\$total_reads 'BEGIN {if (v2 > 0) printf \"%.2f\", (v1 / v2) * 100; else print \"NA\"}')
167-
unmapped_reads=\$((total_reads - (reads_host_x2+reads_virus)))
166+
unmapped_reads=\$((total_reads - (reads_host+reads_virus)))
168167
pc_unmapped=\$(awk -v v1=\$total_reads -v v2=\$unmapped_reads 'BEGIN {printf \"%.2f\", (v2/v1)*100}')
169168
qc_filtered=\$(grep \"\\\"total_reads\\\"\" ../02-preprocessing/\${in}/\${in}_fastp.json | head -n2 | tail -n1 | cut -d \":\" -f2 | sed \"s/,//g\")
170169
read_length=\$(unzip -p ../03-procQC/\${in}/\${in}_R1_filtered_fastqc.zip */fastqc_data.txt | grep \"Sequence length\" | cut -d \"-\" -f2)
@@ -206,7 +205,7 @@ echo "
206205
variants_PB1=\${variants[PB1]}
207206
variants_PB2=\${variants[PB2]}
208207
209-
echo -e \"\${in}\t\$virus_sequence\t\$flu_type\t\$flu_subtype\t\$clade\t\$clade_assignment_date\t\$clade_assignment_software_database_version\t\$total_reads\t\$qc_filtered\t\$reads_host_x2\t\$pc_reads_host\t\$reads_virus\t\$pc_reads_virus\t\$unmapped_reads\t\$pc_unmapped\t\$coverage_depth\t\$pc_genome_greater_10x\t\$pc_Ns\t\$variants_in_consensus\t\$variants_with_effect\t\$number_unambiguous_bases\t\$number_Ns\t\$read_length\t\$analysis_date\t\$cov_HA\t\$cov_MP\t\$cov_NA\t\$cov_NP\t\$cov_NS\t\$cov_PA\t\$cov_PB1\t\$cov_PB2\t\$cov10x_HA\t\$cov10x_MP\t\$cov10x_NA\t\$cov10x_NP\t\$cov10x_NS\t\$cov10x_PA\t\$cov10x_PB1\t\$cov10x_PB2\t\$perNs_HA\t\$perNs_MP\t\$perNs_NA\t\$perNs_NP\t\$perNs_NS\t\$perNs_PA\t\$perNs_PB1\t\$perNs_PB2\t\$variants_HA\t\$variants_MP\t\$variants_NA\t\$variants_NP\t\$variants_NS\t\$variants_PA\t\$variants_PB1\t\$variants_PB2\" >> summary_stats_\$(date \"+%Y%m%d\").tab
208+
echo -e \"\${in}\t\$virus_sequence\t\$flu_type\t\$flu_subtype\t\$clade\t\$clade_assignment_date\t\$clade_assignment_software_database_version\t\$total_reads\t\$qc_filtered\t\$reads_host\t\$pc_reads_host\t\$reads_virus\t\$pc_reads_virus\t\$unmapped_reads\t\$pc_unmapped\t\$coverage_depth\t\$pc_genome_greater_10x\t\$pc_Ns\t\$variants_in_consensus\t\$variants_with_effect\t\$number_unambiguous_bases\t\$number_Ns\t\$read_length\t\$analysis_date\t\$cov_HA\t\$cov_MP\t\$cov_NA\t\$cov_NP\t\$cov_NS\t\$cov_PA\t\$cov_PB1\t\$cov_PB2\t\$cov10x_HA\t\$cov10x_MP\t\$cov10x_NA\t\$cov10x_NP\t\$cov10x_NS\t\$cov10x_PA\t\$cov10x_PB1\t\$cov10x_PB2\t\$perNs_HA\t\$perNs_MP\t\$perNs_NA\t\$perNs_NP\t\$perNs_NS\t\$perNs_PA\t\$perNs_PB1\t\$perNs_PB2\t\$variants_HA\t\$variants_MP\t\$variants_NA\t\$variants_NP\t\$variants_NS\t\$variants_PA\t\$variants_PB1\t\$variants_PB2\" >> summary_stats_\$(date \"+%Y%m%d\").tab
210209
echo -e \"-----Statistics for \$in correctly added into summary_stats_\$(date \"+%Y%m%d\").tab-----\n\"
211210
unset gene_coverage coverages_10x per_Ns variants
212211
done

buisciii/templates/viralrecon/ANALYSIS/sgene_metrics.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
#!/bin/bash
22

3+
# Activate the micromamba environment
4+
eval "$(micromamba shell hook --shell bash)"
5+
micromamba activate outbreakinfo
6+
7+
# Ensure required tools are available
8+
for tool in blastn samtools bcftools; do
9+
if ! command -v "$tool" >/dev/null 2>&1; then
10+
echo "Error: $tool is not available. Make sure you have activated the corresponding micromamba environment. Aborting." >&2
11+
exit 1
12+
fi
13+
done
14+
15+
# Initialize warning counter
16+
warning_count=0
17+
318
# Define directories for variant analysis
419
input_fasta_dir=$(echo ./*_viralrecon_mapping/variants/ivar/consensus/bcftools)
520
input_bam_dir=$(echo ./*_viralrecon_mapping/variants/bowtie2)
@@ -24,14 +39,16 @@ for fasta_file in $input_fasta_dir/*.consensus.fa; do
2439

2540
ref_genome=${ref_map["$sample_name"]}
2641
if [ -z "$ref_genome" ]; then
27-
echo "Warning: No reference found for sample $sample_name" >&2
42+
echo "Warning: No reference found for sample $sample_name!" >&2
43+
((warning_count++))
2844
continue
2945
fi
3046

3147
# Run BLASTn to get S-gene coordinates in the consensus sequence
3248
blast_output=$(blastn -query "$SGENE_OUTPUT" -subject "$fasta_file" -outfmt "6 sstart send" | sort -k2,2nr | head -1)
3349
if [ -z "$blast_output" ]; then
34-
echo "Error: No BLAST hit found for sample $sample_name" >&2
50+
echo "Warning: No BLAST hit found for sample $sample_name!" >&2
51+
((warning_count++))
3552
continue
3653
fi
3754

@@ -68,11 +85,15 @@ for fasta_file in $input_fasta_dir/*.consensus.fa; do
6885
coverage_percentage=$(printf "%.2f" "$coverage_percentage")
6986

7087
# Count S-Gene Frameshifts
71-
vcf_file="$input_vcf_dir/consensus/${sample_name}.vcf.gz"
88+
vcf_file="$input_vcf_dir/consensus/bcftools/${sample_name}.vcf.gz"
7289
indels=$(bcftools view -r "$sample_name:$s_gene_start-$s_gene_end" -i 'TYPE="indel"' "$vcf_file" 2>/dev/null | wc -l)
7390

7491
# Save results to output file
7592
echo -e "$sample_name\t$ambiguous_percentage\t$coverage_percentage\t$indels\t$total_unambiguous_count\t$total_ns_count" >> $output_file
7693
done
7794

78-
echo "Process completed. File generated: $output_file"
95+
if [[ "$warning_count" -eq 0 ]]; then
96+
echo "✅ Process completed successfully. File generated: $output_file"
97+
else
98+
echo "⚠️ Process completed with $warning_count warning(s). Check logs above. File generated: $output_file"
99+
fi

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 = "buisciii-tools"
7-
version = "2.2.11"
7+
version = "2.2.12"
88
dynamic = ["dependencies"]
99

1010
authors = [

0 commit comments

Comments
 (0)