vguard<vguard<LogProb> > SumProduct::logNodeExcludedPostProb (TreeNodeIndex node, TreeNodeIndex exclude, bool normalize) const { Require (!isGap(node), "Attempt to find posterior probability of sequence at gapped position"); const UnvalidatedAlphTok tok = isWild(node) ? -1 : model.tokenize(gappedCol[node]); vguard<LogProb> lppInit (model.alphabetSize(), isWild(node) ? 0 : -numeric_limits<double>::infinity()); if (!isWild(node)) lppInit[tok] = 0; vguard<vguard<LogProb> > v (model.components(), lppInit); LogProb norm = -numeric_limits<double>::infinity(); for (int cpt = 0; cpt < components(); ++cpt) { vguard<LogProb>& lpp = v[cpt]; for (auto& lp: lpp) lp += logCptWeight[cpt]; for (size_t nc = 0; nc < tree.nChildren(node); ++nc) { const TreeNodeIndex child = tree.getChild(node,nc); if (child != exclude) for (AlphTok i = 0; i < model.alphabetSize(); ++i) lpp[i] += log (E[cpt][child][i]) + logE[cpt][child]; } const TreeNodeIndex parent = tree.parentNode (node); for (AlphTok i = 0; i < model.alphabetSize(); ++i) { lpp[i] += parent == exclude ? 0 // to add a prior for orphaned nodes, this should be log(insProb[i]), but that complicates MCMC etc : (log(G[cpt][node][i]) + logG[cpt][node]); log_accum_exp (norm, lpp[i]); } } if (normalize) for (auto& lpp: v) for (auto& lp: lpp) lp -= norm; return v; }
NxI32 deleteFiles(const String &str) { WildCard *wild = createWildCard(str.c_str()); StringVector list; if ( isWild(wild) ) { FileFind ffind(wild); ffind.GetFiles(list); } else { list.push_back(str); } StringVector::iterator i; for (i=list.begin(); i!=list.end(); ++i) { #ifdef WIN32 DeleteFileA( (*i).c_str() ); #endif #ifdef LINUX_GENERIC assert(0); // not implemented on unix yet, not needed though. #endif } releaseWildCard(wild); NxI32 ret = list.size(); return ret; }
bool addFilename(StringAttrArray &names,const char *name,bool sub) { if (isWild(name)) { StringBuffer dir; const char *tail = splitDirTail(name,dir); if (isWild(dir.str())) { printf("Directory %s - cannot be wild!\n",dir.str()); return false; } Owned<IFile> dirf = createIFile(dir.str()); Owned<IDirectoryIterator> iter = dirf->directoryFiles(tail,sub,false); StringBuffer subname; ForEach(*iter) { subname.clear().append(iter->query().queryFilename()); names.append(*new StringAttrItem(subname.str())); } } else