void RFIGuiController::plotMeanSpectrum(bool weight) { if(IsImageLoaded()) { std::string title = weight ? "Sum spectrum" : "Mean spectrum"; Plot2D &plot = _plotManager->NewPlot2D(title); TimeFrequencyData data = ActiveData(); Mask2DCPtr mask = Mask2D::CreateSetMaskPtr<false>(data.ImageWidth(), data.ImageHeight()); Plot2DPointSet &beforeSet = plot.StartLine("Without flagging"); if(weight) RFIPlots::MakeMeanSpectrumPlot<true>(beforeSet, data, mask, MetaData()); else RFIPlots::MakeMeanSpectrumPlot<false>(beforeSet, data, mask, MetaData()); mask = Mask2D::CreateCopy(data.GetSingleMask()); if(!mask->AllFalse()) { Plot2DPointSet &afterSet = plot.StartLine("Flagged"); if(weight) RFIPlots::MakeMeanSpectrumPlot<true>(afterSet, data, mask, MetaData()); else RFIPlots::MakeMeanSpectrumPlot<false>(afterSet, data, mask, MetaData()); } _plotManager->Update(); } }
void RFIGuiController::PlotPowerTime() { if(IsImageLoaded()) { Plot2D &plot = _plotManager->NewPlot2D("Power over time"); plot.SetLogarithmicYAxis(true); TimeFrequencyData activeData = ActiveData(); Image2DCPtr image = activeData.GetSingleImage(); Mask2DPtr mask = Mask2D::CreateSetMaskPtr<false>(image->Width(), image->Height()); Plot2DPointSet &totalPlot = plot.StartLine("Total"); RFIPlots::MakePowerTimePlot(totalPlot, image, mask, MetaData()); mask = Mask2D::CreateCopy(activeData.GetSingleMask()); if(!mask->AllFalse()) { Plot2DPointSet &uncontaminatedPlot = plot.StartLine("Uncontaminated"); RFIPlots::MakePowerTimePlot(uncontaminatedPlot, image, mask, MetaData()); mask->Invert(); Plot2DPointSet &rfiPlot = plot.StartLine("RFI"); RFIPlots::MakePowerTimePlot(rfiPlot, image, mask, MetaData()); } _plotManager->Update(); } }
void RFIGuiController::PlotTimeScatterComparison() { if(IsImageLoaded()) { MultiPlot plot(_plotManager->NewPlot2D("Time scatter comparison"), 8); RFIPlots::MakeScatterPlot(plot, OriginalData(), MetaData(), 0); RFIPlots::MakeScatterPlot(plot, ContaminatedData(), MetaData(), 4); plot.Finish(); _plotManager->Update(); } }
/** * CreateCacheEntry() * * Creates an nsCacheEntry and sets all fields except for the binding. */ nsCacheEntry * nsDiskCacheEntry::CreateCacheEntry(nsCacheDevice * device) { nsCacheEntry * entry = nsnull; nsresult rv = nsCacheEntry::Create(Key(), nsICache::STREAM_BASED, nsICache::STORE_ON_DISK, device, &entry); if (NS_FAILED(rv) || !entry) return nsnull; entry->SetFetchCount(mFetchCount); entry->SetLastFetched(mLastFetched); entry->SetLastModified(mLastModified); entry->SetExpirationTime(mExpirationTime); entry->SetCacheDevice(device); // XXX why does nsCacheService have to fill out device in BindEntry()? entry->SetDataSize(mDataSize); rv = entry->UnflattenMetaData(MetaData(), mMetaDataSize); if (NS_FAILED(rv)) { delete entry; return nsnull; } // Restore security info, if present const char* info = entry->GetMetaDataElement("security-info"); if (info) { nsCOMPtr<nsISupports> infoObj; NS_DeserializeObject(nsDependentCString(info), getter_AddRefs(infoObj)); entry->SetSecurityInfo(infoObj); } return entry; }
// Action_Angle::init() Action::RetType Action_Angle::Init(ArgList& actionArgs, TopologyList* PFL, DataSetList* DSL, DataFileList* DFL, int debugIn) { // Get keywords DataFile* outfile = DFL->AddDataFile( actionArgs.GetStringKey("out"), actionArgs ); useMass_ = actionArgs.hasKey("mass"); // Get Masks std::string mask1 = actionArgs.GetMaskNext(); std::string mask2 = actionArgs.GetMaskNext(); std::string mask3 = actionArgs.GetMaskNext(); if (mask1.empty() || mask2.empty() || mask3.empty()) { mprinterr("Error: angle: Requires 3 masks\n"); return Action::ERR; } Mask1_.SetMaskString(mask1); Mask2_.SetMaskString(mask2); Mask3_.SetMaskString(mask3); // Dataset to store angles ang_ = DSL->AddSet(DataSet::DOUBLE, MetaData(actionArgs.GetStringNext(),MetaData::M_ANGLE),"Ang"); if (ang_==0) return Action::ERR; // Add dataset to data file list if (outfile != 0) outfile->AddDataSet( ang_ ); mprintf(" ANGLE: [%s]-[%s]-[%s]\n",Mask1_.MaskString(), Mask2_.MaskString(), Mask3_.MaskString()); if (useMass_) mprintf("\tUsing center of mass of atoms in masks.\n"); return Action::OK; }
int Action_Esander::AddSet(Energy_Sander::Etype typeIn, DataSetList& DslIn, DataFile* outfile, std::string const& setname) { Esets_[typeIn] = DslIn.AddSet(DataSet::DOUBLE, MetaData(setname, Energy_Sander::Easpect(typeIn))); if (Esets_[typeIn] == 0) return 1; if (outfile != 0) outfile->AddDataSet( Esets_[typeIn] ); return 0; }
MetaData ObjMapObject::get_metadata() const { if (impl.get()) return impl->data; else return MetaData(); }
MetaData Layer::get_metadata() const { if (impl.get()) return impl->data; else return MetaData(); }
int Action_Energy::AddSet(Etype typeIn, DataSetList& DslIn, DataFile* outfile, std::string const& setname) { Energy_[typeIn] = DslIn.AddSet(DataSet::DOUBLE, MetaData(setname, Estring[typeIn])); if (Energy_[typeIn] == 0) return 1; if (outfile != 0) outfile->AddDataSet( Energy_[typeIn] ); return 0; }
// Action_VelocityAutoCorr::Init() Action::RetType Action_VelocityAutoCorr::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { if (actionArgs.hasKey("usevelocity")) { mprinterr("Error: The 'usevelocity' keyword is deprecated. Velocity information\n" "Error: is now used by default if present. To force cpptraj to use\n" "Error: coordinates to estimate velocities (not recommended) use the\n" "Error: 'usecoords' keyword.\n"); return Action::ERR; } useVelInfo_ = !actionArgs.hasKey("usecoords"); if (mask_.SetMaskString( actionArgs.GetMaskNext() )) return Action::ERR; DataFile* outfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs ); diffout_ = init.DFL().AddCpptrajFile( actionArgs.GetStringKey("diffout"), "VAC diffusion constants", DataFileList::TEXT, true ); maxLag_ = actionArgs.getKeyInt("maxlag", -1); tstep_ = actionArgs.getKeyDouble("tstep", 1.0); useFFT_ = !actionArgs.hasKey("direct"); normalize_ = actionArgs.hasKey("norm"); // Set up output data set VAC_ = init.DSL().AddSet(DataSet::DOUBLE, actionArgs.GetStringNext(), "VAC"); if (VAC_ == 0) return Action::ERR; // TODO: This should just be a scalar diffConst_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(VAC_->Meta().Name(), "D", MetaData::NOT_TS)); if (diffConst_ == 0) return Action::ERR; if (outfile != 0) outfile->AddDataSet( VAC_ ); # ifdef MPI trajComm_ = init.TrajComm(); if (trajComm_.Size() > 1 && !useVelInfo_) mprintf("\nWarning: When calculating velocities between consecutive frames,\n" "\nWarning: 'velocityautocorr' in parallel will not work correctly if\n" "\nWarning: coordinates have been modified by previous actions (e.g. 'rms').\n\n"); diffConst_->SetNeedsSync( false ); # endif mprintf(" VELOCITYAUTOCORR:\n" "\tCalculate velocity auto-correlation function for atoms in mask '%s'\n", mask_.MaskString()); if (useVelInfo_) mprintf("\tUsing velocity information present in frames.\n"); else mprintf("\tCalculating velocities between consecutive frames from coordinates.\n"); if (outfile != 0) mprintf("\tOutput velocity autocorrelation function '%s' to '%s'\n", VAC_->legend(), outfile->DataFilename().full()); mprintf("\tWriting diffusion constants to '%s'\n", diffout_->Filename().full()); if (maxLag_ < 1) mprintf("\tMaximum lag will be half total # of frames"); else mprintf("\tMaximum lag is %i frames", maxLag_); mprintf(", time step between frames is %f ps\n", tstep_); if (useFFT_) mprintf("\tUsing FFT to calculate autocorrelation function.\n"); else mprintf("\tUsing direct method to calculate autocorrelation function.\n"); if (normalize_) mprintf("\tNormalizing autocorrelation function to 1.0\n"); return Action::OK; }
void RFIGuiController::PlotTimeScatter() { if(IsImageLoaded()) { MultiPlot plot(_plotManager->NewPlot2D("Time scatter"), 4); RFIPlots::MakeScatterPlot(plot, ActiveData(), MetaData()); plot.Finish(); _plotManager->Update(); } }
// Action_Principal::Init() Action::RetType Action_Principal::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { debug_ = debugIn; // Keywords std::string dsname = actionArgs.GetStringKey("name"); doRotation_ = actionArgs.hasKey("dorotation"); // CPPTRAJ always uses mass no matter what this keyword says. useMass_ = actionArgs.hasKey("mass"); std::string filename = actionArgs.GetStringKey("out"); if (!doRotation_ && filename.empty() && dsname.empty()) { mprinterr("Error: At least one of 'dorotation', 'out <filename>', or 'name <dsname>' must be specified.\n"); return Action::ERR; } // Masks mask_.SetMaskString( actionArgs.GetMaskNext() ); // Set up data if (!dsname.empty()) { vecData_ = (DataSet_Mat3x3*)init.DSL().AddSet(DataSet::MAT3X3, MetaData(dsname, "evec")); valData_ = (DataSet_Vector*)init.DSL().AddSet(DataSet::VECTOR, MetaData(dsname, "eval")); if (vecData_ == 0 || valData_ == 0) return Action::ERR; } mprintf(" PRINCIPAL:"); if (!filename.empty()) { outfile_ = init.DFL().AddCpptrajFile(filename, "Eigenvectors/Eigenvalues"); if (outfile_ == 0) return Action::ERR; mprintf(" output eigenvectors/eigenvalues to %s,", outfile_->Filename().full()); } if (doRotation_) mprintf(" with rotation by"); else mprintf(" without rotation by"); if (useMass_) mprintf(" center of mass"); else mprintf(" center of geometry"); mprintf(", atoms selected by [%s]\n", mask_.MaskString()); if (vecData_ != 0) mprintf("\tSaving eigenvectors to '%s' (in rows of 3x3 matrices).\n" "\tSaving eigenvalues to '%s'\n", vecData_->legend(), valData_->legend()); return Action::OK; }
void RFIGuiController::PlotPowerSpectrumComparison() { if(IsImageLoaded()) { Plot2D &plot = _plotManager->NewPlot2D("Power spectrum comparison"); TimeFrequencyData data = OriginalData(); Image2DCPtr image = data.GetSingleImage(); Mask2DCPtr mask = data.GetSingleMask(); Plot2DPointSet &originalSet = plot.StartLine("Original"); RFIPlots::MakePowerSpectrumPlot(originalSet, image, mask, MetaData()); data = ContaminatedData(); image = data.GetSingleImage(); mask = data.GetSingleMask(); Plot2DPointSet &alternativeSet = plot.StartLine("Alternative"); RFIPlots::MakePowerSpectrumPlot(alternativeSet, image, mask, MetaData()); _plotManager->Update(); } }
/** For per-residue RMSD only. Setup output * file options. Calculate averages if requested. */ void Action_Rmsd::Print() { if (!perres_ || ResidueRMS_.empty()) return; // Per-residue output file if (perresout_ != 0) { // Set output file to be inverted if requested if (perresinvert_) perresout_->ProcessArgs("invert"); mprintf(" RMSD: Per-residue: Writing data for %zu residues to %s\n", ResidueRMS_.size(), perresout_->DataFilename().full()); } // Average if (perresavg_ != 0) { // Use the per residue rmsd dataset list to add one more for averaging DataSet_Mesh* PerResAvg = (DataSet_Mesh*)masterDSL_->AddSet(DataSet::XYMESH, MetaData(rmsd_->Meta().Name(), "Avg")); PerResAvg->ModifyDim(Dimension::X).SetLabel("Residue"); // another for stdev DataSet_Mesh* PerResStdev = (DataSet_Mesh*)masterDSL_->AddSet(DataSet::XYMESH, MetaData(rmsd_->Meta().Name(), "Stdev")); PerResStdev->ModifyDim(Dimension::X).SetLabel("Residue"); // Add the average and stdev datasets to the master datafile list perresavg_->AddDataSet(PerResAvg); perresavg_->AddDataSet(PerResStdev); // For each residue, get the average rmsd double stdev = 0; double avg = 0; for (perResArray::const_iterator PerRes = ResidueRMS_.begin(); PerRes != ResidueRMS_.end(); ++PerRes) { avg = PerRes->data_->Avg( stdev ); double pridx = (double)PerRes->data_->Meta().Idx(); PerResAvg->AddXY(pridx, avg); PerResStdev->AddXY(pridx, stdev); } } }
// Analysis_Hist::Setup() Analysis::RetType Analysis_Hist::ExternalSetup(DataSet_1D* dsIn, std::string const& histname, int setidx, std::string const& outfilenameIn, bool minArgSetIn, double minIn, bool maxArgSetIn, double maxIn, double stepIn, int binsIn, double tempIn, NormMode normIn, DataSetList& datasetlist, DataFileList& DFLin) { debug_ = 0; if (dsIn == 0) return Analysis::ERR; outfilename_ = outfilenameIn; outfile_ = DFLin.AddDataFile(outfilename_); Temp_ = tempIn; if (Temp_ != -1.0) calcFreeE_ = true; else calcFreeE_ = false; gnuplot_ = false; normalize_ = normIn; circular_ = false; nativeOut_ = false; minArgSet_ = minArgSetIn; if (minArgSet_) default_min_ = minIn; maxArgSet_ = maxArgSetIn; if (maxArgSet_) default_max_ = maxIn; default_step_ = stepIn; default_bins_ = binsIn; calcAMD_ = false; amddata_ = 0; dimensionArgs_.push_back( ArgList(dsIn->Meta().Legend()) ); // Needed for dim label histdata_.push_back( dsIn ); N_dimensions_ = 1; std::string setname = histname; std::string htype; if (calcFreeE_) htype = "FreeE_"; else htype = "Hist_"; if (setname.empty()) setname = datasetlist.GenerateDefaultName(htype + dsIn->Meta().Name()); hist_ = datasetlist.AddSet( DataSet::DOUBLE, MetaData(setname, dsIn->Meta().Aspect(), setidx) ); if (hist_ == 0) return Analysis::ERR; hist_->SetLegend(htype + dsIn->Meta().Legend()); if (outfile_ != 0) outfile_->AddDataSet( hist_ ); return Analysis::OK; }
void RFIGuiController::PlotPowerSpectrum() { if(IsImageLoaded()) { Plot2D &plot = _plotManager->NewPlot2D("Power spectrum"); plot.SetLogarithmicYAxis(true); TimeFrequencyData data = ActiveData(); Image2DCPtr image = data.GetSingleImage(); Mask2DPtr mask = Mask2D::CreateSetMaskPtr<false>(image->Width(), image->Height()); Plot2DPointSet &beforeSet = plot.StartLine("Before"); RFIPlots::MakePowerSpectrumPlot(beforeSet, image, mask, MetaData()); mask = Mask2D::CreateCopy(data.GetSingleMask()); if(!mask->AllFalse()) { Plot2DPointSet &afterSet = plot.StartLine("After"); RFIPlots::MakePowerSpectrumPlot(afterSet, image, mask, MetaData()); } _plotManager->Update(); } }
// Action_Distance::Init() Action::RetType Action_Distance::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { AssociatedData_NOE noe; // Get Keywords image_.InitImaging( !(actionArgs.hasKey("noimage")) ); useMass_ = !(actionArgs.hasKey("geom")); DataFile* outfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs ); MetaData::scalarType stype = MetaData::UNDEFINED; std::string stypename = actionArgs.GetStringKey("type"); if ( stypename == "noe" ) { stype = MetaData::NOE; if (noe.NOE_Args( actionArgs )) return Action::ERR; } // Get Masks std::string mask1 = actionArgs.GetMaskNext(); std::string mask2 = actionArgs.GetMaskNext(); if (mask1.empty() || mask2.empty()) { mprinterr("Error: distance requires 2 masks\n"); return Action::ERR; } Mask1_.SetMaskString(mask1); Mask2_.SetMaskString(mask2); // Dataset to store distances TODO store masks in data set? dist_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(actionArgs.GetStringNext(), MetaData::M_DISTANCE, stype), "Dis"); if (dist_==0) return Action::ERR; if ( stype == MetaData::NOE ) { dist_->AssociateData( &noe ); dist_->SetLegend(Mask1_.MaskExpression() + " and " + Mask2_.MaskExpression()); } // Add dataset to data file if (outfile != 0) outfile->AddDataSet( dist_ ); mprintf(" DISTANCE: %s to %s",Mask1_.MaskString(), Mask2_.MaskString()); if (!image_.UseImage()) mprintf(", non-imaged"); if (useMass_) mprintf(", center of mass"); else mprintf(", geometric center"); mprintf(".\n"); return Action::OK; }
void RFIGuiController::OpenTestSet(unsigned index, bool gaussianTestSets) { unsigned width = 1024*16, height = 1024; if(IsImageLoaded()) { TimeFrequencyData activeData = ActiveData(); width = activeData.ImageWidth(); height = activeData.ImageHeight(); } Mask2DPtr rfi = Mask2D::CreateSetMaskPtr<false>(width, height); Image2DPtr testSetReal(MitigationTester::CreateTestSet(index, rfi, width, height, gaussianTestSets)); Image2DPtr testSetImaginary(MitigationTester::CreateTestSet(2, rfi, width, height, gaussianTestSets)); TimeFrequencyData data(SinglePolarisation, testSetReal, testSetImaginary); data.SetGlobalMask(rfi); _rfiGuiWindow.GetTimeFrequencyWidget().SetNewData(data, MetaData()); _rfiGuiWindow.GetTimeFrequencyWidget().Update(); }
void cAnalyzer::Action() { cThreadLock threadLock(this); if (access(path.path.c_str(), R_OK) != 0) return; cFields field; cRow props; bool ok = MetaData(path.path.c_str(), field, props); // XXX metadata extraction failed... what to do ? if (true || ok) { std::string where = "path=\"" + path.path + "\""; writer->Update(METADATA_TABLE, field, props, where); } }
Analysis::RetType Analysis_KDE::ExternalSetup(DataSet_1D* dsIn, std::string const& histname, int setidx, std::string const& outfilenameIn, bool minArgSetIn, double minIn, bool maxArgSetIn, double maxIn, double stepIn, int binsIn, double tempIn, DataSetList& datasetlist, DataFileList& DFLin) { if (dsIn == 0) return Analysis::ERR; data_ = dsIn; q_data_ = 0; kldiv_ = 0; amddata_ = 0; bandwidth_ = -1.0; minArgSet_ = minArgSetIn; if (minArgSet_) default_min_ = minIn; maxArgSet_ = maxArgSetIn; if (maxArgSet_) default_max_ = maxIn; default_step_ = stepIn; default_bins_ = binsIn; Temp_ = tempIn; if (Temp_ != -1.0) calcFreeE_ = true; else calcFreeE_ = false; std::string setname = histname; std::string htype; if (calcFreeE_) htype = "FreeE_"; else htype = "KDE_"; if (setname.empty()) setname = datasetlist.GenerateDefaultName(htype + dsIn->Meta().Name()); DataFile* outfile = DFLin.AddDataFile( outfilenameIn ); output_ = datasetlist.AddSet(DataSet::DOUBLE, MetaData(setname, dsIn->Meta().Aspect(), setidx)); if (output_ == 0) return Analysis::ERR; output_->SetLegend(htype + dsIn->Meta().Legend()); if (outfile != 0) outfile->AddDataSet( output_ ); return Analysis::OK; }
// Analysis_FFT::Setup() Analysis::RetType Analysis_FFT::Setup(ArgList& analyzeArgs, DataSetList* datasetlist, DataFileList* DFLin, int debugIn) { std::string setname = analyzeArgs.GetStringKey("name"); DataFile* outfile = DFLin->AddDataFile(analyzeArgs.GetStringKey("out"), analyzeArgs); dt_ = analyzeArgs.getKeyDouble("dt",1.0); // Select datasets from remaining args if (input_dsets_.AddSetsFromArgs( analyzeArgs.RemainingArgs(), *datasetlist )) { mprinterr("Error: Could not add data sets.\n"); return Analysis::ERR; } if (input_dsets_.empty()) { mprinterr("Error: No input data sets.\n"); return Analysis::ERR; } // If setname is empty generate a default name if (setname.empty()) setname = datasetlist->GenerateDefaultName( "FFT" ); // Setup output datasets. int idx = 0; if ( input_dsets_.size() == 1 ) idx = -1; // Only one input set, no need to refer to it by index for ( Array1D::const_iterator DS = input_dsets_.begin(); DS != input_dsets_.end(); ++DS) { DataSet* dsout = datasetlist->AddSet( DataSet::DOUBLE, MetaData(setname, idx++) ); if (dsout==0) return Analysis::ERR; dsout->SetLegend( (*DS)->Meta().Legend() ); output_dsets_.push_back( (DataSet_1D*)dsout ); if (outfile != 0) outfile->AddDataSet( dsout ); } mprintf(" FFT: Calculating FFT for %u data sets.\n", input_dsets_.size()); mprintf("\tTime step: %f\n", dt_); if ( !setname.empty() ) mprintf("\tSet name: %s\n", setname.c_str() ); if ( outfile != 0 ) mprintf("\tOutfile name: %s\n", outfile->DataFilename().base()); return Analysis::OK; }
// Analysis_Timecorr::Setup() Analysis::RetType Analysis_Timecorr::Setup(ArgList& analyzeArgs, DataSetList* DSLin, TopologyList* PFLin, DataFileList* DFLin, int debugIn) { // Get Vectors std::string vec1name = analyzeArgs.GetStringKey("vec1"); if (vec1name.empty()) { mprinterr("Error: no vec1 given, ignoring command\n"); return Analysis::ERR; } vinfo1_ = (DataSet_Vector*)DSLin->FindSetOfType( vec1name, DataSet::VECTOR ); if (vinfo1_==0) { mprinterr("Error: vec1: no vector with name %s found.\n", vec1name.c_str()); return Analysis::ERR; } std::string vec2name = analyzeArgs.GetStringKey("vec2"); if (!vec2name.empty()) { vinfo2_ = (DataSet_Vector*)DSLin->FindSetOfType( vec2name, DataSet::VECTOR ); if (vinfo2_==0) { mprinterr("Error: vec2: no vector with name %s found.\n", vec2name.c_str()); return Analysis::ERR; } } else vinfo2_ = 0; // Get output DataSet name std::string setname = analyzeArgs.GetStringKey("name"); if (setname.empty()) setname = DSLin->GenerateDefaultName("TC"); // Determine auto or cross correlation if (vinfo2_ == 0) mode_ = AUTOCORR; else mode_ = CROSSCORR; // Get dplr, norm, drct dplr_ = analyzeArgs.hasKey("dplr"); norm_ = analyzeArgs.hasKey("norm"); drct_ = analyzeArgs.hasKey("drct"); std::string dplrname = analyzeArgs.GetStringKey("dplrout"); // Get order for Legendre polynomial, tstep, and tcorr order_ = analyzeArgs.getKeyInt("order",2); if (order_ < 0 || order_ > 2) { mprintf("Warning: vector order out of bounds (should be 0, 1, or 2), resetting to 2.\n"); order_ = 2; } tstep_ = analyzeArgs.getKeyDouble("tstep", 1.0); tcorr_ = analyzeArgs.getKeyDouble("tcorr", 10000.0); // File output. For ptrajformat, time correlation functions and dipolar // are output to file specified by 'out'. Otherwise time correlation // functions are written to file specified by 'out' using DataFile // framework and dipolar output to 'dplrname'. ptrajformat_ = analyzeArgs.hasKey("ptrajformat"); std::string filename = analyzeArgs.GetStringKey("out"); if (ptrajformat_ && filename.empty()) { mprinterr("Error: No output file name given ('out <filename>'). Required for 'ptrajformat'.\n"); return Analysis::ERR; } DataFile* dataout = 0; if (!ptrajformat_) { dataout = DFLin->AddDataFile( filename, analyzeArgs ); if (dplr_) { if (!dplrname.empty() && dplrname == filename) { mprinterr("Error: 'dplrname' cannot be the same file as 'out' when 'ptrajformat' not specified.\n"); return Analysis::ERR; } outfile_ = DFLin->AddCpptrajFile( dplrname, "Timecorr dipolar", DataFileList::TEXT, true ); if (outfile_ == 0) return Analysis::ERR; } } else { outfile_ = DFLin->AddCpptrajFile( filename, "Timecorr output" ); if (outfile_ == 0) return Analysis::ERR; } // Set up output DataSets tc_p_ = DSLin->AddSet( DataSet::DOUBLE, MetaData(setname, "P")); if (tc_p_ == 0) return Analysis::ERR; tc_p_->SetLegend( Plegend_[order_] ); if (dataout != 0) dataout->AddDataSet( tc_p_ ); if (dplr_) { tc_c_ = DSLin->AddSet( DataSet::DOUBLE, MetaData(setname, "C")); tc_r3r3_ = DSLin->AddSet( DataSet::DOUBLE, MetaData(setname, "R3R3")); if (tc_c_ == 0 || tc_r3r3_ == 0) return Analysis::ERR; tc_c_->SetLegend("<C>"); tc_r3r3_->SetLegend( "<1/(r^3*r^3)>" ); if (dataout != 0) { dataout->AddDataSet( tc_c_ ); dataout->AddDataSet( tc_r3r3_ ); } } // Print Status mprintf(" TIMECORR: Calculating %s", ModeString[mode_]); if (mode_ == AUTOCORR) mprintf(" of vector %s\n", vinfo1_->legend()); else // CROSSCORR mprintf(" of vectors %s and %s\n", vinfo1_->legend(), vinfo2_->legend()); mprintf("\tCorrelation time %f, time step %f, order %i\n", tcorr_, tstep_, order_); mprintf("\tCorr. func. are"); if (dplr_) mprintf(" for dipolar interactions and"); if (norm_) mprintf(" normalized.\n"); else mprintf(" not normalized.\n"); mprintf("\tCorr. func. are calculated using the"); if (drct_) mprintf(" direct approach.\n"); else mprintf(" FFT approach.\n"); if (ptrajformat_) mprintf("\tResults are written to %s\n", outfile_->Filename().full()); else { if (dataout != 0) mprintf("\tTime correlation functions written to %s\n", dataout->DataFilename().full()); if (outfile_ != 0) mprintf("\tDipolar results written to %s\n", outfile_->Filename().full()); } return Analysis::OK; }
// Action_Radial::Init() Action::RetType Action_Radial::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { debug_ = debugIn; // Get Keywords image_.InitImaging( !(actionArgs.hasKey("noimage")) ); std::string outfilename = actionArgs.GetStringKey("out"); // Default particle density (mols/Ang^3) for water based on 1.0 g/mL density_ = actionArgs.getKeyDouble("density",0.033456); if (actionArgs.hasKey("center1")) rmode_ = CENTER1; else if (actionArgs.hasKey("center2")) rmode_ = CENTER2; else if (actionArgs.hasKey("nointramol")) rmode_ = NO_INTRAMOL; else rmode_ = NORMAL; useVolume_ = actionArgs.hasKey("volume"); DataFile* intrdfFile = init.DFL().AddDataFile(actionArgs.GetStringKey("intrdf")); DataFile* rawrdfFile = init.DFL().AddDataFile(actionArgs.GetStringKey("rawrdf")); spacing_ = actionArgs.getNextDouble(-1.0); if (spacing_ < 0) { mprinterr("Error: Radial: No spacing argument or arg < 0.\n"); Help(); return Action::ERR; } double maximum = actionArgs.getNextDouble(-1.0); if (maximum < 0) { mprinterr("Error: Radial: No maximum argument or arg < 0.\n"); Help(); return Action::ERR; } // Store max^2, distances^2 greater than max^2 do not need to be // binned and therefore do not need a sqrt calc. maximum2_ = maximum * maximum; // Get First Mask std::string mask1 = actionArgs.GetMaskNext(); if (mask1.empty()) { mprinterr("Error: Radial: No mask given.\n"); return Action::ERR; } Mask1_.SetMaskString(mask1); // Check for second mask - if none specified use first mask std::string mask2 = actionArgs.GetMaskNext(); if (!mask2.empty()) Mask2_.SetMaskString(mask2); else Mask2_.SetMaskString(mask1); // If filename not yet specified check for backwards compat. if (outfilename.empty() && actionArgs.Nargs() > 1 && !actionArgs.Marked(1)) outfilename = actionArgs.GetStringNext(); // Set up output dataset. Dset_ = init.DSL().AddSet( DataSet::DOUBLE, actionArgs.GetStringNext(), "g(r)"); if (Dset_ == 0) return RDF_ERR("Could not allocate RDF data set."); DataFile* outfile = init.DFL().AddDataFile(outfilename, actionArgs); if (outfile != 0) outfile->AddDataSet( Dset_ ); // Make default precision a little higher than normal Dset_->SetupFormat().SetFormatWidthPrecision(12,6); // Set DataSet legend from mask strings. Dset_->SetLegend(Mask1_.MaskExpression() + " => " + Mask2_.MaskExpression()); // TODO: Set Yaxis label in DataFile // Calculate number of bins one_over_spacing_ = 1 / spacing_; double temp_numbins = maximum * one_over_spacing_; temp_numbins = ceil(temp_numbins); numBins_ = (int) temp_numbins; // Setup output datafile. Align on bin centers instead of left. // TODO: Use Rdim for binning? Dimension Rdim( spacing_ / 2.0, spacing_, "Distance (Ang)" ); Dset_->SetDim(Dimension::X, Rdim); // Set up output for integral of mask2 if specified. if (intrdfFile != 0) { intrdf_ = init.DSL().AddSet( DataSet::DOUBLE, MetaData(Dset_->Meta().Name(), "int" )); if (intrdf_ == 0) return RDF_ERR("Could not allocate RDF integral data set."); intrdf_->SetupFormat().SetFormatWidthPrecision(12,6); intrdf_->SetLegend("Int[" + Mask2_.MaskExpression() + "]"); intrdf_->SetDim(Dimension::X, Rdim); intrdfFile->AddDataSet( intrdf_ ); } else intrdf_ = 0; // Set up output for raw rdf if (rawrdfFile != 0) { rawrdf_ = init.DSL().AddSet( DataSet::DOUBLE, MetaData(Dset_->Meta().Name(), "raw" )); if (rawrdf_ == 0) return RDF_ERR("Could not allocate raw RDF data set."); rawrdf_->SetupFormat().SetFormatWidthPrecision(12,6); rawrdf_->SetLegend("Raw[" + Dset_->Meta().Legend() + "]"); rawrdf_->SetDim(Dimension::X, Rdim); rawrdfFile->AddDataSet( rawrdf_ ); } else rawrdf_ = 0; // Set up histogram RDF_ = new int[ numBins_ ]; std::fill(RDF_, RDF_ + numBins_, 0); # ifdef _OPENMP // Since RDF is shared by all threads and we cant guarantee that a given // bin in RDF wont be accessed at the same time by the same thread, // each thread needs its own bin space. #pragma omp parallel { if (omp_get_thread_num()==0) numthreads_ = omp_get_num_threads(); } rdf_thread_ = new int*[ numthreads_ ]; for (int i=0; i < numthreads_; i++) { rdf_thread_[i] = new int[ numBins_ ]; std::fill(rdf_thread_[i], rdf_thread_[i] + numBins_, 0); } # endif mprintf(" RADIAL: Calculating RDF for atoms in mask [%s]",Mask1_.MaskString()); if (!mask2.empty()) mprintf(" to atoms in mask [%s]",Mask2_.MaskString()); mprintf("\n"); if (outfile != 0) mprintf(" Output to %s.\n", outfile->DataFilename().full()); if (intrdf_ != 0) mprintf(" Integral of mask2 atoms will be output to %s\n", intrdfFile->DataFilename().full()); if (rawrdf_ != 0) mprintf(" Raw RDF bin values will be output to %s\n", rawrdfFile->DataFilename().full()); if (rmode_==CENTER1) mprintf(" Using center of atoms in mask1.\n"); else if (rmode_==CENTER2) mprintf(" Using center of atoms in mask2.\n"); mprintf(" Histogram max %f, spacing %f, bins %i.\n",maximum, spacing_,numBins_); if (useVolume_) mprintf(" Normalizing based on cell volume.\n"); else mprintf(" Normalizing using particle density of %f molecules/Ang^3.\n",density_); if (!image_.UseImage()) mprintf(" Imaging disabled.\n"); if (numthreads_ > 1) mprintf(" Parallelizing RDF calculation with %i threads.\n",numthreads_); return Action::OK; }
static MetaData create(Args&&... args) { ManagedObjectPtr object = ManagedObject<T>::make_unique(std::forward<Args>(args)...); return MetaData(std::move(object), object->getHandle()); }
Action::RetType Action_DNAionTracker::Init(ArgList& actionArgs, TopologyList* PFL, DataSetList* DSL, DataFileList* DFL, int debugIn) { // Get keywords DataFile* outfile = DFL->AddDataFile(actionArgs.GetStringKey("out"), actionArgs); poffset_ = actionArgs.getKeyDouble("poffset", 5.0); InitImaging( !actionArgs.hasKey("noimage") ); if (actionArgs.hasKey("shortest")) bintype_ = SHORTEST; else if (actionArgs.hasKey("counttopcone")) bintype_ = TOPCONE; else if (actionArgs.hasKey("countbottomcone")) bintype_ = BOTTOMCONE; else if (actionArgs.hasKey("count")) bintype_ = COUNT; // Get masks - 4 must be specified std::string m1 = actionArgs.GetMaskNext(); std::string m2 = actionArgs.GetMaskNext(); std::string m3 = actionArgs.GetMaskNext(); std::string m4 = actionArgs.GetMaskNext(); if (m1.empty() || m2.empty() || m3.empty() || m4.empty()) { mprinterr("Error: dnaiontracker requires 4 masks.\n"); return Action::ERR; } p1_.SetMaskString(m1); p2_.SetMaskString(m2); base_.SetMaskString(m3); ions_.SetMaskString(m4); // Add dataset to dataset list (and datafile list if filename specified) distance_ = DSL->AddSet(DataSet::DOUBLE, MetaData(actionArgs.GetStringNext(), MetaData::M_DISTANCE), "DNAion"); if (distance_==0) return Action::ERR; if (outfile != 0) outfile->AddDataSet( distance_ ); // INFO mprintf(" DNAIONTRACKER: Data representing the "); switch (bintype_) { case COUNT : mprintf("count within the cone will be\n"); break; case SHORTEST: mprintf("shortest distance to a phosphate or base centroid will be\n"); break; case TOPCONE: mprintf("count in the top half of the cone (and sort-of bound) will be\n"); break; case BOTTOMCONE: mprintf("count in the bottom half of the cone will be\n"); break; } mprintf(" saved to array named %s\n", distance_->legend()); mprintf(" Perpendicular offset for cone is %5.2f angstroms\n", poffset_); if (!UseImage()) mprintf(" Imaging has been disabled\n"); mprintf("\tPhosphate1 Mask [%s]\n", p1_.MaskString()); mprintf("\tPhosphate2 Mask [%s]\n", p2_.MaskString()); mprintf("\tBase Mask [%s]\n", base_.MaskString()); mprintf("\tIons Mask [%s]\n", ions_.MaskString()); if (outfile != 0) mprintf("\tData will be printed to a file named %s\n", outfile->DataFilename().full()); return Action::OK; }
static tCLIFile* LoadPEFile(void *pData) { tCLIFile *pRet = TMALLOC(tCLIFile); unsigned char *pMSDOSHeader = (unsigned char*)&(((unsigned char*)pData)[0]); unsigned char *pPEHeader; unsigned char *pPEOptionalHeader; unsigned char *pPESectionHeaders; unsigned char *pCLIHeader; unsigned char *pRawMetaData; int i; unsigned int lfanew; unsigned short machine; int numSections; unsigned int imageBase; int fileAlignment; unsigned int cliHeaderRVA, cliHeaderSize; unsigned int metaDataRVA, metaDataSize; tMetaData *pMetaData; pRet->pRVA = RVA(); pRet->pMetaData = pMetaData = MetaData(); lfanew = *(unsigned int*)&(pMSDOSHeader[0x3c]); pPEHeader = pMSDOSHeader + lfanew + 4; pPEOptionalHeader = pPEHeader + 20; pPESectionHeaders = pPEOptionalHeader + 224; machine = *(unsigned short*)&(pPEHeader[0]); if (machine != DOT_NET_MACHINE) { return NULL; } numSections = *(unsigned short*)&(pPEHeader[2]); imageBase = *(unsigned int*)&(pPEOptionalHeader[28]); fileAlignment = *(int*)&(pPEOptionalHeader[36]); for (i=0; i<numSections; i++) { unsigned char *pSection = pPESectionHeaders + i * 40; RVA_Create(pRet->pRVA, pData, pSection); } cliHeaderRVA = *(unsigned int*)&(pPEOptionalHeader[208]); cliHeaderSize = *(unsigned int*)&(pPEOptionalHeader[212]); pCLIHeader = RVA_FindData(pRet->pRVA, cliHeaderRVA); metaDataRVA = *(unsigned int*)&(pCLIHeader[8]); metaDataSize = *(unsigned int*)&(pCLIHeader[12]); pRet->entryPoint = *(unsigned int*)&(pCLIHeader[20]); pRawMetaData = RVA_FindData(pRet->pRVA, metaDataRVA); // Load all metadata { unsigned int versionLen = *(unsigned int*)&(pRawMetaData[12]); unsigned int ofs, numberOfStreams; void *pTableStream = NULL; unsigned int tableStreamSize; pRet->pVersion = &(pRawMetaData[16]); log_f(1, "CLI version: %s\n", pRet->pVersion); ofs = 16 + versionLen; numberOfStreams = *(unsigned short*)&(pRawMetaData[ofs + 2]); ofs += 4; for (i=0; i<(signed)numberOfStreams; i++) { unsigned int streamOffset = *(unsigned int*)&pRawMetaData[ofs]; unsigned int streamSize = *(unsigned int*)&pRawMetaData[ofs+4]; unsigned char *pStreamName = &pRawMetaData[ofs+8]; void *pStream = pRawMetaData + streamOffset; ofs += (unsigned int)((strlen(pStreamName)+4) & (~0x3)) + 8; if (strcasecmp(pStreamName, "#Strings") == 0) { MetaData_LoadStrings(pMetaData, pStream, streamSize); } else if (strcasecmp(pStreamName, "#US") == 0) { MetaData_LoadUserStrings(pMetaData, pStream, streamSize); } else if (strcasecmp(pStreamName, "#Blob") == 0) { MetaData_LoadBlobs(pMetaData, pStream, streamSize); } else if (strcasecmp(pStreamName, "#GUID") == 0) { MetaData_LoadGUIDs(pMetaData, pStream, streamSize); } else if (strcasecmp(pStreamName, "#~") == 0) { pTableStream = pStream; tableStreamSize = streamSize; } } // Must load tables last if (pTableStream != NULL) { MetaData_LoadTables(pMetaData, pRet->pRVA, pTableStream, tableStreamSize); } } // Mark all generic definition types and methods as such for (i=pMetaData->tables.numRows[MD_TABLE_GENERICPARAM]; i>0; i--) { tMD_GenericParam *pGenericParam; IDX_TABLE ownerIdx; pGenericParam = (tMD_GenericParam*)MetaData_GetTableRow (pMetaData, MAKE_TABLE_INDEX(MD_TABLE_GENERICPARAM, i)); ownerIdx = pGenericParam->owner; switch (TABLE_ID(ownerIdx)) { case MD_TABLE_TYPEDEF: { tMD_TypeDef *pTypeDef = (tMD_TypeDef*)MetaData_GetTableRow(pMetaData, ownerIdx); pTypeDef->isGenericDefinition = 1; } break; case MD_TABLE_METHODDEF: { tMD_MethodDef *pMethodDef = (tMD_MethodDef*)MetaData_GetTableRow(pMetaData, ownerIdx); pMethodDef->isGenericDefinition = 1; } break; default: Crash("Wrong generic parameter owner: 0x%08x", ownerIdx); } } // Mark all nested classes as such for (i=pMetaData->tables.numRows[MD_TABLE_NESTEDCLASS]; i>0; i--) { tMD_NestedClass *pNested; tMD_TypeDef *pParent, *pChild; pNested = (tMD_NestedClass*)MetaData_GetTableRow(pMetaData, MAKE_TABLE_INDEX(MD_TABLE_NESTEDCLASS, i)); pParent = (tMD_TypeDef*)MetaData_GetTableRow(pMetaData, pNested->enclosingClass); pChild = (tMD_TypeDef*)MetaData_GetTableRow(pMetaData, pNested->nestedClass); pChild->pNestedIn = pParent; } return pRet; }
/** Determine what atoms each mask pertains to for the current parm file. */ Action::RetType Action_NMRrst::Setup(ActionSetup& setup) { if (!viewrst_.empty() && rsttop_ == 0) rsttop_ = setup.TopAddress(); // --------------------------------------------- // Set up NOEs from file. for (noeDataArray::iterator noe = NOEs_.begin(); noe != NOEs_.end(); ++noe) { if (setup.Top().SetupIntegerMask( noe->dMask1_ )) return Action::ERR; if (setup.Top().SetupIntegerMask( noe->dMask2_ )) return Action::ERR; if (noe->dMask1_.None() || noe->dMask2_.None()) { mprintf("Warning: One or both masks for NOE '%s' have no atoms (%i and %i).\n", noe->dist_->legend(), noe->dMask1_.Nselected(), noe->dMask2_.Nselected()); noe->active_ = false; } else noe->active_ = true; } // --------------------------------------------- // Set up potential NOE sites. if (findNOEs_) { if (setup.Top().SetupCharMask( Mask_ )) return Action::ERR; Mask_.MaskInfo(); if (Mask_.None()) return Action::SKIP; SiteArray potentialSites; // .clear(); AtomMap resMap; resMap.SetDebug( debug_ ); std::vector<bool> selected; Range soluteRes = setup.Top().SoluteResidues(); for (Range::const_iterator res = soluteRes.begin(); res != soluteRes.end(); ++res) { int res_first_atom = setup.Top().Res(*res).FirstAtom(); selected.assign( setup.Top().Res(*res).NumAtoms(), false ); // Find symmetric atom groups. AtomMap::AtomIndexArray symmGroups; if (resMap.SymmetricAtoms(setup.Top(), symmGroups, *res)) return Action::ERR; // DEBUG if (debug_ > 0) { mprintf("DEBUG: Residue %i: symmetric atom groups:\n", *res + 1); for (AtomMap::AtomIndexArray::const_iterator grp = symmGroups.begin(); grp != symmGroups.end(); ++grp) { mprintf("\t\t"); for (AtomMap::Iarray::const_iterator at = grp->begin(); at != grp->end(); ++at) mprintf(" %s", setup.Top().TruncAtomNameNum( *at ).c_str()); mprintf("\n"); } } // Each symmetric hydrogen atom group is a site. for (AtomMap::AtomIndexArray::const_iterator grp = symmGroups.begin(); grp != symmGroups.end(); ++grp) { // NOTE: If first atom is H all should be H. if ( setup.Top()[ grp->front() ].Element() == Atom::HYDROGEN ) { Iarray symmAtomGroup; for (Iarray::const_iterator at = grp->begin(); at != grp->end(); ++at) if (Mask_.AtomInCharMask( *at )) symmAtomGroup.push_back( *at ); if (!symmAtomGroup.empty()) { potentialSites.push_back( Site(*res, symmAtomGroup) ); // Mark symmetric atoms as selected. for (AtomMap::Iarray::const_iterator at = grp->begin(); at != grp->end(); ++at) selected[ *at - res_first_atom ] = true; } } } // All other non-selected hydrogens bonded to same heavy atom are sites. for (int ratom = res_first_atom; ratom != setup.Top().Res(*res).LastAtom(); ++ratom) { if ( setup.Top()[ratom].Element() != Atom::HYDROGEN ) { Iarray heavyAtomGroup; for (Atom::bond_iterator ba = setup.Top()[ratom].bondbegin(); ba != setup.Top()[ratom].bondend(); ++ba) if ( Mask_.AtomInCharMask(*ba) && *ba >= res_first_atom && *ba < setup.Top().Res(*res).LastAtom() ) { if ( !selected[ *ba - res_first_atom ] && setup.Top()[ *ba ].Element() == Atom::HYDROGEN ) heavyAtomGroup.push_back( *ba ); } if (!heavyAtomGroup.empty()) potentialSites.push_back( Site(*res, heavyAtomGroup) ); } } } mprintf("\t%zu potential NOE sites:\n", potentialSites.size()); for (SiteArray::const_iterator site = potentialSites.begin(); site != potentialSites.end(); ++site) { mprintf(" %u\tRes %i:", site - potentialSites.begin(), site->ResNum()+1); for (unsigned int idx = 0; idx != site->Nindices(); ++idx) mprintf(" %s", setup.Top().TruncAtomNameNum( site->Idx(idx) ).c_str()); mprintf("\n"); } if (noeArray_.empty()) { size_t siteArraySize = 0; // Set up all potential NOE pairs. Keep track of size. for (SiteArray::const_iterator site1 = potentialSites.begin(); site1 != potentialSites.end(); ++site1) { for (SiteArray::const_iterator site2 = site1 + 1; site2 != potentialSites.end(); ++site2) { if (site1->ResNum() != site2->ResNum()) { std::string legend = site1->SiteLegend(setup.Top()) + "--" + site2->SiteLegend(setup.Top()); DataSet* ds = 0; if (series_) { ds = masterDSL_->AddSet(DataSet::FLOAT, MetaData(setname_, "foundNOE", noeArray_.size())); if (ds == 0) return Action::ERR; // Construct a data set name. ds->SetLegend(legend); } noeArray_.push_back( NOEtype(*site1, *site2, ds, legend) ); siteArraySize += (2 * sizeof(int) * site1->Nindices()) + (2 * sizeof(int) * site2->Nindices()); } } } numNoePairs_ = noeArray_.size(); size_t siteSize = sizeof(int) + (2 * sizeof(Iarray)) + sizeof(Site); size_t noeSize = (2 * siteSize) + sizeof(DataSet*) + sizeof(double) + sizeof(NOEtype); if (series_) noeSize += sizeof(std::vector<float>); size_t noeArraySize = (noeSize * numNoePairs_) + siteArraySize; if (series_) noeArraySize += (setup.Nframes() * numNoePairs_ * sizeof(float)); mprintf("\t%zu potential NOE pairs. Estimated memory usage is %s\n", numNoePairs_, ByteString(noeArraySize, BYTE_DECIMAL).c_str()); } else if (numNoePairs_ != potentialSites.size()) { mprinterr("Warning: Found NOE matrix has already been set up for %zu potential\n" "Warning: NOEs, but %zu NOEs currently found.\n", numNoePairs_, potentialSites.size()); return Action::SKIP; } } // --------------------------------------------- // Set up NOEs specified on the command line if (!Pairs_.empty()) { if (!specifiedNOEs_.empty()) { mprintf("Warning: Specifying NOEs currently only works with first topology used.\n"); return Action::SKIP; } for (MaskPairArray::iterator mp = Pairs_.begin(); mp != Pairs_.end(); mp++) { if (setup.Top().SetupIntegerMask( mp->first )) return Action::ERR; int res1 = CheckSameResidue(setup.Top(), mp->first); if (res1 < 0) continue; if (setup.Top().SetupIntegerMask( mp->second )) return Action::ERR; int res2 = CheckSameResidue(setup.Top(), mp->second); if (res2 < 0) continue; Site site1( res1, mp->first.Selected() ); Site site2( res2, mp->second.Selected() ); std::string legend = site1.SiteLegend(setup.Top()) + "--" + site2.SiteLegend(setup.Top()); DataSet* ds = 0; if (series_) { ds = masterDSL_->AddSet(DataSet::FLOAT, MetaData(setname_, "specNOE", specifiedNOEs_.size())); if (ds == 0) return Action::ERR; ds->SetLegend(legend); } specifiedNOEs_.push_back( NOEtype(site1, site2, ds, legend) ); } } // Set up imaging info for this parm Image_.SetupImaging( setup.CoordInfo().TrajBox().Type() ); if (Image_.ImagingEnabled()) mprintf("\tImaged.\n"); else mprintf("\tImaging off.\n"); return Action::OK; }
// Analysis_KDE::Setup() Analysis::RetType Analysis_KDE::Setup(ArgList& analyzeArgs, AnalysisSetup& setup, int debugIn) { if (analyzeArgs.Contains("min")) { default_min_ = analyzeArgs.getKeyDouble("min", 0.0); minArgSet_ = true; } if (analyzeArgs.Contains("max")) { default_max_ = analyzeArgs.getKeyDouble("max", 0.0); maxArgSet_ = true; } default_step_ = analyzeArgs.getKeyDouble("step", 0.0); default_bins_ = analyzeArgs.getKeyInt("bins", -1); if (default_step_ == 0.0 && default_bins_ < 1) { mprinterr("Error: Must set either bins or step.\n"); return Analysis::ERR; } Temp_ = analyzeArgs.getKeyDouble("free",-1.0); if (Temp_!=-1.0) calcFreeE_ = true; else calcFreeE_ = false; std::string setname = analyzeArgs.GetStringKey("name"); bandwidth_ = analyzeArgs.getKeyDouble("bandwidth", -1.0); DataFile* outfile = setup.DFL().AddDataFile( analyzeArgs.GetStringKey("out"), analyzeArgs ); DataFile* klOutfile = 0; // Get second data set for KL divergence calc. std::string q_dsname = analyzeArgs.GetStringKey("kldiv"); if (!q_dsname.empty()) { q_data_ = setup.DSL().GetDataSet( q_dsname ); if (q_data_ == 0) { mprinterr("Error: Data set %s not found.\n", q_dsname.c_str()); return Analysis::ERR; } if (q_data_->Ndim() != 1) { mprinterr("Error: Only 1D data sets supported.\n"); return Analysis::ERR; } klOutfile = setup.DFL().AddDataFile( analyzeArgs.GetStringKey("klout"), analyzeArgs ); } else { q_data_ = 0; kldiv_ = 0; } // Get AMD boost data set std::string amdname = analyzeArgs.GetStringKey("amd"); if (!amdname.empty()) { amddata_ = setup.DSL().GetDataSet( amdname ); if (amddata_ == 0) { mprinterr("Error: AMD data set %s not found.\n", amdname.c_str()); return Analysis::ERR; } if (amddata_->Ndim() != 1) { mprinterr("Error: AMD data set must be 1D.\n"); return Analysis::ERR; } } else amddata_ = 0; // Get data set data_ = setup.DSL().GetDataSet( analyzeArgs.GetStringNext() ); if (data_ == 0) { mprinterr("Error: No data set or invalid data set name specified\n"); return Analysis::ERR; } if (data_->Ndim() != 1) { mprinterr("Error: Only 1D data sets supported.\n"); return Analysis::ERR; } // Output data set output_ = setup.DSL().AddSet(DataSet::DOUBLE, setname, "kde"); if (output_ == 0) return Analysis::ERR; if (outfile != 0) outfile->AddDataSet( output_ ); // Output for KL divergence calc. if ( q_data_ != 0 ) { kldiv_ = setup.DSL().AddSet(DataSet::DOUBLE, MetaData(output_->Meta().Name(), "kld")); if (klOutfile != 0) klOutfile->AddDataSet( kldiv_ ); } mprintf(" KDE: Using gaussian KDE to histogram set \"%s\"\n", data_->legend()); if (amddata_!=0) mprintf("\tPopulating bins using AMD boost from data set %s\n", amddata_->legend()); if (q_data_ != 0) { mprintf("\tCalculating Kullback-Leibler divergence with set \"%s\"\n", q_data_->legend()); } if (bandwidth_ < 0.0) mprintf("\tBandwidth will be estimated.\n"); else mprintf("\tBandwidth= %f\n", bandwidth_); if (calcFreeE_) mprintf("\tFree energy in kcal/mol will be calculated from bin populations at %f K.\n",Temp_); return Analysis::OK; }
// Action_LIE::init() Action::RetType Action_LIE::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { // Always use imaged distances InitImaging(true); double cut; // Get Keywords doelec_ = !(actionArgs.hasKey("noelec")); dovdw_ = !(actionArgs.hasKey("novdw")); DataFile* datafile = init.DFL().AddDataFile(actionArgs.GetStringKey("out"), actionArgs); dielc_ = actionArgs.getKeyDouble("diel", 1.0); cut = actionArgs.getKeyDouble("cutvdw", 12.0); cut2vdw_ = cut * cut; // store square of cut for computational efficiency cut = actionArgs.getKeyDouble("cutelec", 12.0); cut2elec_ = cut * cut; // store square of cut for computational efficiency onecut2_ = 1 / cut2elec_; bool has_mask2 = false; if (!doelec_ && !dovdw_) { mprinterr("Error: LIE: Cannot skip both ELEC and VDW calcs\n"); return Action::ERR; } // Get Masks Mask1_.SetMaskString( actionArgs.GetMaskNext() ); std::string refmask = actionArgs.GetMaskNext(); if (!refmask.empty()) { Mask2_.SetMaskString(refmask); has_mask2 = true; } else { Mask2_ = Mask1_; Mask2_.InvertMaskExpression(); } // Get data set name std::string ds_name = actionArgs.GetStringNext(); if (ds_name.empty()) ds_name = init.DSL().GenerateDefaultName("LIE"); // Datasets if (doelec_) { elec_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(ds_name, "EELEC")); if (elec_ == 0) return Action::ERR; if (datafile != 0) datafile->AddDataSet(elec_); } if (dovdw_) { vdw_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(ds_name, "EVDW")); if (vdw_ == 0) return Action::ERR; if (datafile != 0) datafile->AddDataSet(vdw_); } mprintf(" LIE: Ligand mask is %s. Surroundings are ", Mask1_.MaskString()); if (!has_mask2) mprintf("everything else. "); else mprintf("atoms in mask %s. ", Mask2_.MaskString()); mprintf("Cutoff is %.3lf Ang. ", cut); if (!doelec_) mprintf("Skipping Electrostatic Calc. "); if (!dovdw_) mprintf("Skipping VDW Calc. "); mprintf("\n"); return Action::OK; }
MetaData make_metadata(VALUE obj) { return MetaData(boost::shared_ptr<MetaDataImpl>(new RubyMetaData(RubyObject(obj)))); }