Example #1
0
/** Set up masks and properties for selected atoms. */
Action::RetType Action_Density::HistSetup(ActionSetup& setup) {
  properties_.clear();
  properties_.reserve( masks_.size() );

  for (std::vector<AtomMask>::iterator mask = masks_.begin();
                                       mask != masks_.end();
                                       mask++)
  {
    if (setup.Top().SetupIntegerMask(*mask) ) return Action::ERR;

    std::vector<double> property;

    for (AtomMask::const_iterator idx = mask->begin();
                                  idx != mask->end(); idx++)
    {
      const Atom& atom = setup.Top()[*idx];

      switch (property_) {
        case NUMBER   : property.push_back(1.0); break;
        case MASS     : property.push_back(atom.Mass() ); break;
        case CHARGE   : property.push_back(atom.Charge() ); break;
        case ELECTRON : property.push_back(atom.AtomicNumber() - atom.Charge() ); break;
      }
    }

    properties_.push_back(property);

    mprintf("\t");
    mask->BriefMaskInfo();
    mprintf("\n");
  }

  return Action::OK;  
}
Example #2
0
/** If the current parm does not match the target parm, deactivate. Otherwise
  * replace current parm with mapped parm.
  */
Action::RetType Action_AtomMap::Setup(ActionSetup& setup) {
    if (maponly_) {
        mprintf("    ATOMMAP: maponly was specified, not using atom map during traj read.\n");
        return Action::OK;
    }
    if (setup.Top().Pindex() != TgtFrame_->Top().Pindex() ||
            setup.Top().Natom() != TgtFrame_->Top().Natom())
    {
        mprintf("    ATOMMAP: Map for parm %s -> %s (%i atom).\n",TgtFrame_->Top().c_str(),
                RefFrame_->Top().c_str(), TgtFrame_->Top().Natom());
        mprintf("             Current parm %s (%i atom).\n",setup.Top().c_str(),
                setup.Top().Natom());
        mprintf("             Not using map for this parm.\n");
        return Action::SKIP;
    }
    if (rmsfit_) {
        mprintf("    ATOMMAP: rmsfit specified, %i atoms.\n",rmsRefFrame_.Natom());
        return Action::OK;
    }
    mprintf("    ATOMMAP: Map for parm %s -> %s (%i atom).\n",TgtFrame_->Top().c_str(),
            RefFrame_->Top().c_str(), TgtFrame_->Top().Natom());

    setup.SetTopology( newParm_ );

    return Action::MODIFY_TOPOLOGY;
}
Example #3
0
Action::RetType Action_DNAionTracker::Setup(ActionSetup& setup) {
  // Setup masks
  if (setup.Top().SetupIntegerMask( p1_ )) return Action::ERR; 
  if ( p1_.None() ) {
    mprinterr("Error: dnaiontracker: No atoms in mask1\n");
    return Action::ERR;
  }
  if (setup.Top().SetupIntegerMask( p2_ )) return Action::ERR;  
  if ( p2_.None() ) {
    mprinterr("Error: dnaiontracker: No atoms in mask2\n");
    return Action::ERR;
  }
  if (setup.Top().SetupIntegerMask( base_ )) return Action::ERR;  
  if ( base_.None() ) {
    mprinterr("Error: dnaiontracker: No atoms in mask3\n");
    return Action::ERR;
  }
  if (setup.Top().SetupIntegerMask( ions_ )) return Action::ERR;  
  if ( ions_.None() ) {
    mprinterr("Error: dnaiontracker: No atoms in mask4\n");
    return Action::ERR;
  }
  SetupImaging( setup.CoordInfo().TrajBox().Type() );
  mprintf("\tPhosphate1 Mask [%s] %i atoms.\n", p1_.MaskString(), p1_.Nselected());
  mprintf("\tPhosphate2 Mask [%s] %i atoms.\n", p2_.MaskString(), p2_.Nselected());
  mprintf("\t      Base Mask [%s] %i atoms.\n", base_.MaskString(), base_.Nselected());
  mprintf("\t      Ions Mask [%s] %i atoms.\n", ions_.MaskString(), ions_.Nselected());

  return Action::OK;
}
Example #4
0
/** Determine what atoms each mask pertains to for the current parm file.
  */
Action::RetType Action_LIE::Setup(ActionSetup& setup) {
  if (setup.Top().SetupIntegerMask( Mask1_ )) return Action::ERR;
  if (setup.Top().SetupIntegerMask( Mask2_ )) return Action::ERR;

  mprintf("\tLIE: %i Ligand Atoms, %i Surrounding Atoms\n",
          Mask1_.Nselected(), Mask2_.Nselected());

  if (setup.CoordInfo().TrajBox().Type() == Box::NOBOX) {
    mprinterr("Error: LIE: Must have explicit solvent system with box info\n");
    return Action::ERR;
  }

  if (Mask1_.None() || Mask2_.None()) {
    mprintf("Warning: LIE: One or both masks have no atoms.\n");
    return Action::SKIP;
  }

  if (SetupParms(setup.Top()))
    return Action::ERR;

  // Back up the parm
  CurrentParm_ = setup.TopAddress();

  return Action::OK;
}
/** For this to be valid the same # of atoms should be selected each time. */
Action::RetType Action_VelocityAutoCorr::Setup(ActionSetup& setup) {
  if (setup.Top().SetupIntegerMask( mask_ )) return Action::ERR;
  mask_.MaskInfo();
  if (mask_.None()) {
    mprintf("Warning: No atoms selected by mask.\n");
    return Action::SKIP;
  }
  // If using velocity info, check that it is present.
  if (useVelInfo_ && !setup.CoordInfo().HasVel()) {
    mprinterr("Error: 'usevelocity' specified but no velocity info assocated with %s\n",
              setup.Top().c_str());
    return Action::ERR;
  }
  // If we have already started recording velocities, check that the current 
  // number of selected atoms has remained the same.
  if (!Vel_.empty()) {
    if ((int)Vel_.size() != mask_.Nselected()) {
      mprinterr("Error: # of selected atoms %i has changed (previously %zu)\n",
                mask_.Nselected(), Vel_.size());
      return Action::ERR;
    }
  } else
    Vel_.resize( mask_.Nselected() );
  return Action::OK;
}
Example #6
0
// Action_MultiVector::Setup();
Action::RetType Action_MultiVector::Setup(ActionSetup& setup) {
  Range actualRange;
  // If range is empty (i.e. no resrange arg given) look through all 
  // solute residues.
  if (resRange_.Empty())
    actualRange = setup.Top().SoluteResidues();
  else {
    // If user range specified, create new range shifted by -1 since internal
    // resnums start from 0.
    actualRange = resRange_;
    actualRange.ShiftBy(-1);
  }
  // Exit if no residues specified
  if (actualRange.Empty()) {
    mprintf("Warning: No residues specified for %s\n",setup.Top().c_str());
    return Action::SKIP;
  }
  // Set default DataSet name if not specified.
  if (dsetname_.empty())
    dsetname_ = masterDSL_->GenerateDefaultName( "MVEC" );
  // Search for specified atom names in each residue in the range
  CrdIdx1_.clear();
  CrdIdx2_.clear();
  for (Range::const_iterator res = actualRange.begin(); res != actualRange.end(); ++res)
  {
    int atom1 = setup.Top().FindAtomInResidue( *res, name1_ );
    int atom2 = setup.Top().FindAtomInResidue( *res, name2_ );
    if (atom1 != -1 && atom2 != -1) {
      MetaData md(dsetname_, atom1+1);
      md.SetScalarMode( MetaData::M_VECTOR );
      if (ired_) md.SetScalarType( MetaData::IREDVEC );
      DataSet_Vector* ds = (DataSet_Vector*)masterDSL_->CheckForSet( md );
      if (ds == 0) {
        // Create DataSet
        ds = (DataSet_Vector*)masterDSL_->AddSet( DataSet::VECTOR, md );
        if (ds == 0) return Action::ERR;
        ds->SetLegend( "v" + setup.Top().AtomMaskName(atom1) + "->" +
                             setup.Top().AtomMaskName(atom2) );
        if (outfile_ != 0) outfile_->AddDataSet( ds );
      }
      data_.push_back( ds );
      CrdIdx1_.push_back( atom1 * 3 ); // Pre calc coordinate index
      CrdIdx2_.push_back( atom2 * 3 );
    } else if ((atom1==-1) != (atom2==-1)) {
      if (atom1==-1)
        mprintf("Warning: '%s' not found but '%s' found for residue %i.\n", 
                *name1_, *name2_, *res + 1);
      else // atom2==-1
        mprintf("Warning: '%s' not found but '%s' found for residue %i.\n",
                *name2_, *name1_, *res + 1);
    }
  }
  mprintf("\tSelected %zu vectors.\n", CrdIdx1_.size());
  for (std::vector<DataSet_Vector*>::const_iterator it = data_.begin();
                                                    it != data_.end(); ++it)
    mprintf("\t  %s\n", (*it)->legend());

  return Action::OK;
}
Example #7
0
// Action_Principal::Setup()
Action::RetType Action_Principal::Setup(ActionSetup& setup) {
  if (setup.Top().SetupIntegerMask(mask_)) return Action::ERR;
  mask_.MaskInfo();
  if (mask_.None()) {
    mprintf("Warning: No atoms selected for %s [%s].\n",setup.Top().c_str(), mask_.MaskString());
    return Action::SKIP;
  }
  return Action::OK;
}
Example #8
0
/** Set angle up for this parmtop. Get masks etc.
  */
Action::RetType Action_Esander::Setup(ActionSetup& setup) {
  if (currentParm_ != 0 && currentParm_->Pindex() != setup.Top().Pindex())
  {
    mprintf("Warning: Current topology is %i:%s but reference is %i:%s. Skipping.\n",
            setup.Top().Pindex(), setup.Top().c_str(),
            currentParm_->Pindex(), currentParm_->c_str());
    return Action::SKIP;
  }
  // Check for LJ terms
  if (!setup.Top().Nonbond().HasNonbond())
  {
    mprinterr("Error: Topology '%s' does not have non-bonded parameters.\n", setup.Top().c_str());
    return Action::ERR;
  }
  // If reference specified, init now. Otherwise using first frame.
  if (currentParm_ != 0 ) {
    if ( InitForRef() ) return Action::ERR;
  } else
    currentParm_ = setup.TopAddress();
  // If saving of forces is requested, make sure CoordinateInfo has force.
  if (save_forces_) {
    cInfo_ = setup.CoordInfo();
    cInfo_.SetForce( true );
    newFrame_.SetupFrameV( setup.Top().Atoms(), cInfo_ );
    setup.SetCoordInfo( &cInfo_ );
    ret_ = Action::MODIFY_COORDS;
    return Action::MODIFY_TOPOLOGY;
  }
  ret_ = Action::OK;
  return Action::OK;
}
Example #9
0
// Action_Outtraj::Setup()
Action::RetType Action_Outtraj::Setup(ActionSetup& setup) {
  if (associatedParm_->Pindex() != setup.Top().Pindex())
    return Action::SKIP;
  if (!isSetup_) { // TODO: Trajout IsOpen?
    if (outtraj_.SetupTrajWrite(setup.TopAddress(), setup.CoordInfo(), setup.Nframes()))
      return Action::ERR;
    outtraj_.PrintInfo(0);
    isSetup_ = true;
  }
  return Action::OK;
}
Example #10
0
/** Determine what atoms each mask pertains to for the current parm file.
  */
Action::RetType Action_ReplicateCell::Setup(ActionSetup& setup) {
  if (setup.Top().SetupIntegerMask( Mask1_ )) return Action::ERR;
  mprintf("\t%s (%i atoms)\n",Mask1_.MaskString(), Mask1_.Nselected());
  if (Mask1_.None()) {
    mprintf("Warning: One or both masks have no atoms.\n");
    return Action::SKIP;
  }
  // Set up imaging info for this parm
  image_.SetupImaging( setup.CoordInfo().TrajBox().Type() );
  if (!image_.ImagingEnabled()) {
    mprintf("Warning: Imaging cannot be performed for topology %s\n", setup.Top().c_str());
    return Action::SKIP;
  }
  // Create combined topology.
  if (combinedTop_.Natom() > 0) {
    // Topology already set up. Check that # atoms matches.
    if (Mask1_.Nselected() * ncopies_ != combinedTop_.Natom()) {
      mprintf("Warning: Unit cell can currently only be replicated for"
              " topologies with same # atoms.\n");
      return Action::SKIP;
    }
    // Otherwise assume top does not change.
  } else {
    // Set up topology and frame.
    Topology* stripParm = setup.Top().modifyStateByMask( Mask1_ );
    if (stripParm == 0) return Action::ERR;
    for (int cell = 0; cell != ncopies_; cell++)
      combinedTop_.AppendTop( *stripParm );
    combinedTop_.Brief("Combined parm:");
    delete stripParm;
    if (!parmfilename_.empty()) {
      ParmFile pfile;
      if (pfile.WriteTopology(combinedTop_, parmfilename_, ParmFile::UNKNOWN_PARM, 0)) {
        mprinterr("Error: Topology file %s not written.\n", parmfilename_.c_str());
        return Action::ERR;
      }
    }
    // Only coordinates for now. FIXME
    combinedFrame_.SetupFrameM(combinedTop_.Atoms());
    // Set up COORDS / output traj if necessary.
    if (coords_ != 0)
      coords_->CoordsSetup( combinedTop_, CoordinateInfo() );
    if (!trajfilename_.empty()) {
      if ( outtraj_.PrepareEnsembleTrajWrite(trajfilename_, trajArgs_,
                                             &combinedTop_, CoordinateInfo(),
                                             setup.Nframes(), TrajectoryFile::UNKNOWN_TRAJ,
                                             ensembleNum_) )
        return Action::ERR;
    }
  }

  return Action::OK;
}
// Action_CheckStructure::Setup()
Action::RetType Action_CheckStructure::Setup(ActionSetup& setup) {
  CurrentParm_ = setup.TopAddress();
  if (SeparateSetup( setup.Top(), setup.CoordInfo().TrajBox().Type(),bondcheck_ ))
    return Action::ERR;
  // Print imaging info for this parm
  if (bondcheck_)
    mprintf("\tChecking %u bonds.\n", bondList_.size());
  if (image_.ImagingEnabled())
    mprintf("\tImaging on.\n");
  else
    mprintf("\timaging off.\n");
  return Action::OK;
}
Example #12
0
// Action_Unwrap::Setup()
Action::RetType Action_Unwrap::Setup(ActionSetup& setup) {
  // Ensure same number of atoms in current parm and ref parm
  if ( RefParm_!=0 ) {
    if ( setup.Top().Natom() != RefParm_->Natom() ) {
      mprinterr("Error: unwrap: # atoms in reference parm %s is not\n", RefParm_->c_str());
      mprinterr("Error:         equal to # atoms in parm %s\n", setup.Top().c_str());
      return Action::ERR;
    }
  }
  // Check box type
  if (setup.CoordInfo().TrajBox().Type()==Box::NOBOX) {
    mprintf("Error: unwrap: Parm %s does not contain box information.\n",
            setup.Top().c_str());
    return Action::ERR;
  }
  orthogonal_ = false;
  if (setup.CoordInfo().TrajBox().Type()==Box::ORTHO)
    orthogonal_ = true;

  // Setup atom pairs to be unwrapped.
  imageList_ = Image::CreatePairList(setup.Top(), imageMode_, maskExpression_);
  if (imageList_.empty()) {
    mprintf("Warning: Mask selects no atoms for topology '%s'.\n", setup.Top().c_str());
    return Action::SKIP;
  }
  mprintf("\tNumber of %ss to be unwrapped is %zu\n",
          Image::ModeString(imageMode_), imageList_.size()/2);

  // Use current parm as reference if not already set
  if (RefParm_ == 0)
    RefParm_ = setup.TopAddress();
  return Action::OK;
}
Example #13
0
/** Set angle up for this parmtop. Get masks etc.
  */
Action::RetType Action_Angle::Setup(ActionSetup& setup) {
  if (setup.Top().SetupIntegerMask(Mask1_)) return Action::ERR;
  if (setup.Top().SetupIntegerMask(Mask2_)) return Action::ERR;
  if (setup.Top().SetupIntegerMask(Mask3_)) return Action::ERR;
  mprintf("\t");
  Mask1_.BriefMaskInfo();
  Mask2_.BriefMaskInfo();
  Mask3_.BriefMaskInfo();
  mprintf("\n");
  if (Mask1_.None() || Mask2_.None() || Mask3_.None()) {
    mprintf("Warning: angle: One or more masks contain 0 atoms.\n");
    return Action::SKIP;
  }
  return Action::OK;  
}
// Action_GridFreeEnergy::setup()
Action::RetType Action_GridFreeEnergy::Setup(ActionSetup& setup) {
  // Setup grid, checks box info.
  if (GridSetup( setup.Top(), setup.CoordInfo() )) return Action::ERR;

  // Setup mask
  if (setup.Top().SetupIntegerMask( mask_ ))
    return Action::ERR;
  mask_.MaskInfo();
  if (mask_.None()) {
    mprinterr("Warning: No atoms selected for parm %s\n", setup.Top().c_str());
    return Action::SKIP;
  }

  return Action::OK;
}
Example #15
0
// Action_Outtraj::Setup()
Action::RetType Action_Outtraj::Setup(ActionSetup& setup) {
  if (!isActive_ || associatedParm_->Pindex() != setup.Top().Pindex()) {
    mprintf("\tOutput trajectory not active for topology '%s'\n", setup.Top().c_str());
    return Action::SKIP;
  }
  if (!isSetup_) { // TODO: Trajout IsOpen?
    if (outtraj_.SetupTrajWrite(setup.TopAddress(), setup.CoordInfo(), setup.Nframes()))
      return Action::ERR;
    mprintf("      "); //TODO this is a kludge; PrintInfo should be a string.
    outtraj_.PrintInfo(0);
    mprintf("\tHas %s\n", outtraj_.Traj().CoordInfo().InfoString().c_str());
    isSetup_ = true;
  }
  return Action::OK;
}
Example #16
0
// Action_Center::Setup()
Action::RetType Action_Center::Setup(ActionSetup& setup) {

  if ( setup.Top().SetupIntegerMask(Mask_) ) return Action::ERR;
  Mask_.MaskInfo();
  if (Mask_.None()) {
    mprintf("Warning: Mask contains 0 atoms.\n");
    return Action::SKIP;
  }

  if (centerMode_ == BOXCTR && setup.CoordInfo().TrajBox().Type()==Box::NOBOX) {
    mprintf("Warning: Box center specified but no box information.\n");
    return Action::SKIP;
  }

  return Action::OK;  
}
Example #17
0
/** Called every time the trajectory changes. Set up TgtMask for the new 
  * parmtop and allocate space for selected atoms from the Frame.
  */
Action::RetType Action_DistRmsd::Setup(ActionSetup& setup) {

  if ( setup.Top().SetupIntegerMask(TgtMask_) ) return Action::ERR;
  if ( TgtMask_.None() ) {
    mprintf("Warning: No atoms in mask.\n");
    return Action::SKIP;
  }
  // Allocate space for selected atoms in the frame. This will also put the
  // correct masses in based on the mask.
  SelectedTgt_.SetupFrameFromMask(TgtMask_, setup.Top().Atoms());

  if (refHolder_.SetupRef(setup.Top(), TgtMask_.Nselected(), "distrmsd"))
    return Action::ERR; 

  return Action::OK;
}
// Action_NativeContacts::Setup()
Action::RetType Action_NativeContacts::Setup(ActionSetup& setup) {
  // Setup potential contact lists for this topology
  if (SetupContactLists( setup.Top(), Frame()))
    return Action::SKIP;
  mprintf("\t%zu potential contact sites for '%s'\n", Mask1_.Nselected(), Mask1_.MaskString());
  if (Mask2_.MaskStringSet())
    mprintf("\t%zu potential contact sites for '%s'\n", Mask2_.Nselected(), Mask2_.MaskString());
  // Set up imaging info for this parm
  image_.SetupImaging( setup.CoordInfo().TrajBox().Type() );
  if (image_.ImagingEnabled())
    mprintf("\tImaging enabled.\n");
  else
    mprintf("\tImaging disabled.\n");
  CurrentParm_ = setup.TopAddress();
  return Action::OK;
}
Example #19
0
// Action_Density::DensitySetup()
Action::RetType Action_Density::DensitySetup(ActionSetup& setup) {
  // Total system density setup
  image_.SetupImaging( setup.CoordInfo().TrajBox().Type() );
  if (!image_.ImagingEnabled()) {
    mprintf("Warning: No unit cell information, total density cannot be calculated for '%s'\n",
            setup.Top().c_str());
    return Action::SKIP;
  }
  // delta_ will hold sum of masses
  delta_ = 0.0;
  for (int idx = 0; idx != setup.Top().Natom(); idx++)
    delta_ += setup.Top()[idx].Mass();
  mprintf("\tSum of masses is %g amu\n", delta_);

  return Action::OK;
}
Example #20
0
/** Set angle up for this parmtop. Get masks etc.
  */
Action::RetType Action_Energy::Setup(ActionSetup& setup) {
  if (setup.Top().SetupCharMask(Mask1_)) return Action::ERR;
  if (Mask1_.None()) {
    mprintf("Warning: Mask '%s' selects no atoms.\n", Mask1_.MaskString());
    return Action::SKIP;
  }
  Mask1_.MaskInfo();
  Imask_ = AtomMask(Mask1_.ConvertToIntMask(), Mask1_.Natom());
  // Check for LJ terms
  for (calc_it calc = Ecalcs_.begin(); calc != Ecalcs_.end(); ++calc)
    if ((*calc == N14 || *calc == NBD) && !setup.Top().Nonbond().HasNonbond())
    {
      mprinterr("Error: Nonbonded energy calc requested but topology '%s'\n"
                "Error:   does not have non-bonded parameters.\n", setup.Top().c_str());
      return Action::ERR;
    }
  currentParm_ = setup.TopAddress();
  return Action::OK;
}
Example #21
0
/** Determine what atoms each mask pertains to for the current parm file.
  * Imaging is checked for in Action::Setup. 
  */
Action::RetType Action_Distance::Setup(ActionSetup& setup) {
  if (setup.Top().SetupIntegerMask( Mask1_ )) return Action::ERR;
  if (setup.Top().SetupIntegerMask( Mask2_ )) return Action::ERR;
  mprintf("\t%s (%i atoms) to %s (%i atoms)",Mask1_.MaskString(), Mask1_.Nselected(),
          Mask2_.MaskString(),Mask2_.Nselected());
  if (Mask1_.None() || Mask2_.None()) {
    mprintf("\nWarning: One or both masks have no atoms.\n");
    return Action::SKIP;
  }
  // Set up imaging info for this parm
  image_.SetupImaging( setup.CoordInfo().TrajBox().Type() );
  if (image_.ImagingEnabled())
    mprintf(", imaged");
  else
    mprintf(", imaging off");
  mprintf(".\n");

  return Action::OK;  
}
Example #22
0
Action::RetType Action_AtomicCorr::Setup(ActionSetup& setup) {
  if (setup.Top().SetupIntegerMask( mask_ )) return Action::ERR;
  mask_.MaskInfo();
  if (mask_.None()) return Action::SKIP;
  if (acorr_mode_ == ATOM) {
    // Setup output array; labels and index
    atom_vectors_.clear();
    for (AtomMask::const_iterator atom = mask_.begin(); atom != mask_.end(); ++atom)
      atom_vectors_.push_back( AtomVector(integerToString( *atom + 1 ), *atom) );
  } else {
    std::map<int,AtomMask> rmaskmap;
    // Find which residues selected atoms belong to.
    for (AtomMask::const_iterator atom = mask_.begin(); atom != mask_.end(); ++atom) 
    {
      int current_res = setup.Top()[*atom].ResNum();
      std::map<int,AtomMask>::iterator rmask = rmaskmap.find( current_res );
      if ( rmask == rmaskmap.end() ) {
        // Residue not yet in map.
        AtomMask newmask;
        newmask.AddAtom( *atom );
        rmaskmap.insert( std::pair<int,AtomMask>( current_res, newmask ) );
      } else {
        // Residue is already in map. Add this atom.
        rmask->second.AddAtom( *atom );
      }
    }
    // Place selected residues in mask vector and setup output array; labels and index.
    resmasks_.clear();
    atom_vectors_.clear();
    for (std::map<int,AtomMask>::const_iterator rmask = rmaskmap.begin();
                                                rmask != rmaskmap.end(); ++rmask)
    {
      if (debug_ > 0)
        mprintf("DBG:\tRes mask for %i has %i atoms\n", rmask->first, rmask->second.Nselected());
      resmasks_.push_back( rmask->second );
      atom_vectors_.push_back( AtomVector( setup.Top().TruncResNameNum( rmask->first ),
                                           rmask->first ) );
    }
    mprintf("\tSelected %zu residues.\n", resmasks_.size());
  }
  return Action::OK;
}
Example #23
0
Action::RetType Action_Channel::Setup(ActionSetup& setup) {
  // Initial grid setup
  if (grid_->Size() == 0) {
    DataSet_3D& GRID = static_cast<DataSet_3D&>( *grid_ );
    Box const& box = setup.Top().ParmBox();
    if (box.Type() == Box::NOBOX) {
      mprinterr("Error: No box information to set up grid.\n");
      return Action::ERR;
    } else if (box.Type() == Box::ORTHO) {
      // FIXME: May need to update parm box info or set up on first frame.
      if (GRID.Allocate_X_C_D(box.Lengths(), box.Center(), dxyz_)) return Action::ERR; 
    } else {
      Vec3 nxyz = box.Lengths() / dxyz_;
      if (GRID.Allocate_N_O_Box((size_t)nxyz[0], (size_t)nxyz[1], (size_t)nxyz[2],
                                Vec3(0.0), box)) return Action::ERR;
    }
    GRID.GridInfo();
  }
  // Set up masks
  if (setup.Top().SetupIntegerMask( soluteMask_ ) ||
      setup.Top().SetupIntegerMask( solventMask_)   )
    return Action::ERR;
  soluteMask_.MaskInfo();
  if (soluteMask_.None()) {
    mprintf("Warning: No solute atoms selected.\n");
    return Action::SKIP;
  }
  solventMask_.MaskInfo();
  if (solventMask_.None()) {
    mprintf("Warning: No solvent atoms selected.\n");
    return Action::SKIP;
  }
  // Set up solute van der Waals. FIXME: Handle case where no LJ params
  radii_.clear();
  for (AtomMask::const_iterator uAtom = soluteMask_.begin();
                                uAtom != soluteMask_.end(); ++uAtom)
    radii_.push_back( setup.Top().GetVDWradius( *uAtom ) );
  return Action::OK;
}
// Action_CreateReservoir::Setup()
Action::RetType Action_CreateReservoir::Setup(ActionSetup& setup) {
  // Check that input parm matches current parm
  if (original_trajparm_->Pindex() != setup.Top().Pindex()) {
    mprintf("Info: createreservoir was set up for topology %s\n", original_trajparm_->c_str());
    mprintf("Info: skipping topology %s\n", setup.Top().c_str());
    return Action::SKIP;
  }
  if (!trajIsOpen_) {
    mprintf("\tCreating reservoir file %s\n", filename_.full());
    CoordinateInfo cinfo = setup.CoordInfo();
    if (!useVelocity_) cinfo.SetVelocity(false);
    if (!useForce_)    cinfo.SetForce(false);
    if (reservoir_.InitReservoir(filename_, title_, cinfo, setup.Top().Natom(),
                                 (bin_ != 0), reservoirT_, iseed_))
    {
      mprinterr("Error: Could not set up NetCDF reservoir.\n");
      return Action::ERR;
    }
    trajIsOpen_ = true;
    nframes_ = 0;
  }
  return Action::OK;
}
Example #25
0
// Action_Vector::Setup()
Action::RetType Action_Vector::Setup(ActionSetup& setup) {
  if (needBoxInfo_) {
    // Check for box info
    if (setup.CoordInfo().TrajBox().Type() == Box::NOBOX) {
      mprinterr("Error: vector box: No box information.\n",
                setup.Top().c_str());
      return Action::ERR;
    }
  }
  if (mask_.MaskStringSet()) {
    // Setup mask 1
    if (setup.Top().SetupIntegerMask(mask_)) return Action::ERR;
    mask_.MaskInfo();
    if (mask_.None()) {
      mprinterr("Error: First vector mask is empty.\n");
      return Action::ERR;
    }
  }

  // Allocate space for CORRPLANE. 
  if (mode_ == CORRPLANE) {
    if (vcorr_!=0) delete[] vcorr_;
    vcorr_ = new double[ 3 * mask_.Nselected() ];
  }

  // Setup mask 2
  if (mask2_.MaskStringSet()) {
    if (setup.Top().SetupIntegerMask(mask2_)) return Action::ERR;
    mask2_.MaskInfo();
    if (mask2_.None()) {
      mprinterr("Error: Second vector mask is empty.\n");
      return Action::ERR;
    }
  }
  CurrentParm_ = setup.TopAddress();
  return Action::OK;
}
Example #26
0
Action::RetType Action_Contacts::Setup(ActionSetup& setup) {
  //if (first_) 
  //  RefParm_ = currentParm;
  // Set up atom mask 
  if (setup.Top().SetupIntegerMask(Mask_)) return Action::ERR;

  // Determine which residues are active based on the mask
  activeResidues_.clear();
  for (AtomMask::const_iterator atom = Mask_.begin();
                                atom != Mask_.end(); ++atom)
  {
    int resnum = setup.Top()[*atom].ResNum();
    activeResidues_.insert( resnum );
  }

  // byresidue header - only on first time through
  if (residueContacts_.empty() && byResidue_) {
    outfile_->Printf("#time");
    outfile2_->Printf("#time");
    for (std::set<int>::iterator res = activeResidues_.begin();
                                 res != activeResidues_.end(); ++res)
    {
      outfile_->Printf("\tresidue %i", *res);
      outfile2_->Printf("\tresidue %i", *res);
    }
    outfile_->Printf("\tTotal\n");
    outfile2_->Printf("\tTotal\n");
  }

  // Reserve space for residue contact counts
  residueContacts_.reserve( setup.Top().Nres() );
  residueNative_.reserve( setup.Top().Nres() );
  
  CurrentParm_ = setup.TopAddress();
  return Action::OK;
}
Example #27
0
Action::RetType Action_CreateCrd::Setup(ActionSetup& setup) {
  // Set COORDS topology now if not already set.
  if (setup.Top().Pindex() == pindex_ && coords_->Top().Natom() == 0) {
    coords_->CoordsSetup( setup.Top(), setup.CoordInfo() );
    // Estimate memory usage
    mprintf("\tEstimated memory usage (%i frames): %s\n",
            setup.Nframes(),
            ByteString(coords_->SizeInBytes(setup.Nframes()), BYTE_DECIMAL).c_str());
  }
  // If # atoms in currentParm does not match coords, warn user.
  if (setup.Top().Natom() != coords_->Top().Natom()) {
    if (check_) {
      mprinterr("Error: # atoms in current topology (%i) != # atoms in coords set \"%s\" (%i)\n",
                setup.Top().Natom(), coords_->legend(), coords_->Top().Natom());
      return Action::ERR;
    } else {
      mprintf("Warning: # atoms in current topology (%i) != # atoms in coords set \"%s\" (%i)\n"
              "Warning:   The resulting COORDS data set may have problems.\n",
              setup.Top().Natom(), coords_->legend(), coords_->Top().Natom());
    }
  }
  return Action::OK;
}
Example #28
0
/** Set up mask, allocate memory for exclusion list.
  */
Action::RetType Action_Pairwise::Setup(ActionSetup& setup) {
  // Set up mask
  if ( setup.Top().SetupIntegerMask( Mask0_ ) ) return Action::ERR;
  if (Mask0_.None()) {
    mprintf("Warning: Mask has no atoms.\n");
    return Action::SKIP;
  }

  // Set up exclusion list and determine total # interactions.
  int N_interactions = SetupNonbondParm(Mask0_, setup.Top());
  if (N_interactions == -1) return Action::ERR;
  // Allocate matrix memory
  int previous_size = (int)vdwMat_->Size();
  if (previous_size == 0) {
    vdwMat_->AllocateTriangle( setup.Top().Natom() );
    eleMat_->AllocateTriangle( setup.Top().Natom() );
  } else {
    if (previous_size != N_interactions) {
      mprinterr("Error: Attempting to reallocate matrix with different size.\n"
                "Error:   Original size= %i, new size= %i\n"
                "Error:   This can occur when different #s of atoms are selected in\n"
                "Error:   different topology files.\n", previous_size, N_interactions);
      return Action::ERR;
    }
  }

  // If comparing to a reference frame for atom-by-atom comparison make sure
  // the number of interactions is the same in reference and parm.
  if (nb_calcType_==COMPARE_REF) {
    if (N_interactions != N_ref_interactions_) {
      mprinterr("Error: # reference interactions (%i) != # interactions for this parm (%i)\n",
                N_ref_interactions_, N_interactions);
      return Action::ERR;
    }
  }
  // Set up cumulative energy arrays
  atom_eelec_.clear();
  atom_eelec_.resize(setup.Top().Natom(), 0.0);
  atom_evdw_.clear();
  atom_evdw_.resize(setup.Top().Natom(), 0.0);
  // Print pairwise info for this parm
  Mask0_.MaskInfo();
  CurrentParm_ = setup.TopAddress();
  return Action::OK;  
}
Example #29
0
// Action_SymmetricRmsd::Setup()
Action::RetType Action_SymmetricRmsd::Setup(ActionSetup& setup) {
  // Setup target mask.
  if (setup.Top().SetupIntegerMask( tgtMask_ )) return Action::ERR;
  tgtMask_.MaskInfo();
  if (tgtMask_.None()) {
    mprintf("Warning: No atoms selected by mask '%s'\n", tgtMask_.MaskString());
    return Action::SKIP;
  }
  // Allocate space for selected atoms in target frame. This will also
  // put the correct masses in based on the mask.
  selectedTgt_.SetupFrameFromMask(tgtMask_, setup.Top().Atoms());
  // Setup Symmetric RMSD calc (target mask, symmetric atoms etc)
  if (SRMSD_.SetupSymmRMSD( setup.Top(), tgtMask_, remap_ )) return Action::ERR;
  if (remap_) {
    // Allocate space for remapped frame; same # atoms as original frame
    remapFrame_.SetupFrameV( setup.Top().Atoms(), setup.CoordInfo() );
    targetMap_.resize( setup.Top().Natom() );
  }
  // Reference frame setup
  if (REF_.SetupRef(setup.Top(), tgtMask_.Nselected(), "symmrmsd"))
    return Action::ERR;
  return Action::OK;
}
Example #30
0
/** Called every time the trajectory changes. Set up FrameMask for the new 
  * parmtop and allocate space for selected atoms from the Frame.
  */
Action::RetType Action_Rmsd::Setup(ActionSetup& setup) {
  // Target setup
  if ( setup.Top().SetupIntegerMask( tgtMask_ ) ) return Action::ERR;
  mprintf("\tTarget mask:");
  tgtMask_.BriefMaskInfo();
  mprintf("\n");
  if ( tgtMask_.None() ) {
    mprintf("Warning: No atoms in mask '%s'.\n", tgtMask_.MaskString());
    return Action::SKIP;
  }
  // Allocate space for selected atoms in the frame. This will also put the
  // correct masses in based on the mask.
  tgtFrame_.SetupFrameFromMask(tgtMask_, setup.Top().Atoms());
  // Reference setup
  if (REF_.SetupRef(setup.Top(), tgtMask_.Nselected(), "rmsd"))
    return Action::SKIP;
 
  // Per residue rmsd setup
  if (perres_) {
    // If RefParm is still NULL probably 'first', set now.
    if (RefParm_ == 0)
      RefParm_ = setup.TopAddress();
    int err = perResSetup(setup.Top(), *RefParm_);
    if      (err == 1) return Action::SKIP;
    else if (err == 2) return Action::ERR;
  }

  // Warn if PBC and rotating
  if (rotate_ && setup.CoordInfo().TrajBox().Type() != Box::NOBOX) {
    mprintf("Warning: Coordinates are being rotated and box coordinates are present.\n"
            "Warning: Unit cell vectors are NOT rotated; imaging will not be possible\n"
            "Warning:  after the RMS-fit is performed.\n");
  }

  return Action::OK;
}