static void pTree( struct phyloTree *tree,FILE *f, boolean noDups) /* print out phylogenetic tree in Newick format */ { if (tree) { int ii; if (noDups && (tree->numEdges == 1)) pTree(tree->edges[0], f, noDups); else { if (tree->numEdges) { fprintf(f,"("); for (ii= 0; ii < tree->numEdges; ii++) { pTree(tree->edges[ii], f, noDups); if (ii + 1 < tree->numEdges) fprintf(f,","); } fprintf(f,")"); } if (tree->ident->name) fprintf(f,"%s",tree->ident->name); //if (tree->ident->length != 0.0) fprintf(f,":%0.04g", tree->ident->length); if (tree->isDup) fprintf(f,"[&&NHX:D=Y]"); } } }
static PT_Tree pList(PT_Tree tree, int *i, SDF_Symbol ssym) { PT_Tree layout; PT_Args elems; PT_Args newElems; ATbool isLayout; int indent = *i; assert(PT_isTreeApplList(tree) && "This tool only supports AsFix2ME"); assert(SDF_isSymbolIterStar(ssym) || SDF_isSymbolIter(ssym)); layout = (PT_Tree) SDF_getSymbolWsAfterSymbol(ssym); elems = PT_getTreeArgs(tree); newElems = PT_makeArgsEmpty(); isLayout = ATfalse; for (; !PT_isArgsEmpty(elems); elems = PT_getArgsTail(elems)) { PT_Tree head = PT_getArgsHead(elems); if (isLayout) { newElems = PT_makeArgsList(createLayoutTree(*i, layout), newElems); *i = calcIndentationLevel(*i, layout); } else { newElems = PT_makeArgsList(pTree(head, i), newElems); } isLayout = !isLayout; *i = indent; } return PT_setTreeArgs(tree, PT_reverseArgs(newElems)); }
Tree1 * Tree1::Create() { Tree1 *pTree(new Tree1); if (pTree->Init()){ return pTree; } else return nullptr; }
Bush * Bush::Create() { Bush *pTree(new Bush); if (pTree->Init()){ return pTree; } else return nullptr; }
static PT_Args pArgs(PT_Args args, int *i) { int indent = *i; PT_Args newArgs = PT_makeArgsEmpty(); for(; !PT_isArgsEmpty(args); args = PT_getArgsTail(args)) { PT_Tree head = PT_getArgsHead(args); newArgs = PT_makeArgsList(pTree(head, i), newArgs); *i = indent; } return PT_reverseArgs(newArgs); }
// ---------------------------------------------------------------------------- void CMultiReaderApp::xProcessNewick( const CArgs& args, CNcbiIstream& istr, CNcbiOstream& ostr) // ---------------------------------------------------------------------------- { string strTree; char c = istr.get(); while (!istr.eof()) { strTree += c; if (c == ';') { CNcbiIstrstream istrstr(strTree.c_str()); auto_ptr<TPhyTreeNode> pTree(ReadNewickTree(istrstr) ); CRef<CBioTreeContainer> btc = MakeBioTreeContainer(pTree.get()); xWriteObject(*btc, ostr); strTree.clear(); } c = istr.get(); } }
static PT_Tree pTreeWithSymbol(PT_Tree tree, int *i, PT_Symbol sym, SDF_Symbol ssym) { if (PT_isSymbolSort(sym)) { return pTree(tree, i); } else if (PT_isSymbolLit(sym)) { return tree; } else if (PT_isSymbolIterStar(sym) || PT_isSymbolIterPlus(sym)) { return pList(tree, i, ssym); } else if (PT_isSymbolIterStarSep(sym) || PT_isSymbolIterPlusSep(sym)) { return pSepList(tree, i, ssym); } /* the rest is handled by doing nothing */ if (PT_hasTreeArgs(tree)) { return PT_setTreeArgs(tree, pArgs(PT_getTreeArgs(tree), i)); } else { return tree; } }
void phyloPrintTree( struct phyloTree *tree,FILE *f) /* print out phylogenetic tree in Newick format */ { pTree(tree, f, FALSE); fprintf(f, ";\n"); }
void phyloPrintTreeNoDups( struct phyloTree *tree,FILE *f) /* print out phylogenetic tree in Newick format (only speciation nodes) */ { pTree(tree, f, TRUE); fprintf(f, ";\n"); }
static PT_ParseTree pParseTree(PT_ParseTree parsetree) { int indent = 0; PT_Tree tree = PT_getParseTreeTree(parsetree); return PT_setParseTreeTree(parsetree, pTree(tree, &indent)); }
const CKeyFrame* CTrackerStereoMotionModel::_getLoopClosureKeyFrame( const UIDKeyFrame& p_uID, const Eigen::Isometry3d& p_matTransformationLEFTtoWORLD, cv::Mat& p_matDisplayLEFT ) { //ds save to cloudfile //CCloudstreamer::saveLandmarksToCloudFile( p_uID, p_matTransformationLEFTtoWORLD, m_cMatcherEpipolar.getVisibleLandmarks( ) ); //ds retrieve current point cloud const CDescriptorPointCloud* pCloudCurrent( CCloudstreamer::getCloud( p_uID, p_matTransformationLEFTtoWORLD, m_cMatcher.getVisibleOptimizedLandmarks( ) ) ); //ds retrieve current kdtree C67DTree* pTree( CCloudstreamer::getTree( p_uID, p_matTransformationLEFTtoWORLD, m_cMatcher.getVisibleOptimizedLandmarks( ) ) ); //ds match buffers std::shared_ptr< const std::vector< CMatchCloud > > p_vecMatchesBest( 0 ); UIDLandmark uBestMatches = 0; UIDKeyFrame uIDKeyFrameBest = 0; //ds compare current cloud against previous ones to enable loop closure (skipping the keyframes added just before) for( UIDKeyFrame i = 0; i < p_uID-m_uLoopClosingKeyFrameDistance; ++i ) { //ds get matches std::shared_ptr< const std::vector< CMatchCloud > > vecMatches( CCloudMatcher::getMatches( pCloudCurrent, m_vecClouds->at( i ) ) ); const UIDLandmark uNumberOfMatches = vecMatches->size( ); int32_t iTreeMatches = pTree->getMatches( m_vecTrees->at( i ) ); //std::printf( "<CTrackerStereoMotionModel>(_trackLandmarks) cloud [%02lu] > [%02lu] matches: %03lu\n", pCloudCurrent->uID, m_vecClouds->at( i )->uID, uNumberOfMatches ); std::printf( "<CTrackerStereoMotionModel>(_trackLandmarks) tree [%02lu] > [%02lu] matches: %03i\n", pTree->uID, m_vecTrees->at( i )->uID, iTreeMatches ); //ds if we have a suffient amount of matches if( m_uMinimumNumberOfMatchesLoopClosure < uNumberOfMatches ) { if( uBestMatches < uNumberOfMatches ) { p_vecMatchesBest = vecMatches; uIDKeyFrameBest = m_vecClouds->at( i )->uID; uBestMatches = uNumberOfMatches; } } } //ds push cloud m_vecClouds->push_back( pCloudCurrent ); m_vecTrees->push_back( pTree ); //ds if we got a match if( 0 < uBestMatches ) { std::printf( "<CTrackerStereoMotionModel>(_trackLandmarks) found loop closure for keyframes: %06lu -> %06lu (points: %lu)\n", p_uID, uIDKeyFrameBest, uBestMatches ); //ds draw matches for( const CMatchCloud& cMatch: *p_vecMatchesBest ) { cv::circle( p_matDisplayLEFT, m_vecLandmarks->at( cMatch.uIDQuery )->getLastDetectionLEFT( ), 3, CColorCodeBGR( 255, 0, 255 ), -1 ); } //m_uWaitKeyTimeoutMS = 0; //ds return reference return m_vecKeyFrames->at( uIDKeyFrameBest ); } else { //ds return empty return 0; } }
shared_ptr<TreeNode> TreeNode::makeTree(shared_ptr<NodeContent> node){ TreeNode *treeNode = new TreeNode(node); shared_ptr<TreeNode> pTree(treeNode); return pTree; }