57 auto en_map = std::unordered_map<int, PlacementTreeEdge*>();
58 for(
auto& edge : tree.
edges() ) {
60 assert( en_map.count( edge_data.edge_num() ) == 0);
61 en_map.emplace( edge_data.edge_num(), &edge );
73 bool only_max_lwr_placements
75 auto result = std::vector<std::vector< Pquery const* >>();
78 for(
auto const& pqry : sample.
pqueries() ) {
79 if( only_max_lwr_placements ) {
83 double max_v = std::numeric_limits<double>::lowest();
84 for(
auto const& place : pqry.placements() ) {
86 max_v = place.like_weight_ratio;
92 result[ max_p->
edge().
index() ].push_back( &pqry );
97 for(
auto const& place : pqry.placements() ) {
98 result[ place.edge().index() ].push_back( &pqry );
108 bool only_max_lwr_placements
110 std::vector< std::vector< PqueryPlacement const* >> result;
113 for(
auto const& pqry : smp.
pqueries() ) {
114 if( only_max_lwr_placements ) {
118 double max_v = std::numeric_limits<double>::lowest();
119 for(
auto const& place : pqry.placements() ) {
121 max_v = place.like_weight_ratio;
127 result[ max_p->
edge().
index() ].push_back( max_p );
132 for(
auto const& place : pqry.placements() ) {
133 result[ place.edge().index() ].push_back( &place );
145 std::vector<PqueryPlacement const*> result;
147 for(
auto const& pqry : smp.
pqueries() ) {
148 for(
auto const& place : pqry.placements() ) {
149 if( &place.edge() == &edge ) {
150 result.push_back( &place );
160 auto result = std::vector<size_t>( sample.
tree().
edge_count(), 0 );
162 for(
auto const& pqry : sample.
pqueries() ) {
163 for(
auto const& place : pqry.placements() ) {
164 ++result[ place.edge().index() ];
174 auto const set_size = sample_set.
size();
175 if( set_size == 0 ) {
183 #pragma omp parallel for
184 for(
size_t i = 0; i < set_size; ++i ) {
185 for(
auto const& pqry : sample_set[ i ].pqueries() ) {
186 for(
auto const& place : pqry.placements() ) {
187 ++result( i, place.edge().index() );
197 auto pqueries = std::vector<PqueryPlain>( smp.
size() );
199 #pragma omp parallel for
200 for (
size_t i = 0; i < smp.
size(); ++i) {
201 const auto& opqry = smp.
at(i);
203 pqueries[i].index = i;
205 pqueries[i].placements = std::vector<PqueryPlacementPlain>(opqry.placement_size());
207 for (
size_t j = 0; j < opqry.placement_size(); ++j) {
208 auto const& oplace = opqry.placement_at(j);
209 auto& place = pqueries[i].placements[j];
211 place.edge_index = oplace.edge().index();
212 place.primary_node_index = oplace.edge().primary_node().index();
213 place.secondary_node_index = oplace.edge().secondary_node().index();
217 place.pendant_length = oplace.pendant_length;
218 place.proximal_length = oplace.proximal_length;
219 place.like_weight_ratio = oplace.like_weight_ratio;
231 for(
auto& pqry : sample.
pqueries() ) {
234 double lwr_sum = 0.0;
235 for(
auto& p : pqry.placements() ) {
238 if( p.like_weight_ratio < 0.0 ) {
239 p.like_weight_ratio = 0.0;
241 if( p.like_weight_ratio > 1.0) {
242 p.like_weight_ratio = 1.0;
244 lwr_sum += p.like_weight_ratio;
247 if( p.pendant_length < 0.0 ) {
248 p.pendant_length = 0.0;
252 if( p.proximal_length < 0.0 ) {
253 p.proximal_length = 0.0;
261 if( lwr_sum > 1.0 ) {
266 for(
auto& n : pqry.names() ) {
270 if( n.multiplicity < 0.0 ) {
271 n.multiplicity = 0.0;
279 for(
auto& smp : sset ) {
291 if (it.is_last_iteration()) {
303 auto order = std::vector<int>();
304 for(
auto const& edge : tree.
edges() ) {
309 std::sort( order.begin(), order.end() );
310 if( std::unique( order.begin(), order.end() ) != order.end() ) {
315 if( order.empty() ) {
318 assert( order.size() >= 1 );
319 return order.front() == 0 && order.back() ==
static_cast<int>( order.size() - 1 );
330 if (it.is_last_iteration()) {
347 LOG_INFO <<
"Invalid placement tree topology.";
350 if( ! tree::tree_data_is< PlacementNodeData, PlacementEdgeData >( smp.
tree() )) {
351 LOG_INFO <<
"Tree does not only contain Placement Node and Edge data types.";
356 std::unordered_map<int, PlacementTreeEdge const*> edge_num_map;
357 for(
auto const& edge : smp.
tree().
edges() ) {
360 LOG_INFO <<
"More than one edge has edge_num '"
364 edge_num_map.emplace(
369 LOG_INFO <<
"Tree does not have correct edge nums.";
374 for(
auto const& pqry : smp.
pqueries() ) {
377 if (pqry.name_size() > 0) {
378 name =
"'" + pqry.name_at(0).name +
"'";
380 name =
"(unnamed pquery)";
384 if (check_values && pqry.placement_size() == 0) {
385 LOG_INFO <<
"Pquery without any placements at '" << name <<
"'.";
386 if (break_on_values) {
390 double ratio_sum = 0.0;
391 for(
auto pit = pqry.begin_placements(); pit != pqry.end_placements(); ++pit ) {
392 auto const& p = *pit;
401 edge_num_map.count( edge_data.edge_num() ) == 0 ||
402 edge_data.edge_num() != p.edge_num()
404 LOG_INFO <<
"Invlaid edge pointer or edge num.";
410 assert( edge_num_map.count( p.edge_num() ) > 0 );
416 if (p.like_weight_ratio < 0.0 || p.like_weight_ratio > 1.0) {
417 LOG_INFO <<
"Invalid placement with like_weight_ratio '" << p.like_weight_ratio
418 <<
"' not in [0.0, 1.0] at " << name <<
".";
419 if (break_on_values) {
423 if (p.pendant_length < 0.0 || p.proximal_length < 0.0) {
424 LOG_INFO <<
"Invalid placement with pendant_length '" << p.pendant_length
425 <<
"' or proximal_length '" << p.proximal_length <<
"' < 0.0 at "
427 if (break_on_values) {
431 if (p.proximal_length > edge_data.branch_length) {
432 LOG_INFO <<
"Invalid placement with proximal_length '" << p.proximal_length
433 <<
"' > branch_length '"
434 << edge_data.branch_length <<
"' at "
436 if (break_on_values) {
440 ratio_sum += p.like_weight_ratio;
444 if (check_values && ratio_sum > 1.000000001) {
445 LOG_INFO <<
"Invalid pquery with sum of like_weight_ratio '" << ratio_sum
446 <<
"' > 1.0 at " << name <<
".";
447 if (break_on_values) {
453 if (check_values && pqry.name_size() == 0) {
454 LOG_INFO <<
"Pquery without any names at '" << name <<
"'.";
455 if (break_on_values) {