Files
2026-10-02 03:32:03 +08:00

23 lines
681 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 轻量组装 QC:contig 数 / 总长度 / N50 / N 占比 / GC%
# 用法: bash asm_qc.sh <fasta文件或目录...> > qc.tsv
set -euo pipefail
files=()
for p in "$@"; do
if [ -d "$p" ]; then
while IFS= read -r f; do files+=("$f"); done \
< <(find "$p" -type f \( -name '*.fa' -o -name '*.fasta' -o -name '*.fna' -o -name '*.fa.gz' -o -name '*.fasta.gz' -o -name '*.fna.gz' \))
else
files+=("$p")
fi
done
seqkit stats -a -T -j 8 "${files[@]}" | awk 'BEGIN{OFS="\t"}
NR==1 {print $0, "N%"; next}
{
# $5=sum_len, $19=sum_n(N 碱基数)
n = ($5 > 0) ? sprintf("%.4f", $19 / $5 * 100) : "NA"
print $0, n
}'