Example #1
0
void ASENSOR_DAQFT_FT( ASENSOR *asensor, matrix &f, matrix &t )
{
matrix D;

    asensor->CurrentValues(D);
    
    matrix_dim(f,AXIS_XYZ,1);
    f(1,1) = D(1,1);
    f(2,1) = D(2,1);
    f(3,1) = D(3,1);

    matrix_dim(t,AXIS_XYZ,1);
    t(1,1) = D(4,1);
    t(2,1) = D(5,1);
    t(3,1) = D(6,1);
}
int Action_NativeContacts::DetermineNativeContacts(Topology const& parmIn, Frame const& fIn)
#endif
{
# ifdef MPI
  Frame fIn = frameIn;
  if (trajComm_.Size() > 1) {
    // Ensure all threads use same reference
    if (trajComm_.Master())
      for (int rank = 1; rank < trajComm_.Size(); rank++)
        fIn.SendFrame( rank, trajComm_ );
    else
      fIn.RecvFrame( 0, trajComm_ );
  }
# endif
  if (pfile_ != 0 || nfile_ != 0) {
    refFrame_ = fIn; // Save frame for later PDB output.
    refParm_ = &parmIn;  // Save parm for later PDB output.
  }
  if ( SetupContactLists(parmIn, fIn) ) return 1;
  // If specified, set up contacts maps; base size on atom masks.
  if (nativeMap_ != 0) {
    int matrix_max;
    if (Mask2_.MaskStringSet()) {
      matrix_min_ = std::min( Mask1_[0], Mask2_[0] );
      matrix_max = std::max( Mask1_.back(), Mask2_.back() );
    } else {
      matrix_min_ = Mask1_[0];
      matrix_max = Mask1_.back();
    }
    std::string label("Atom");
    if (byResidue_) {
      matrix_min_ = parmIn[matrix_min_].ResNum();
      matrix_max = parmIn[matrix_max].ResNum();
      label.assign("Residue");
    }
    int matrix_cols = matrix_max - matrix_min_ + 1;
    if (nativeMap_->AllocateHalf( matrix_cols )) return 1;
    if (nonnatMap_->AllocateHalf( matrix_cols )) return 1;
    Dimension matrix_dim( matrix_min_+1, 1, label );
    nativeMap_->SetDim(Dimension::X, matrix_dim);
    nativeMap_->SetDim(Dimension::Y, matrix_dim);
    nonnatMap_->SetDim(Dimension::X, matrix_dim);
    nonnatMap_->SetDim(Dimension::Y, matrix_dim);
  }
  double maxDist2 = 0.0;
  double minDist2 = DBL_MAX;
  nativeContacts_.clear();
  std::pair<contactListType::iterator, bool> ret;
  if (determineNativeContacts_) {
    if ( Mask2_.MaskStringSet() ) {
      for (AtomMask::const_iterator c1 = Mask1_.begin(); c1 != Mask1_.end(); ++c1)
        for (AtomMask::const_iterator c2 = Mask2_.begin(); c2 != Mask2_.end(); ++c2)
        {
          SetNativeContact();
        }
    } else {
      for (AtomMask::const_iterator c1 = Mask1_.begin(); c1 != Mask1_.end(); ++c1)
        for (AtomMask::const_iterator c2 = c1 + 1; c2 != Mask1_.end(); ++c2)
        {
          SetNativeContact();
        }
    }
  }
  //mprintf("\tMinimum observed distance= %f, maximum observed distance= %f\n",
  //        sqrt(minDist2), sqrt(maxDist2));
  // Print contacts
  mprintf("\tSetup %zu native contacts:\n", nativeContacts_.size());
  for (contactListType::const_iterator contact = nativeContacts_.begin();
                                       contact != nativeContacts_.end(); ++contact)
  {
    int a1 = contact->first.first;
    int a2 = contact->first.second;
    mprintf("\t\tAtom '%s' to '%s'\n", parmIn.AtomMaskName(a1).c_str(),
            parmIn.AtomMaskName(a2).c_str());
  }
  return 0;  
}