Action::RetType Action_MultiVector::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { debug_ = debugIn; // Get keywords outfile_ = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs); std::string resrange_arg = actionArgs.GetStringKey("resrange"); if (!resrange_arg.empty()) if (resRange_.SetRange( resrange_arg )) return Action::ERR; ired_ = actionArgs.hasKey("ired"); // Get atom names if (SetName(name1_, actionArgs.GetStringKey("name1"), "name1")) return Action::ERR; if (SetName(name2_, actionArgs.GetStringKey("name2"), "name2")) return Action::ERR; // Setup DataSet(s) name dsetname_ = actionArgs.GetStringNext(); mprintf(" MULTIVECTOR: Calculating"); if (ired_) mprintf(" IRED"); if (!resRange_.Empty()) mprintf(" vectors for residues in range %s\n", resRange_.RangeArg()); else mprintf(" vectors for all solute residues.\n"); mprintf("\tName1='%s' (origin) Name2='%s'\n", *name1_, *name2_); if (!dsetname_.empty()) mprintf("\tDataSet name: %s\n", dsetname_.c_str()); if (outfile_ != 0) mprintf("\tOutput to %s\n", outfile_->DataFilename().base()); init.DSL().SetDataSetsPending(true); masterDSL_ = init.DslPtr(); return Action::OK; }
// ----------------------------------------------------------------------------- // Action_Jcoupling::Init() Action::RetType Action_Jcoupling::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { debug_ = debugIn; outfile_ = 0; // Get Keywords outputfile_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("outfile"), "J-coupling"); outfile_ = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs ); std::string karpluspath = actionArgs.GetStringKey("kfile"); setname_ = actionArgs.GetStringKey("name"); // Get Masks if (Mask1_.SetMaskString( actionArgs.GetMaskNext() )) return Action::ERR; // If no Karplus params specified check environment vars. if (karpluspath.empty()) { // Check if the KARPLUS env var is set. const char* env = getenv("KARPLUS"); if (env != 0) { mprintf("Info: Using parameter file defined by $KARPLUS environment variable.\n"); karpluspath.assign(env); } else { // If KARPLUS not set check for $AMBERHOME/dat/Karplus.txt env = getenv("AMBERHOME"); if (env == 0) { mprinterr("Error: Either AMBERHOME must be set or KARPLUS must point\n" "Error: to the file containing Karplus parameters.\n"); return Action::ERR; } mprintf("Info: Using parameter file in '$AMBERHOME/dat/'.\n"); karpluspath.assign(env); karpluspath += "/dat/Karplus.txt"; } } // Load Karplus parameters if (loadKarplus(karpluspath)) return Action::ERR; mprintf(" J-COUPLING: Searching for dihedrals in mask [%s].\n" "\tUsing Karplus parameters in \"%s\"\n" "\t%i parameters found for %zu residues.\n", Mask1_.MaskString(), karpluspath.c_str(), Nconstants_, KarplusConstants_.size()); if (outfile_ != 0) mprintf("\tDataSets will be written to %s\n", outfile_->DataFilename().full()); if (outputfile_ != 0) mprintf("\tWriting fixed-format output to %s\n",outputfile_->Filename().full()); mprintf("# Citations: Chou et al. JACS (2003) 125 p.8959-8966\n" "# Perez et al. JACS (2001) 123 p.7081-7093\n"); init.DSL().SetDataSetsPending(true); masterDSL_ = init.DslPtr(); return Action::OK; }
// ----------------------------------------------------------------------------- // Action_NMRrst::Init() Action::RetType Action_NMRrst::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { # ifdef MPI if (init.TrajComm().Size() > 1) { mprinterr("Error: 'nmrrst' action does not work with > 1 thread (%i threads currently).\n", init.TrajComm().Size()); return Action::ERR; } # endif debug_ = debugIn; // Get Keywords Image_.InitImaging( !(actionArgs.hasKey("noimage")) ); useMass_ = !(actionArgs.hasKey("geom")); findNOEs_ = actionArgs.hasKey("findnoes"); findOutput_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("findout"), "Found NOEs", DataFileList::TEXT, true); specOutput_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("specout"), "Specified NOEs", DataFileList::TEXT, true); if (findOutput_ == 0 || specOutput_ == 0) return Action::ERR; resOffset_ = actionArgs.getKeyInt("resoffset", 0); DataFile* outfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs ); max_cut_ = actionArgs.getKeyDouble("cut", 6.0); strong_cut_ = actionArgs.getKeyDouble("strongcut", 2.9); medium_cut_ = actionArgs.getKeyDouble("mediumcut", 3.5); weak_cut_ = actionArgs.getKeyDouble("weakcut", 5.0); series_ = actionArgs.hasKey("series"); std::string rstfilename = actionArgs.GetStringKey("file"); viewrst_ = actionArgs.GetStringKey("viewrst"); setname_ = actionArgs.GetStringKey("name"); if (setname_.empty()) setname_ = init.DSL().GenerateDefaultName("NMR"); nframes_ = 0; // Atom Mask Mask_.SetMaskString( actionArgs.GetMaskNext() ); // Pairs specified on command line. std::string pair1 = actionArgs.GetStringKey("pair"); while (!pair1.empty()) { std::string pair2 = actionArgs.GetStringNext(); if (pair2.empty()) { mprinterr("Error: Only one mask specified for pair (%s)\n", pair1.c_str()); return Action::ERR; } Pairs_.push_back( MaskPairType(AtomMask(pair1), AtomMask(pair2)) ); pair1 = actionArgs.GetStringKey("pair"); } // Check that something will be done if (!findNOEs_ && rstfilename.empty() && Pairs_.empty()) { mprinterr("Error: Must specify restraint file, 'pair', and/or 'findnoes'.\n"); return Action::ERR; } // Read in NMR restraints. if (!rstfilename.empty()) { if (ReadNmrRestraints( rstfilename )) return Action::ERR; } // Set up distances. int num_noe = 1; for (noeDataArray::iterator noe = NOEs_.begin(); noe != NOEs_.end(); ++noe, ++num_noe) { // Translate any ambiguous atom names TranslateAmbiguous( noe->aName1_ ); TranslateAmbiguous( noe->aName2_ ); // Create mask expressions from resnum/atom name noe->dMask1_.SetMaskString( MaskExpression( noe->resNum1_, noe->aName1_ ) ); noe->dMask2_.SetMaskString( MaskExpression( noe->resNum2_, noe->aName2_ ) ); // Dataset to store distances AssociatedData_NOE noeData(noe->bound_, noe->boundh_, noe->rexp_); MetaData md(setname_, "NOE", num_noe); md.SetLegend( noe->dMask1_.MaskExpression() + " and " + noe->dMask2_.MaskExpression()); md.SetScalarMode( MetaData::M_DISTANCE ); md.SetScalarType( MetaData::NOE ); noe->dist_ = init.DSL().AddSet(DataSet::DOUBLE, md); if (noe->dist_==0) return Action::ERR; noe->dist_->AssociateData( &noeData ); // Add dataset to data file if (outfile != 0) outfile->AddDataSet( noe->dist_ ); } masterDSL_ = init.DslPtr(); mprintf("Warning: *** THIS ACTION IS EXPERIMENTAL. ***\n"); mprintf(" NMRRST: %zu NOEs from NMR restraint file.\n", NOEs_.size()); mprintf("\tShifting residue numbers in restraint file by %i\n", resOffset_); // DEBUG - print NOEs for (noeDataArray::const_iterator noe = NOEs_.begin(); noe != NOEs_.end(); ++noe) mprintf("\t'%s' %f < %f < %f\n", noe->dist_->legend(), noe->bound_, noe->rexp_, noe->boundh_); if (findNOEs_) { mprintf("\tSearching for potential NOEs. Max cutoff is %g Ang.\n", max_cut_); mprintf("\tNOE distance criteria (Ang.): S= %g, M= %g, W= %g\n", strong_cut_, medium_cut_, weak_cut_); if (series_) mprintf("\tDistance data for NOEs less than cutoff will be saved as '%s[foundNOE]'.\n", setname_.c_str()); mprintf("\tFound NOEs will be written to '%s'\n", findOutput_->Filename().full()); } if (!Pairs_.empty()) { mprintf("\tSpecified NOE pairs:\n"); for (MaskPairArray::const_iterator mp = Pairs_.begin(); mp != Pairs_.end(); ++mp) mprintf("\t\t[%s] to [%s]\n", mp->first.MaskString(), mp->second.MaskString()); mprintf("\tSpecified NOE data will be written to '%s'\n", specOutput_->Filename().full()); } if (!Image_.UseImage()) mprintf("\tNon-imaged"); else mprintf("\tImaged"); if (useMass_) mprintf(", center of mass.\n"); else mprintf(", geometric center.\n"); if (!viewrst_.empty()) mprintf("\tTopologies corresponding to found NOEs will be written to '%s'\n", viewrst_.c_str()); return Action::OK; }
// Action_Diffusion::Init() Action::RetType Action_Diffusion::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { # ifdef MPI trajComm_ = init.TrajComm(); # endif debug_ = debugIn; image_.InitImaging( !(actionArgs.hasKey("noimage")) ); // Determine if this is old syntax or new. if (actionArgs.Nargs() > 2 && actionArgs.ArgIsMask(1) && validDouble(actionArgs[2])) { // Old syntax: <mask> <time per frame> [average] [<prefix>] printIndividual_ = !(actionArgs.hasKey("average")); calcDiffConst_ = false; mprintf("Warning: Deprecated syntax for 'diffusion'. Consider using new syntax:\n"); ShortHelp(); mask_.SetMaskString( actionArgs.GetMaskNext() ); time_ = actionArgs.getNextDouble(1.0); if (CheckTimeArg(time_)) return Action::ERR; std::string outputNameRoot = actionArgs.GetStringNext(); // Default filename: 'diffusion' if (outputNameRoot.empty()) outputNameRoot.assign("diffusion"); // Open output files ArgList oldArgs("prec 8.3 noheader"); DataFile::DataFormatType dft = DataFile::DATAFILE; outputx_ = init.DFL().AddDataFile(outputNameRoot+"_x.xmgr", dft, oldArgs); outputy_ = init.DFL().AddDataFile(outputNameRoot+"_y.xmgr", dft, oldArgs); outputz_ = init.DFL().AddDataFile(outputNameRoot+"_z.xmgr", dft, oldArgs); outputr_ = init.DFL().AddDataFile(outputNameRoot+"_r.xmgr", dft, oldArgs); outputa_ = init.DFL().AddDataFile(outputNameRoot+"_a.xmgr", dft, oldArgs); } else { // New syntax: [{separateout <suffix> | out <filename>}] [time <time per frame>] // [<mask>] [<set name>] [individual] [diffout <filename>] [nocalc] printIndividual_ = actionArgs.hasKey("individual"); calcDiffConst_ = !(actionArgs.hasKey("nocalc")); std::string suffix = actionArgs.GetStringKey("separateout"); std::string outname = actionArgs.GetStringKey("out"); if (!outname.empty() && !suffix.empty()) { mprinterr("Error: Specify either 'out' or 'separateout', not both.\n"); return Action::ERR; } diffout_ = init.DFL().AddDataFile(actionArgs.GetStringKey("diffout")); time_ = actionArgs.getKeyDouble("time", 1.0); if (CheckTimeArg(time_)) return Action::ERR; mask_.SetMaskString( actionArgs.GetMaskNext() ); // Open output files. if (!suffix.empty()) { FileName FName( suffix ); outputx_ = init.DFL().AddDataFile(FName.PrependFileName("x_"), actionArgs); outputy_ = init.DFL().AddDataFile(FName.PrependFileName("y_"), actionArgs); outputz_ = init.DFL().AddDataFile(FName.PrependFileName("z_"), actionArgs); outputr_ = init.DFL().AddDataFile(FName.PrependFileName("r_"), actionArgs); outputa_ = init.DFL().AddDataFile(FName.PrependFileName("a_"), actionArgs); if (diffout_ == 0 && calcDiffConst_) diffout_ = init.DFL().AddDataFile(FName.PrependFileName("diff_"), actionArgs); } else if (!outname.empty()) { outputr_ = init.DFL().AddDataFile( outname, actionArgs ); outputx_ = outputy_ = outputz_ = outputa_ = outputr_; } } if (diffout_ != 0) calcDiffConst_ = true; // Add DataSets dsname_ = actionArgs.GetStringNext(); if (dsname_.empty()) dsname_ = init.DSL().GenerateDefaultName("Diff"); avg_x_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(dsname_, "X")); avg_y_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(dsname_, "Y")); avg_z_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(dsname_, "Z")); avg_r_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(dsname_, "R")); avg_a_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(dsname_, "A")); if (avg_x_ == 0 || avg_y_ == 0 || avg_z_ == 0 || avg_r_ == 0 || avg_a_ == 0) return Action::ERR; if (outputr_ != 0) outputr_->AddDataSet( avg_r_ ); if (outputx_ != 0) outputx_->AddDataSet( avg_x_ ); if (outputy_ != 0) outputy_->AddDataSet( avg_y_ ); if (outputz_ != 0) outputz_->AddDataSet( avg_z_ ); if (outputa_ != 0) outputa_->AddDataSet( avg_a_ ); // Set X dim Xdim_ = Dimension(0.0, time_, "Time"); avg_x_->SetDim(Dimension::X, Xdim_); avg_y_->SetDim(Dimension::X, Xdim_); avg_z_->SetDim(Dimension::X, Xdim_); avg_r_->SetDim(Dimension::X, Xdim_); avg_a_->SetDim(Dimension::X, Xdim_); // Add DataSets for diffusion constant calc if (calcDiffConst_) { MetaData::tsType ts = MetaData::NOT_TS; diffConst_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(dsname_, "D", ts)); diffLabel_ = init.DSL().AddSet(DataSet::STRING, MetaData(dsname_, "Label", ts)); diffSlope_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(dsname_, "Slope", ts)); diffInter_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(dsname_, "Intercept", ts)); diffCorrl_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(dsname_, "Corr", ts)); if (diffConst_ == 0 || diffLabel_ == 0 || diffSlope_ == 0 || diffInter_ == 0 || diffCorrl_ == 0) return Action::ERR; # ifdef MPI // No sync needed since these are not time series diffConst_->SetNeedsSync( false ); diffLabel_->SetNeedsSync( false ); diffSlope_->SetNeedsSync( false ); diffInter_->SetNeedsSync( false ); diffCorrl_->SetNeedsSync( false ); # endif if (diffout_ != 0) { diffout_->AddDataSet( diffConst_ ); diffout_->AddDataSet( diffSlope_ ); diffout_->AddDataSet( diffInter_ ); diffout_->AddDataSet( diffCorrl_ ); diffout_->AddDataSet( diffLabel_ ); } Dimension Ddim( 1, 1, "Set" ); diffConst_->SetDim(Dimension::X, Ddim); diffLabel_->SetDim(Dimension::X, Ddim); diffSlope_->SetDim(Dimension::X, Ddim); diffInter_->SetDim(Dimension::X, Ddim); diffCorrl_->SetDim(Dimension::X, Ddim); } // Save master data set list, needed when printIndividual_ masterDSL_ = init.DslPtr(); mprintf(" DIFFUSION:\n"); mprintf("\tAtom Mask is [%s]\n", mask_.MaskString()); if (printIndividual_) mprintf("\tBoth average and individual diffusion will be calculated.\n"); else mprintf("\tOnly average diffusion will be calculated.\n"); mprintf("\tData set base name: %s\n", avg_x_->Meta().Name().c_str()); if (image_.UseImage()) mprintf("\tCorrections for imaging enabled.\n"); else mprintf("\tCorrections for imaging disabled.\n"); // If one file defined, assume all are. if (outputx_ != 0) { mprintf("\tOutput files:\n" "\t %s: (x) Mean square displacement(s) in the X direction (in Ang.^2).\n" "\t %s: (y) Mean square displacement(s) in the Y direction (in Ang.^2).\n" "\t %s: (z) Mean square displacement(s) in the Z direction (in Ang.^2).\n" "\t %s: (r) Overall mean square displacement(s) (in Ang.^2).\n" "\t %s: (a) Total distance travelled (in Ang.).\n", outputx_->DataFilename().full(), outputy_->DataFilename().full(), outputz_->DataFilename().full(), outputr_->DataFilename().full(), outputa_->DataFilename().full()); } mprintf("\tThe time between frames is %g ps.\n", time_); if (calcDiffConst_) { mprintf("\tCalculating diffusion constants by fitting slope to MSD vs time\n" "\t and multiplying by 10.0/2*N (where N is # of dimensions), units\n" "\t are 1x10^-5 cm^2/s.\n"); if (diffout_ != 0) mprintf("\tDiffusion constant output to '%s'\n", diffout_->DataFilename().full()); else mprintf("\tDiffusion constant output to STDOUT.\n"); } else mprintf("\tTo calculate diffusion constant from mean squared displacement plots,\n" "\t calculate the slope of MSD vs time and multiply by 10.0/2*N (where N\n" "\t is # of dimensions); this will give units of 1x10^-5 cm^2/s.\n"); return Action::OK; }
// Action_NativeContacts::Init() Action::RetType Action_NativeContacts::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { # ifdef MPI trajComm_ = init.TrajComm(); # endif masterDSL_ = init.DslPtr(); debug_ = debugIn; // Get Keywords image_.InitImaging( !(actionArgs.hasKey("noimage")) ); double dist = actionArgs.getKeyDouble("distance", 7.0); byResidue_ = actionArgs.hasKey("byresidue"); resoffset_ = actionArgs.getKeyInt("resoffset", 0) + 1; if (resoffset_ < 1) { mprinterr("Error: Residue offset must be >= 0\n"); return Action::ERR; } includeSolvent_ = actionArgs.hasKey("includesolvent"); series_ = actionArgs.hasKey("series"); saveNonNative_ = actionArgs.hasKey("savenonnative"); if (actionArgs.hasKey("skipnative")) determineNativeContacts_ = false; if (!determineNativeContacts_ && !saveNonNative_) { mprintf("Warning: 'skipnative' specified; implies 'savenonnative'.\n"); saveNonNative_ = true; } # ifdef MPI if (saveNonNative_) { mprinterr("Error: Saving non-native contact data not yet supported for MPI\n"); return Action::ERR; } # endif distance_ = dist * dist; // Square the cutoff first_ = actionArgs.hasKey("first"); DataFile* outfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs ); Rseries_ = NO_RESSERIES; if (series_) { seriesout_ = init.DFL().AddDataFile(actionArgs.GetStringKey("seriesout"), actionArgs); init.DSL().SetDataSetsPending( true ); if (saveNonNative_) seriesNNout_ = init.DFL().AddDataFile(actionArgs.GetStringKey("seriesnnout"), actionArgs); std::string rs_arg = actionArgs.GetStringKey("resseries"); if (!rs_arg.empty()) { if (rs_arg == "present") Rseries_ = RES_PRESENT; else if (rs_arg == "sum") Rseries_ = RES_SUM; else { mprinterr("Error: '%s' is not a valid 'resseries' keyword.\n", rs_arg.c_str()); return Action::ERR; } seriesRout_ = init.DFL().AddDataFile(actionArgs.GetStringKey("resseriesout"), actionArgs); } } else { if (KeywordError(actionArgs,"seriesout")) return Action::ERR; if (KeywordError(actionArgs,"seriesnnout")) return Action::ERR; if (KeywordError(actionArgs,"resseries")) return Action::ERR; if (KeywordError(actionArgs,"resseriesout")) return Action::ERR; } cfile_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("writecontacts"), "Native Contacts", DataFileList::TEXT, true); pfile_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("contactpdb"), "Contact PDB", DataFileList::PDB); if (saveNonNative_) nfile_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("nncontactpdb"), "Non-native Contact PDB", DataFileList::PDB); rfile_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("resout"), "Contact Res Pairs", DataFileList::TEXT, true); if (cfile_ == 0 || rfile_ == 0) return Action::ERR; pdbcut_ = (float)actionArgs.getKeyDouble("pdbcut", -1.0); usepdbcut_ = (pdbcut_ > -1.0); // Get reference for native contacts. Do this even if we wont be // determining native contacts in order to set up contact lists. ReferenceFrame REF = init.DSL().GetReferenceFrame( actionArgs ); if (!first_) { if (REF.error()) return Action::ERR; if (REF.empty()) { mprintf("Warning: No reference structure specified. Defaulting to first.\n"); first_ = true; } } else { if (!REF.empty()) { mprinterr("Error: Must only specify 'first' or a reference structure, not both.\n"); return Action::ERR; } } // Create data sets std::string name = actionArgs.GetStringKey("name"); if (name.empty()) name = init.DSL().GenerateDefaultName("Contacts"); numnative_ = init.DSL().AddSet(DataSet::INTEGER, MetaData(name, "native")); nonnative_ = init.DSL().AddSet(DataSet::INTEGER, MetaData(name, "nonnative")); if (outfile != 0) { outfile->AddDataSet(numnative_); outfile->AddDataSet(nonnative_); } if (numnative_ == 0 || nonnative_ == 0) return Action::ERR; if (actionArgs.hasKey("mindist")) { mindist_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(name, "mindist")); if (mindist_ == 0) return Action::ERR; if (outfile != 0) outfile->AddDataSet(mindist_); } if (actionArgs.hasKey("maxdist")) { maxdist_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(name, "maxdist")); if (maxdist_ == 0) return Action::ERR; if (outfile != 0) outfile->AddDataSet(maxdist_); } DataFile *natmapfile = 0, *nonmapfile = 0; if (actionArgs.hasKey("map")) { nativeMap_ = (DataSet_MatrixDbl*)init.DSL().AddSet(DataSet::MATRIX_DBL, MetaData(name, "nativemap")); if (nativeMap_ == 0) return Action::ERR; nonnatMap_ = (DataSet_MatrixDbl*)init.DSL().AddSet(DataSet::MATRIX_DBL, MetaData(name, "nonnatmap")); if (nonnatMap_ == 0) return Action::ERR; FileName mapFilename; mapFilename.SetFileName( actionArgs.GetStringKey("mapout") ); if (!mapFilename.empty()) { natmapfile = init.DFL().AddDataFile(mapFilename.PrependFileName("native.")); if (natmapfile != 0) natmapfile->AddDataSet(nativeMap_); nonmapfile = init.DFL().AddDataFile(mapFilename.PrependFileName("nonnative.")); if (nonmapfile != 0) nonmapfile->AddDataSet(nonnatMap_); } } // Get Masks if (Mask1_.SetMaskString( actionArgs.GetMaskNext() )) return Action::ERR; std::string mask2 = actionArgs.GetMaskNext(); if (!mask2.empty()) { if (Mask2_.SetMaskString( mask2 )) return Action::ERR; } mprintf(" NATIVECONTACTS: Mask1='%s'", Mask1_.MaskString()); if (Mask2_.MaskStringSet()) mprintf(" Mask2='%s'", Mask2_.MaskString()); if (determineNativeContacts_) { mprintf(", native contacts set up based on"); if (first_) mprintf(" first frame.\n"); else mprintf("'%s'.\n", REF.refName()); } else { mprintf(", skipping native contacts set up.\n"); } if (byResidue_) { mprintf("\tContacts will be ignored for residues spaced < %i apart.\n", resoffset_); if (nativeMap_ != 0) mprintf("\tMap will be printed by residue.\n"); } if (saveNonNative_) mprintf("\tSaving non-native contacts as well (may use a lot of memory).\n"); mprintf("\tDistance cutoff is %g Angstroms,", sqrt(distance_)); if (!image_.UseImage()) mprintf(" imaging is off.\n"); else mprintf(" imaging is on.\n"); if (includeSolvent_) mprintf("\tMask selection will including solvent.\n"); else mprintf("\tMask selection will not include solvent.\n"); mprintf("\tData set name: %s\n", name.c_str()); if (maxdist_ != 0) mprintf("\tSaving maximum observed distances in set '%s'\n", maxdist_->legend()); if (mindist_ != 0) mprintf("\tSaving minimum observed distances in set '%s'\n", mindist_->legend()); if (outfile != 0) mprintf("\tOutput to '%s'\n", outfile->DataFilename().full()); mprintf("\tContact stats will be written to '%s'\n", cfile_->Filename().full()); mprintf("\tContact res pairs will be written to '%s'\n", rfile_->Filename().full()); if (pfile_ != 0) { mprintf("\tContact PDB will be written to '%s'\n", pfile_->Filename().full()); if (usepdbcut_) mprintf("\tOnly atoms with values > %g will be written to PDB.\n", pdbcut_); } if (nfile_ != 0) { mprintf("\tNon-native contact PDB will be written to '%s'\n", nfile_->Filename().full()); if (usepdbcut_) mprintf("\tOnly atoms with values > %g will be written to PDB.\n", pdbcut_); } if (nativeMap_ != 0) { mprintf("\tNative contacts map will be saved as set '%s'\n" "\tNon-native contacts map will be saved as set '%s'\n", nativeMap_->legend(), nonnatMap_->legend()); if (natmapfile!=0) mprintf("\tNative map output to '%s'\n",natmapfile->DataFilename().full()); if (nonmapfile!=0) mprintf("\tNative map output to '%s'\n",nonmapfile->DataFilename().full()); } if (series_) { mprintf("\tSaving native contact time series %s[NC].\n", name.c_str()); if (seriesout_ != 0) mprintf("\tWriting native contact time series to %s\n", seriesout_->DataFilename().full()); if (saveNonNative_) { mprintf("\tSaving non-native contact time series %s[NN]\n", name.c_str()); if (seriesNNout_ != 0) mprintf("\tWriting non-native contact time series to %s\n", seriesNNout_->DataFilename().full()); } if (Rseries_ != NO_RESSERIES) { if (Rseries_ == RES_PRESENT) mprintf("\tResidue contact time series will reflect presence of individual contacts.\n"); else if (Rseries_ == RES_SUM) mprintf("\tResidue contact time series will reflect sum of individual contacts.\n"); if (seriesRout_ != 0) mprintf("\tWriting residue contact time series to %s\n", seriesRout_->DataFilename().full()); } } // Set up reference if necessary. if (!first_) { // Set up imaging info for ref parm image_.SetupImaging( REF.CoordsInfo().TrajBox().Type() ); if (image_.ImageType() == NONORTHO) REF.Coord().BoxCrd().ToRecip(ucell_, recip_); if (DetermineNativeContacts( REF.Parm(), REF.Coord() )) return Action::ERR; } return Action::OK; }
/** Called once before traj processing. Set up reference info. */ Action::RetType Action_Rmsd::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { debug_ = debugIn; // Check for keywords fit_ = !actionArgs.hasKey("nofit"); if (fit_) rotate_ = !actionArgs.hasKey("norotate"); useMass_ = actionArgs.hasKey("mass"); DataFile* outfile = init.DFL().AddDataFile(actionArgs.GetStringKey("out"), actionArgs); bool saveMatrices = actionArgs.hasKey("savematrices"); // Reference keywords bool previous = actionArgs.hasKey("previous"); bool first = actionArgs.hasKey("first"); ReferenceFrame refFrm = init.DSL().GetReferenceFrame( actionArgs ); std::string reftrajname = actionArgs.GetStringKey("reftraj"); if (!reftrajname.empty()) RefParm_ = init.DSL().GetTopology( actionArgs ); // Per-res keywords perres_ = actionArgs.hasKey("perres"); if (perres_) { perresout_ = init.DFL().AddDataFile( actionArgs.GetStringKey("perresout") ); perresinvert_ = actionArgs.hasKey("perresinvert"); TgtRange_.SetRange( actionArgs.GetStringKey("range") ); RefRange_.SetRange( actionArgs.GetStringKey("refrange") ); perresmask_ = actionArgs.GetStringKey("perresmask"); if (perresmask_.empty()) perresmask_.assign(""); else { // If perresmask does not start with ampersand, insert one. if (perresmask_[0] != '&') perresmask_ = '&' + perresmask_; } perrescenter_ = actionArgs.hasKey("perrescenter"); perresavg_ = init.DFL().AddDataFile( actionArgs.GetStringKey("perresavg") ); } // Get the RMS mask string for target std::string tMaskExpr = actionArgs.GetMaskNext(); tgtMask_.SetMaskString(tMaskExpr); // Get the RMS mask string for reference std::string rMaskExpr = actionArgs.GetMaskNext(); if (rMaskExpr.empty()) rMaskExpr = tMaskExpr; // Initialize reference if (REF_.InitRef(previous, first, useMass_, fit_, reftrajname, refFrm, RefParm_, rMaskExpr, actionArgs, "rmsd")) return Action::ERR; // Set RefParm for perres if not empty if (perres_ && RefParm_ == 0 && !refFrm.empty()) RefParm_ = refFrm.ParmPtr(); // Set up the RMSD data set. MetaData md( actionArgs.GetStringNext(), MetaData::M_RMS ); rmsd_ = init.DSL().AddSet(DataSet::DOUBLE, md, "RMSD"); if (rmsd_==0) return Action::ERR; // Add dataset to data file list if (outfile != 0) outfile->AddDataSet( rmsd_ ); // Set up rotation matrix data set if specified if (saveMatrices) { md.SetAspect("RM"); if (!fit_) { mprinterr("Error: Must be fitting in order to save rotation matrices.\n"); return Action::ERR; } rmatrices_ = init.DSL().AddSet(DataSet::MAT3X3, md); if (rmatrices_ == 0) return Action::ERR; } mprintf(" RMSD: (%s), reference is %s", tgtMask_.MaskString(), REF_.RefModeString()); if (!fit_) mprintf(", no fitting"); else { mprintf(", with fitting"); if (!rotate_) mprintf(" (no rotation)"); } if (useMass_) mprintf(", mass-weighted"); mprintf(".\n"); if (rmatrices_ != 0) mprintf("\tRotation matrices will be saved to set '%s'\n", rmatrices_->legend()); // Per-residue RMSD info. if (perres_) { mprintf(" No-fit RMSD will also be calculated for "); if (TgtRange_.Empty()) mprintf("each solute residue"); else mprintf("residues %s",TgtRange_.RangeArg()); if (!RefRange_.Empty()) mprintf(" (reference residues %s)",RefRange_.RangeArg()); mprintf(" using mask [:X%s].\n",perresmask_.c_str()); if (perresout_ != 0) mprintf(" Per-residue output file is %s\n",perresout_->DataFilename().base()); if (perresavg_ != 0) mprintf(" Avg per-residue output file is %s\n",perresavg_->DataFilename().base()); if (perrescenter_) mprintf(" perrescenter: Each residue will be centered prior to RMS calc.\n"); if (perresinvert_) mprintf(" perresinvert: Frames will be written in rows instead of columns.\n"); } if (perres_) init.DSL().SetDataSetsPending(true); masterDSL_ = init.DslPtr(); return Action::OK; }