Files
biyelunwen/99.scripts/workflow/phylogeny_reconstruction/02.mbsum.sh
T
agent e467d67723 Add scripts for phylogenetic analysis using MrBayes and RAxML
- Created `mbblock.txt` for MrBayes configuration.
- Implemented `mrbayes.sh` to convert FASTA to Nexus and run MrBayes.
- Developed `raxml.sh` to run modeltest-ng and raxml-ng on alignments.
- Added `04.filter_ogs.sh` to filter orthologous groups based on taxon count and sequence length.
- Implemented `01.run_mrbayes.sh` to execute MrBayes for multiple FASTA files.
- Created `02.mbsum.sh` to summarize MrBayes output while skipping high DSF analyses.
- Developed `03.run_raxml.sh` to run raxml-ng on filtered alignments.
2025-12-20 23:33:05 +08:00

32 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
THREADS=${THREADS:-12}
MIN_DSF=${MIN_DSF:-0.01}
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <mrbayes_output_dir> <mbsum_output_dir> <num_skip>"
echo "Summarize MrBayes output using mbsum, skipping analyses with high DSF"
exit 1
fi
mb_dir=$(readlink -f "$1")
mbsum_out_dir=$2
num_skip=$3
mkdir -p "$mbsum_out_dir"
echo -n "" >mbsum.skip.log
echo -n "" >mbsum.cmds
for i in "$mb_dir"/*/mrbayes.log; do
og_dir=$(dirname "$i")
base=$(basename "$og_dir")
## skip Average standard deviation of split frequencies > 0.01
dsf=$(awk '/Average standard deviation of split frequencies:/ {out=$7} END{print out+0}' "$i" 2>/dev/null)
if awk -v d="$dsf" -v min_dsf="$MIN_DSF" 'BEGIN{if (d >= min_dsf) exit 0; exit 1}'; then
echo "Skipping ${base} due to high DSF: ${dsf}" >>mbsum.skip.log
continue
else
echo "mbsum ${og_dir}/*.t -n $num_skip -o $mbsum_out_dir/${base}.in >> $og_dir/mbsum.log 2>&1" >>mbsum.cmds
fi
done
xargs -t -P "$THREADS" -I cmd -a mbsum.cmds bash -c "cmd"
echo "Mbsum all done!"