void AnalysisTemplate::writeOutput() { // We print out the average of the mean distances for each group. for (size_t g = 0; g < sel_.size(); ++g) { fprintf(stderr, "Average mean distance for '%s': %.3f nm\n", sel_[g].name(), avem_->average(0, g)); } }
void SelectionTester::printSelections() { fprintf(stderr, "\nSelections:\n"); for (size_t g = 0; g < selections_.size(); ++g) { selections_[g].printDebugInfo(stderr, nmaxind_); } fprintf(stderr, "\n"); }
void AbstractTwoLevelAgreement::overLapNamesFinished(const SelectionList & tagWords, const SelectionList & outputWords,int &numWords) { if (tagWords.size()==0 && outputWords.size()==0 ) return; bool underComputation=(&numWords==&underNumWords); int countCommon=commonWords(text,tagWords,outputWords); //not working correctly on maximal boundaries int countCorrect=countWords(text,tagWords); int countDetected=countWords(text,outputWords); assert (countCorrect!=0); assert (countDetected!=0); numWords+=countCorrect; double recall=(double)countCommon/countCorrect * countCorrect, precision=(double)countCommon/countDetected *countCorrect; if (countDetected==0) precision=0; if (underComputation) { underBoundaryRecallList.append(recall); underBoundaryPrecisionList.append(precision); } else { boundaryRecallList.append(recall); boundaryPrecisionList.append(precision); } }
SelectionList TrajectoryAnalysisModuleData::parallelSelections(const SelectionList &selections) { // TODO: Consider an implementation that does not allocate memory every time. SelectionList newSelections; newSelections.reserve(selections.size()); SelectionList::const_iterator i = selections.begin(); for (; i != selections.end(); ++i) { newSelections.push_back(parallelSelection(*i)); } return newSelections; }
void Angle::checkSelections(const SelectionList &sel1, const SelectionList &sel2) const { if (natoms2_ > 0 && sel1.size() != sel2.size()) { GMX_THROW(InconsistentInputError( "-group1 and -group2 should specify the same number of selections")); } for (size_t g = 0; g < sel1.size(); ++g) { int na1 = sel1[g].posCount(); int na2 = (natoms2_ > 0) ? sel2[g].posCount() : 0; if (natoms1_ > 1 && na1 % natoms1_ != 0) { GMX_THROW(InconsistentInputError(formatString( "Number of positions in selection %d in the first group not divisible by %d", static_cast<int>(g + 1), natoms1_))); } if (natoms2_ > 1 && na2 % natoms2_ != 0) { GMX_THROW(InconsistentInputError(formatString( "Number of positions in selection %d in the second group not divisible by %d", static_cast<int>(g + 1), natoms2_))); } if (natoms1_ > 0 && natoms2_ > 1 && na1 / natoms1_ != na2 / natoms2_) { GMX_THROW(InconsistentInputError( "Number of vectors defined by the two groups are not the same")); } if (g2type_[0] == 's' && sel2[g].posCount() != 1) { GMX_THROW(InconsistentInputError( "The second group should contain a single position with -g2 sphnorm")); } } }
void SelectionTester::analyzeFrame(int /*frnr*/, const t_trxframe & /*fr*/, t_pbc * /*pbc*/, TrajectoryAnalysisModuleData * /*pdata*/) { fprintf(stderr, "\n"); for (size_t g = 0; g < selections_.size(); ++g) { const Selection &sel = selections_[g]; int n; fprintf(stderr, " Atoms (%d pcs):", sel.atomCount()); n = sel.atomCount(); if (nmaxind_ >= 0 && n > nmaxind_) { n = nmaxind_; } ConstArrayRef<int> atoms = sel.atomIndices(); for (int i = 0; i < n; ++i) { fprintf(stderr, " %d", atoms[i]+1); } if (n < sel.atomCount()) { fprintf(stderr, " ..."); } fprintf(stderr, "\n"); fprintf(stderr, " Positions (%d pcs):\n", sel.posCount()); n = sel.posCount(); if (nmaxind_ >= 0 && n > nmaxind_) { n = nmaxind_; } for (int i = 0; i < n; ++i) { const SelectionPosition &p = sel.position(i); fprintf(stderr, " (%.2f,%.2f,%.2f) r=%d, m=%d, n=%d\n", p.x()[XX], p.x()[YY], p.x()[ZZ], p.refId(), p.mappedId(), p.atomCount()); } if (n < sel.posCount()) { fprintf(stderr, " ...\n"); } } fprintf(stderr, "\n"); }
void TimeTaggerDialog::unTag_action() { if (this==NULL) return; SelectionList listForRemoval; int i=findSelection(0,SELECTION_OUTSIDE); if (i>=0) { while (i>=0) { listForRemoval.append(Selection(tags[i].first,tags[i].second)); tags.removeAt(i); i--; i=findSelection(i+1,SELECTION_OUTSIDE); } } else { QTextCursor c=text->textCursor(); int start=c.selectionStart(); int end=c.selectionEnd(); int i=findSelection(0,SELECTION_OUTSIDEOVERLAP); if (i>=0) { listForRemoval.append(Selection(start,end-1)); } while (i>=0) { if (tags[i].first>=start) { tags[i].first=end; } else { tags[i].second=start-1; } if (tags[i].first==tags[i].second) { tags.removeAt(i); i--; } i=findSelection(i+1,SELECTION_OUTSIDEOVERLAP); } } QTextCursor c=text->textCursor(); for (int i=0;i<listForRemoval.size();i++) { c.setPosition(listForRemoval[i].first,QTextCursor::MoveAnchor); c.setPosition(listForRemoval[i].second+1,QTextCursor::KeepAnchor); text->setTextCursor(c); text->setTextBackgroundColor(Qt::white); text->setTextColor(Qt::black); text->setTextCursor(c); } c.clearSelection(); text->setTextCursor(c); }
void AnalysisTemplate::initAnalysis(const TrajectoryAnalysisSettings &settings, const TopologyInformation & /*top*/) { nb_.setCutoff(cutoff_); data_.setColumnCount(0, sel_.size()); avem_.reset(new AnalysisDataAverageModule()); data_.addModule(avem_); if (!fnDist_.empty()) { AnalysisDataPlotModulePointer plotm( new AnalysisDataPlotModule(settings.plotSettings())); plotm->setFileName(fnDist_); plotm->setTitle("Average distance"); plotm->setXAxisIsTime(); plotm->setYLabel("Distance (nm)"); data_.addModule(plotm); } }
void AnalysisTemplate::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc, TrajectoryAnalysisModuleData *pdata) { AnalysisDataHandle dh = pdata->dataHandle(data_); const Selection &refsel = pdata->parallelSelection(refsel_); AnalysisNeighborhoodSearch nbsearch = nb_.initSearch(pbc, refsel); dh.startFrame(frnr, fr.time); for (size_t g = 0; g < sel_.size(); ++g) { const Selection &sel = pdata->parallelSelection(sel_[g]); int nr = sel.posCount(); real frave = 0.0; for (int i = 0; i < nr; ++i) { SelectionPosition p = sel.position(i); frave += nbsearch.minimumDistance(p.x()); } frave /= nr; dh.setPoint(g, frave); } dh.finishFrame(); }
void AbstractTwoLevelAgreement::overLapMainFinished(int i,int j,const SelectionList & tagNames, const SelectionList & outputNames,int &numNames) { bool underComputation=(&numNames==&underNumNames); assert(underComputation || (i<0 && j<0 )); //if in max-boundary, i and j have no significance QSet<int> visitedTags; int allCommonCount; int countCommon=commonNames(tagNames,outputNames,visitedTags,allCommonCount); int countCorrect=tagNames.size(); int countDetected=outputNames.size(); assert (countCommon<=countDetected); if (countCorrect>0) { numNames+=countCorrect; double recall=(double)countCommon/countCorrect * countCorrect, precision=(double)countCommon/countDetected *countCorrect; if (countDetected==0) precision=0; if (underComputation) { underNameRecallList.append(recall); underNamePrecisionList.append(precision); } else { nameRecallList.append(recall); namePrecisionList.append(precision); } int k=0,h=0; QList<int> common_k,common_h; SelectionList tagWords, outputWords; while (k<tagNames.size() && h<outputNames.size()) { int start1=tagNames[k].first,end1=tagNames[k].second, start2=outputNames[h].first,end2=outputNames[h].second; if (overLaps(start1,end1,start2,end2) && start1!=end2) { bool foundK=common_k.contains(k), foundH=common_h.contains(h); if (underComputation) startNamesOverLap(i,j,k,h,countCommon); if (!foundK /*&& !foundJ*/) {//so that merged parts will not be double counted common_k.append(k); tagWords.append(tagNames[k]); if (foundH) { //new correctnode that matches detected if (underComputation) anotherTagOverLapPreviousOutputName(i,j,k,h); } } if (!foundH) {//common_i and common_j now are not same size, bc recall and precision need different treatment for overlap common_h.append(h); outputWords.append(outputNames[h]); if (foundK) { //new detectednode that matches correct if (underComputation) anotherOutputOverLapPreviousTagName(i,j,k,h); } } if (!foundK && !foundH) { if (underComputation) firstNameOverLap(i,j,k,h); } //[underboundary computations SelectionList singleTagWords, singleOutputWords; singleTagWords.append(tagNames[k]); singleOutputWords.append(outputNames[h]); overLapNamesFinished(singleTagWords,singleOutputWords,underNumWords); //] int process=0; if (end1<=end2 ) { k++; process++; } if (end2<=end1) { h++; process++; } if (process==2) { //[max-boundary computations overLapNamesFinished(tagWords,outputWords,numWords); //] tagWords.clear(); outputWords.clear(); } } else if (before(start1,end1,start2,end2)) { if (underComputation) beforeMovingToNextTagName(i,j,k,h); //[max-boundary computations overLapNamesFinished(tagWords,outputWords,numWords); //] tagWords.clear(); outputWords.clear(); k++; } else if (after(start1,end1,start2,end2) ) { if (underComputation) beforeMovingToNextOutputName(i,j,k,h); //[max-boundary computations overLapNamesFinished(tagWords,outputWords,numWords); //] tagWords.clear(); outputWords.clear(); h++; } } if (tagWords.size()>0 || outputWords.size()>0) { //[max-boundary computations overLapNamesFinished(tagWords,outputWords,numWords); //] tagWords.clear(); outputWords.clear(); } } else { nameRecallList.append(0); namePrecisionList.append(0); } if (underComputation) { //under computation only if (hadithParameters.detailed_statistics) { theSarf->displayed_error <</*text->mid(start1,end1-start1+1)*/i<<"\t" <</*text->mid(start2,end2-start2+1)*/j<<"\t" <<countCommon<<"/"<<countCorrect<<"\t"<<allCommonCount<<"/"<<countDetected<<"\n"; } } }