📄 clean_jumbles
字号:
#! /bin/sh## clean_jumbles file_name_root#comm=`echo $0 | sed 's&^.*/&&g'`nosummaryflag="-nosummary"summaryflag="-summary"summary=1while echo " $1" | grep "^ -" >/dev/null; do if test $# -lt 2; then break elif test $1 = "$nosummaryflag"; then summary=0; shift elif test $1 = "-n"; then summary=0; shift elif test $1 = "$summaryflag"; then summary=1; shift elif test $1 = "-s"; then summary=1; shift elif test $1 = "-"; then shift; break else echo "Bad flag: $*"; shift $#; break fidoneif test $# -ne 1; then echo "Usage: $comm [ $nosummaryflag ] file_name_root" exitfiout="$1"# Check requested nameif test `ls -d $out.[0-9]* 2>/dev/null | wc -l` -eq 0; then echo "$comm: No files found of form $out.(jumble_seed)" exitelif grep '^Ln Likelihood' $out.[0-9]* >/dev/null; then :else echo "$comm: No likelihoods found in files of form $out.(jumble_seed)" exitfi# Summary existssummarized=0if test -f "$out.summary" -a $summary -gt 0; then if test ! -f "$out.tree" -o ! -f "$out.out"; then echo "$comm: Summary file $out.summary exists, but corresponding outputand tree files ($out.out and $out.tree) cannot be found.Cleaning aborted." exit else echo "Summary file $out.summary exists. New jumbles will be added to thatsummary without further checking." summarized=1 fifi# Don't clobber an existing fileif test $summarized -eq 0 -a \( -f "$out.tree" -o -f "$out.out" \); then echo "$comm: File(s) with the name(s) $out.out and/or $out.treealready exist and would be clobbered by 'cleaning' the jumble output files.Move them to a new name and try again." exitfi# Find best file PID with the given nameif test $summarized -eq 0; then pid=`grep '^Ln Likelihood' $out.[0-9]* /dev/null | sed 's/^\(.*\):Ln Like.*=\(.*\)$/\2 \1/' | sort -nr +0 | head -1 | sed -e 's/^[^ ]* //' -e 's/^.*\.//'`fi# Write score summary file, if requestedif test $summary -gt 0; then if test $summarized -eq 0; then grep '^Ln Likelihood' $out.[0-9]* /dev/null | sed 's/^\(.*\):\(Ln Like.*\)$/\2 (file: \1)/' | sort -nr +3 > "$out.summary" else temp_name="$out.`uname -n`.$$" mv "$out.summary" "$temp_name" grep '^Ln Likelihood' $out.[0-9]* /dev/null | sed 's/^\(.*\):\(Ln Like.*\)$/\2 (file: \1)/' | cat "$temp_name" - | sort -nr +3 > "$out.summary" rm -f "$temp_name" fifi# Move output and treefile to new namesif test $summarized -eq 0; then oldname="$out.$pid" if grep "^Ln Likelihood" "$oldname" >/dev/null; then newname="$out.out" treenew="$out.tree" treeold="treefile.$pid" checkpt="checkpoint.$pid" if test -f "$treeold"; then mv "$treeold" "$treenew" elif test -f "$checkpt"; then tail -1 "$checkpt" >"$treenew" else echo "$comm: Cannot find tree file. Cleaning aborted."; exit fi mv "$oldname" "$newname" rm -f "$checkpt" fifi# Remove other output, tree and checkpoint files:if test `ls -d $out.[0-9]* 2>/dev/null | wc -l` -gt 0; then pids=`grep '^Ln Likelihood' $out.[0-9]* /dev/null | sed -e 's/^\(.*\):Ln Like.*$/\1/' -e 's/^.*\.//'` for pid in $pids; do rm -f "$out.$pid" "treefile.$pid" "checkpoint.$pid" donefi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -