Hi Mat, there seems to be a
problem with the addInterval function, when the interval tree is empty. I will
fix that as soon as possible. However, in your case it
would make sense to create a string of intervals, and then construct the
interval tree on the whole set of intervals at once. This will be more
efficient and may construct a more balanced tree. addInterval was originally
meant to add intervals later on to an existing tree (anyway, it should of
course also work on an empty tree!). You can see an example in
demos/interval_tree.cpp. I’m copy&pasting the relevant part here:
typedef CharString TCargo; // id type
typedef int TValue;
// position type
typedef IntervalAndCargo<TValue, TCargo> TInterval;
typedef IntervalTree<TValue, TCargo> TIntervalTree;
String<TInterval> intervals;
resize(intervals,3);
// store gene annotation in intervals
intervals[0].i1 = 5; intervals[0].i2 = 1000;
intervals[0].cargo = "gene";
intervals[1].i1 = 50; intervals[1].i2 = 200;
intervals[1].cargo = "exon";
intervals[2].i1 = 600; intervals[2].i2 = 800;
intervals[2].cargo = "exon";
TIntervalTree tree(intervals); Best, Anne-Katrin From: Mat [mailto:matthias.dodt@mdc-berlin.de] Hey guys! |