Skip to content

Commit

Permalink
distTree_new can work with a tree file as input
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrover committed Aug 29, 2020
1 parent d6415ae commit e8250d5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
10 changes: 6 additions & 4 deletions phylogeny/distTree_inc_place_seq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
THIS=`dirname $0`
source $THIS/../bash_common.sh
if [ $# -ne 2 ]; then
echo "Find the place of a sequence in a sequecne incremewntal tree"
echo "Find the place of a sequence in a sequence incremental tree"
echo "Print: <new sequence name> <tree node> <new leaf arc length> <tree node arc length>"
echo "#1: sequence file"
echo "#2: incremental tree directory"
exit 1
Expand All @@ -25,11 +26,12 @@ while [ -s $TMP.request ]; do
$INC/request2dissim.sh $TMP.request $QUERY $TMP.dissim-add $TMP.log &> /dev/null
rm $TMP.request
cat $TMP.dissim-add >> $TMP.dissim
$THIS/../phylogeny/distTree_new $INC/ -variance $VARIANCE -name $NAME -dissim $TMP.dissim -request $TMP.request -leaf $TMP.leaf
$THIS/../phylogeny/distTree_new $INC/tree.released -variance $VARIANCE -name $NAME -dissim $TMP.dissim -request $TMP.request -leaf $TMP.leaf
done

L=(`cat $TMP.leaf`)
echo "${L[0]} has arc of length ${L[2]} joining above ${L[1]} by ${L[3]}"
#L=(`cat $TMP.leaf`)
#echo "${L[0]} has arc of length ${L[2]} joining above ${L[1]} by ${L[3]}"
cat $TMP.leaf | cut -f 1,2,3,4


rm -fr $TMP*
Expand Down
36 changes: 20 additions & 16 deletions phylogeny/distTree_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ Update: <incremental distance tree directory>/search/")
version = VERSION;

// Input
addPositional ("data", "Directory with data");
addPositional ("data", "Directory with data ending with '\', or tree file");
addFlag ("init", "Initialize search");

//addKey ("dissim_power", "Power to raise dissimilarity in", "1");

addKey ("variance", "Dissimilarity variance function: " + varianceTypeNames. toString (" | "), varianceTypeNames [varianceType]);
addKey ("variance_power", "Power for -variance pow; >= 0", "NaN");
addFlag ("variance_dissim", "Variance is computed off dissimilarities");
addFlag ("variance_dissim", "Variance is computed off dissimilarities"); // Can be used in inc/varaince
addKey ("variance_min", "Min. dissimilarity variance; to be added to the computed variance", "0");

addKey ("name", "Name of the object");
Expand All @@ -81,19 +81,20 @@ Update: <incremental distance tree directory>/search/")
const string dataDir = getArg ("data");
const bool init = getFlag ("init");

//dissim_power = str2real (getArg ("dissim_power")); // Global
//dissim_power = str2real (getArg ("dissim_power")); // Global

varianceType = str2varianceType (getArg ("variance")); // Global
variancePower = str2real (getArg ("variance_power")); // Global
variance_min = str2real (getArg ("variance_min")); // Global
//const bool variance_dissim = getFlag ("variance_dissim");
varianceType = str2varianceType (getArg ("variance")); // Global
variancePower = str2real (getArg ("variance_power")); // Global
variance_min = str2real (getArg ("variance_min")); // Global
//const bool variance_dissim = getFlag ("variance_dissim");

const string name = getArg ("name");
const string dissimFName = getArg ("dissim");
const string requestFName = getArg ("request");
const string leafFName = getArg ("leaf");

if (! isRight (dataDir, "/"))

if (name. empty () && ! isRight (dataDir, "/"))
throw runtime_error (strQuote (dataDir) + " must end with '/'");

if (! isNan (variancePower) && varianceType != varianceType_pow)
Expand All @@ -103,9 +104,9 @@ Update: <incremental distance tree directory>/search/")
if (variancePower <= 0.0)
throw runtime_error ("-variance_power must be positive");

ASSERT (name. empty () == dissimFName. empty ());
ASSERT (name. empty () == requestFName. empty ());
ASSERT (name. empty () == leafFName. empty ());
QC_ASSERT (name. empty () == dissimFName. empty ());
QC_ASSERT (name. empty () == requestFName. empty ());
QC_ASSERT (name. empty () == leafFName. empty ());


if (verbose ())
Expand All @@ -114,12 +115,15 @@ Update: <incremental distance tree directory>/search/")
cout << endl;
}

DistTree tree (dataDir, string (), false, false, false);
tree. qc ();
unique_ptr<const DistTree> tree (isRight (dataDir, "/")
? new DistTree (dataDir, string (), false, false, false)
: new DistTree (dataDir, string (), string (), string ())
);
tree->qc ();

if (verbose ())
{
tree. printInput (cout);
tree->printInput (cout);
cout << endl;
}

Expand All @@ -130,13 +134,13 @@ Update: <incremental distance tree directory>/search/")
string item;
while (fig. next (item))
{
const NewLeaf nl (tree, newDir, item, init);
const NewLeaf nl (*tree, newDir, item, init);
nl. qc ();
}
}
else
{
const NewLeaf nl (tree, name, dissimFName, leafFName, requestFName, init);
const NewLeaf nl (*tree, name, dissimFName, leafFName, requestFName, init);
nl. qc ();
}
}
Expand Down
3 changes: 2 additions & 1 deletion version.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define VERSION "1.2.1"
#define VERSION "1.2.2"


// 1.2.2 08/28/2020 distTree_new.cpp accepts a tree file as input
// 1.2.1 08/20/2020 request2dissim.sh: 4 parameters
// 1.1.12 07/28/2020 Newick import removes transient nodes; printDistTree: 'itree' --> 'dm'
// 1.1.11 07/27/2020 improvement of Func::findZero(); statDistTree: length precision is increased; DistTree::saveFeatureTree(withTime); Feature::getLambda()
Expand Down

0 comments on commit e8250d5

Please sign in to comment.