// Analysis_RemLog::Setup() Analysis::RetType Analysis_RemLog::Setup(ArgList& analyzeArgs, DataSetList* datasetlist, DataFileList* DFLin, int debugIn) { debug_ = debugIn; // Get remlog dataset std::string remlogName = analyzeArgs.GetStringNext(); if (remlogName.empty()) { mprinterr("Error: no remlog data set or file name specified.\n"); return Analysis::ERR; } // Check if data set exists remlog_ = (DataSet_RemLog*)datasetlist->FindSetOfType( remlogName, DataSet::REMLOG ); if (remlog_ == 0) { mprinterr("Error: remlog data with name %s not found.\n", remlogName.c_str()); return Analysis::ERR; } if (remlog_->Size() < 1 || remlog_->NumExchange() < 1) { mprinterr("Error: remlog data set appears to be empty.\n"); return Analysis::ERR; } acceptout_ = DFLin->AddCpptrajFile( analyzeArgs.GetStringKey("acceptout"), "replica acceptance", DataFileList::TEXT, true ); if (acceptout_ == 0) return Analysis::ERR; lifetimes_ = DFLin->AddCpptrajFile( analyzeArgs.GetStringKey("lifetime"), "remlog lifetimes" ); calculateLifetimes_ = (lifetimes_ != 0); calculateStats_ = analyzeArgs.hasKey("stats"); if (calculateStats_) { statsout_ = DFLin->AddCpptrajFile( analyzeArgs.GetStringKey("statsout"), "remlog stats", DataFileList::TEXT, true ); reptime_ = DFLin->AddCpptrajFile( analyzeArgs.GetStringKey("reptime"), "replica times", DataFileList::TEXT, true ); if (statsout_ == 0 || reptime_ == 0) return Analysis::ERR; } calcRepFracSlope_ = analyzeArgs.getKeyInt("reptimeslope", 0); std::string rfs_name = analyzeArgs.GetStringKey("reptimeslopeout"); if (!calculateStats_) { calcRepFracSlope_ = 0; rfs_name.clear(); } if ( (calcRepFracSlope_ > 0) != (!rfs_name.empty()) ) { mprinterr("Error: Both reptimeslope and reptimeslopeout must be specified.\n"); return Analysis::ERR; } repFracSlope_ = DFLin->AddCpptrajFile( rfs_name, "replica fraction slope" ); printIndividualTrips_ = analyzeArgs.hasKey("printtrips"); // Get mode if (analyzeArgs.hasKey("crdidx")) mode_ = CRDIDX; else if (analyzeArgs.hasKey("repidx")) mode_ = REPIDX; else mode_ = NONE; const char* def_name = 0; const char* yaxis = 0; if (mode_ == CRDIDX) { def_name = "repidx"; yaxis = "ylabel CrdIdx"; } else if (mode_ == REPIDX) { def_name = "crdidx"; yaxis = "ylabel RepIdx"; } // Set up an output set for each replica DataFile* dfout = 0; if (mode_ != NONE) { // Get output filename std::string outname = analyzeArgs.GetStringKey("out"); if (!outname.empty()) { dfout = DFLin->AddDataFile( outname, analyzeArgs ); if (dfout == 0 ) return Analysis::ERR; if (yaxis != 0 ) dfout->ProcessArgs(yaxis); } std::string dsname = analyzeArgs.GetStringKey("name"); if (dsname.empty()) dsname = datasetlist->GenerateDefaultName(def_name); MetaData md(dsname); for (int i = 0; i < (int)remlog_->Size(); i++) { md.SetIdx(i+1); DataSet_integer* ds = (DataSet_integer*)datasetlist->AddSet(DataSet::INTEGER, md); if (ds == 0) return Analysis::ERR; outputDsets_.push_back( (DataSet*)ds ); if (dfout != 0) dfout->AddDataSet( (DataSet*)ds ); ds->Resize( remlog_->NumExchange() ); } } mprintf(" REMLOG: %s, %i replicas, %i exchanges\n", remlog_->legend(), remlog_->Size(), remlog_->NumExchange()); if (mode_ == CRDIDX) mprintf("\tGetting coordinate index vs exchange.\n"); else if (mode_ == REPIDX) mprintf("\tGetting replica index vs exchange.\n"); if (mode_ != NONE && dfout != 0) mprintf("\tOutput is to %s\n", dfout->DataFilename().base()); if (calculateStats_) { mprintf("\tGetting replica exchange stats, output to %s\n", statsout_->Filename().full()); if (printIndividualTrips_) mprintf("\tIndividual round trips will be printed.\n"); mprintf("\tWriting time spent at each replica to %s\n", reptime_->Filename().full()); } if (calculateLifetimes_) mprintf("\tThe lifetime of each crd at each replica will be calculated.\n"); if (acceptout_ != 0) mprintf("\tOverall exchange acceptance % will be written to %s\n", acceptout_->Filename().full()); return Analysis::OK; }
// Action_ClusterDihedral::Print() void Action_ClusterDihedral::Print() { // Setup output file mprintf("\tPrinting Dihedral Clustering Results.\n"); // Print bin information outfile_->Printf("DIHEDRAL CLUSTER RESULTS"); if (mask_.MaskStringSet()) outfile_->Printf(" for %s", mask_.MaskString()); outfile_->Printf("\n"); long int num = 0; for (std::vector<DCmask>::const_iterator dih = DCmasks_.begin(); dih != DCmasks_.end(); ++dih) { outfile_->Printf(" %6li ", num++); outfile_->Printf("%-s(%i)", (*dcparm_)[ dih->A1() ].c_str(), dih->A1() + 1); outfile_->Printf("%-s(%i)", (*dcparm_)[ dih->A2() ].c_str(), dih->A2() + 1); outfile_->Printf("%-s(%i)", (*dcparm_)[ dih->A3() ].c_str(), dih->A3() + 1); outfile_->Printf("%-s(%i)", (*dcparm_)[ dih->A4() ].c_str(), dih->A4() + 1); outfile_->Printf(" [Bins=%i]\n", dih->Bins()); } outfile_->Printf("%zu clusters.\n", dcarray_.size()); // Sort array by count std::sort( dcarray_.begin(), dcarray_.end() ); // Allocate space for storing cluster #s for each frame std::vector<long int> framecluster( lastframe_ + 1 ); // Print sorted cluster array if (CUT_ > 0) outfile_->Printf("Only printing clusters with pop > %i\n",CUT_); num = 0; for (std::vector<DCnode>::const_iterator DC = dcarray_.begin(); DC != dcarray_.end(); ++DC) { if ( DC->Count() > CUT_ ) { //mprintf("DEBUG: Cluster %li has %i frames.\n", num, DC->NumFrames()); outfile_->Printf("Cluster %10li %10li [ ", num+1, DC->Count()); for (DCnode::bin_it binid = DC->binbegin(); binid != DC->binend(); ++binid) outfile_->Printf("%3i ", *binid); outfile_->Printf(" ]\n"); for (DCnode::frame_it frame = DC->framebegin(); frame != DC->frameend(); ++frame) { outfile_->Printf("%i ", *frame + 1); // store which cluster each frame belongs to. Not neccesary if user // didn't specify this option, but avoids a second loop if they did. framecluster[ *frame ] = num; } outfile_->Printf("\n"); } ++num; } // Place reordered cluster nums in CVT if (CVT_ != 0) { DataSet_integer* iCVT = (DataSet_integer*)CVT_; iCVT->Resize( framecluster.size() ); num = 0; for (std::vector<long int>::const_iterator cnum = framecluster.begin(); cnum != framecluster.end(); ++cnum) (*iCVT)[ num++ ] = (int)*cnum + 1; } // Print cluster for each frame if (framefile_ != 0) { mprintf("\tPrinting cluster number for each frame.\n"); num = 1; for (std::vector<long int>::const_iterator cnum = framecluster.begin(); cnum != framecluster.end(); ++cnum) { // Frame, cluster num, cluster count framefile_->Printf("%10li %10i %10li ", num++, *cnum + 1, dcarray_[*cnum].Count()); // Print binID for (DCnode::bin_it binid = dcarray_[*cnum].binbegin(); binid != dcarray_[*cnum].binend(); ++binid) framefile_->Printf("%03i", *binid); framefile_->Printf("\n"); } } // Print cluster information file if (infofile_!=0) { mprintf("\tPrinting cluster information.\n"); infofile_->Printf("%zu\n", DCmasks_.size()); for (std::vector<DCmask>::const_iterator dih = DCmasks_.begin(); dih != DCmasks_.end(); ++dih) { infofile_->Printf("%10i %10i %10i %10i %10i %8.3f\n", dih->A1()+1, dih->A2()+1, dih->A3()+1, dih->A4()+1, dih->Bins(), dih->Min()); } infofile_->Printf("%zu\n", dcarray_.size()); num = 1; for (std::vector<DCnode>::const_iterator DC = dcarray_.begin(); DC != dcarray_.end(); ++DC) { infofile_->Printf("%10li %10li ", num++, DC->Count()); for (DCnode::bin_it binid = DC->binbegin(); binid != DC->binend(); ++binid) infofile_->Printf(" %3i", *binid); infofile_->Printf("\n"); } } }