Skip to content

Commit

Permalink
#2: compute dissimilarity requests (0/1); #3: save old #1/dissim in #1/…
Browse files Browse the repository at this point in the history
…dissim.<version>.gz (0/1)
  • Loading branch information
Vyacheslav Brover committed Oct 17, 2024
1 parent 2cd15a2 commit b1965fc
Showing 1 changed file with 46 additions and 21 deletions.
67 changes: 46 additions & 21 deletions phylogeny/distTree_inc_refresh_dissim.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,71 @@
#!/bin/bash --noprofile
THIS=`dirname $0`
THIS=$( dirname $0 )
source $THIS/../bash_common.sh
if [ $# -ne 1 ]; then
echo "Compute new #1/dissim given #1/tree; save old #1/dissim in #1/dissim.<version>"
if [ $# -ne 3 ]; then
echo "Update #1/dissim"
echo "#1: incremental distance tree directory"
echo "#2: compute dissimilarity requests (0/1)"
echo "#3: save old #1/dissim in #1/dissim.<version>.gz (0/1)"
exit 1
fi
INC=$1
REQ=$2
SAVE=$3


VER=`cat $INC/version`
VER=$( cat $INC/version )
THREADS=$( file2var $INC/threads 15 )

N=15
if [ -e $INC/threads ]; then
N=`cat $INC/threads`
fi
THREADS="-threads $N"

wc -l $INC/dissim


section "Saving $INC/dissim to $INC/dissim.$VER"
if [ -e $INC/dissim.$VER ]; then
error "$INC/dissim.$VER exists"
if [ $SAVE == 1 ]; then
section "Saving $INC/dissim to $INC/dissim.$VER"
if [ -e $INC/dissim.$VER ]; then
error "$INC/dissim.$VER exists"
fi
cp $INC/dissim $INC/dissim.$VER && gzip $INC/dissim.$VER &
fi
wc -l $INC/dissim
cp $INC/dissim $INC/dissim.$VER
gzip $INC/dissim.$VER &


TMP=`mktemp`
TMP=$( mktemp )
comment $TMP


section "Computing dissimilarity requests"
$THIS/distTree_refresh_dissim $INC $TMP.req $INC/dissim $THREADS
wc -l $INC/dissim

if [ $REQ == 1 ]; then
section "Computing dissimilarity requests"
$THIS/distTree_refresh_dissim $INC $TMP.req $INC/dissim -threads $THREADS
else
cut -f 1,2 $INC/dissim > $TMP.req
fi

section "Computing dissimilarities"
$THIS/distTree_inc_request2dissim.sh $INC $TMP.req $TMP.dissim-add

section "Updating $INC/indiscern"
$THIS/distTree_inc_dissim2indiscern.sh $INC $TMP.dissim-add
cat $TMP.dissim-add >> $INC/dissim
section "Updating $INC/dissim and $INC/indiscern"
if [ $REQ == 1 ]; then
$THIS/distTree_inc_dissim2indiscern.sh $INC $TMP.dissim-add
cat $TMP.dissim-add >> $INC/dissim
else
mv $TMP.dissim-add $INC/dissim
cp /dev/null $INC/indiscern
$THIS/distTree_inc_dissim2indiscern.sh $INC $INC/dissim
section "Updating $INC/tree"
cp $INC/tree $INC/hist/tree.$VER
gzip $INC/hist/tree.$VER
VARIANCE=$( cat $INC/variance )
$THIS/makeDistTree -data $INC/ -output_tree $TMP.tree -threads $THREADS -variance $VARIANCE -fix_discernible -optimize -skip_len -subgraph_iter_max 2 > $INC/hist/makeDistTree.$VER
mv $TMP.tree $INC/tree
fi

section "QC $INC/indiscern"
$THIS/distTree_inc_indiscern_qc.sh $INC 0 0

VER=$(( VER + 1 ))
echo $VER > $INC/version


rm $TMP*
Expand Down

0 comments on commit b1965fc

Please sign in to comment.