Beispiel #1
0
void SSfind::prep_search( const clipper::Xmap<float>& xmap, const double rhocut, const double radcut, const clipper::Coord_orth centre )
{
  // make list of results
  typedef clipper::Xmap<float>::Map_reference_index MRI;
  srctrn.clear();
  double r2cut = ( radcut > 0.0 ) ? radcut*radcut : 1.0e20;
  clipper::Coord_frac cf = centre.coord_frac( xmap.cell() );
  for ( MRI ix = xmap.first(); !ix.last(); ix.next() )
    if ( xmap[ix] > rhocut ) {
      clipper::Coord_frac df = ix.coord().coord_frac( xmap.grid_sampling() );
      df = df.symmetry_copy_near( xmap.spacegroup(), xmap.cell(), cf ) - cf;
      double r2 = df.lengthsq( xmap.cell() );
      if ( r2 < r2cut )
	srctrn.push_back( grid.index( ix.coord() ) );
    }
}
Beispiel #2
0
void SSfind::prep_xmap( const clipper::Xmap<float>& xmap, const double radius )
{
  // make a 1-d array of gridded density values covering ASU+border
  grid = xmap.grid_sampling();
  grrot = xmap.operator_orth_grid().rot();
  clipper::Grid_range gr0 = xmap.grid_asu();
  clipper::Grid_range gr1( xmap.cell(), xmap.grid_sampling(), radius );
  mxgr = clipper::Grid_range( gr0.min()+gr1.min(), gr0.max()+gr1.max() );
  mapbox = std::vector<float>( mxgr.size(), 0.0 );

  // make 1d list of densities
  clipper::Xmap<float>::Map_reference_index ix( xmap );
  for ( int i = 0; i < mapbox.size(); i++ ) {
    ix.set_coord( mxgr.deindex( i ) );
    mapbox[i] = xmap[ix];
  }
}
Beispiel #3
0
/* \return The negative of the correlation */
clipper::ftype LLK_map_target::Sampled::correl( const clipper::Xmap<float>& xmap, const clipper::RTop_orth& rtop ) const {
  clipper::ftype x, y, w, sw, swx, swy, swxx, swyy, swxy;
  sw = swx = swy = swxx = swyy = swxy = 0.0;
  for ( int i = 0; i < repxyz.size(); i++ ) {
    w = repwgt[i];
    x = reptgt[i];
    y = xmap.interp<clipper::Interp_linear>( (rtop*repxyz[i]).coord_frac(xmap.cell()) );
    sw   += w;
    swx  += w * x;
    swy  += w * y;
    swxx += w * x * x;
    swyy += w * y * y;
    swxy += w * x * y;
  }
  return -( sw*swxy - swx*swy ) / sqrt( clipper::Util::max(
      ( sw*swxx - swx*swx ) * ( sw*swyy - swy*swy ), 1.0e-20 ) );
}
Beispiel #4
0
/*! A log-likelihood FFFear search is performed for the target in the given map.
  \param resultscr The best scores.
  \param resultrot The best rotations.
  \param resulttrn The best translations.
  \param xmap The map to search.
  \param rtops The oprientations to search. */
void LLK_map_target::search( clipper::Xmap<float>& resultscr, clipper::Xmap<int>& resultrot, clipper::Xmap<int>& resulttrn, const clipper::Xmap<float>& xmap, const std::vector<clipper::RTop_orth>& rtops ) const
{
  // set up results
  const clipper::Spacegroup&    spgr = xmap.spacegroup();
  const clipper::Cell&          cell = xmap.cell();
  const clipper::Grid_sampling& grid = xmap.grid_sampling();
  resultscr.init( spgr, cell, grid );
  resultrot.init( spgr, cell, grid );
  resulttrn.init( spgr, cell, grid );
  resultscr = 1.0e20;

  // now search for ML target in each orientation in turn
  clipper::Xmap<float> resultp1( clipper::Spacegroup::p1(), cell, grid );
  clipper::Xmap<float>::Map_reference_index i1(resultp1);
  clipper::Xmap<float>::Map_reference_coord ix(resultscr);

  // set up z scoring
  clipper::FFFear_fft<float> srch( xmap );
  clipper::NX_operator nxop( xmap, target, rtops[0] );
  srch( resultp1, target, weight, nxop );
  clipper::Map_stats zstats( resultp1 );

  // loop over orientations
  for ( int op = 0; op < rtops.size(); op++ ) {
    // do the fffear search
    clipper::NX_operator nxop( xmap, target, rtops[op].inverse() );
    srch( resultp1, target, weight, nxop );

    // store best scores
    for ( i1 = resultp1.first(); !i1.last(); i1.next() ) {
      ix.set_coord( i1.coord() );
      float score = ( resultp1[i1] - zstats.mean() ) / zstats.std_dev();
      if ( score < resultscr[ix] ) {
	resultscr[ix] = score;
	resultrot[ix] = op;
	resulttrn[ix] = grid.index( i1.coord() );
      }
    }
  }
}
Beispiel #5
0
/*! Accumulate the statistics for a log-likelihood target using a known
  map and operator maping into that map. After accumulation is
  completed, you must call prep_llk().
  \param xmap The known map from which to accumulate density statistics.
  \param rtop The operator from the target map at the origin into the xmap. */
void LLK_map_target::accumulate( const clipper::Xmap<float>& xmap, const clipper::RTop_orth rtop )
{
  // aliases for maps
  clipper::NXmap<float>& mrho = target;
  clipper::NXmap<float>& mrho2 = weight;

  // zero maps if necessary
  if ( naccum == 0.0 ) target = weight = float(0.0);
  naccum++;

  // accumulate stats
  clipper::ftype extentsq =
    pow( mrho.operator_grid_orth().rot()(0,0) * (mrho.grid().nu()-1)/2, 2 );
  clipper::NXmap_base::Map_reference_index ix;
  float rho;
  for ( ix = mrho.first(); !ix.last(); ix.next() )
    if ( ix.coord_orth().lengthsq() <= extentsq ) {
      rho = xmap.interp<clipper::Interp_cubic>( (rtop*ix.coord_orth()).coord_frac(xmap.cell()) );
      mrho[ix]  += rho;
      mrho2[ix] += rho*rho;
    }
}
Beispiel #6
0
/* \return The log likelihood */
clipper::ftype LLK_map_target::Sampled::llk( const clipper::Xmap<float>& xmap, const clipper::RTop_orth& rtop ) const {
  clipper::ftype r( 0.0 ), s( 0.0 );
  for ( int i = 0; i < repxyz.size(); i++ ) {
    r += repwgt[i] * pow( xmap.interp<clipper::Interp_linear>( (rtop*repxyz[i]).coord_frac(xmap.cell()) ) - reptgt[i], 2 );
    s += repwgt[i];
  }
  return r/s;
}
Beispiel #7
0
/*! Search from scratch.

  Combined search, scoring and sorting of fragments. This version is
  for general use.

  \param frag The fragment to search for.
  \param nfrag The maximum  number of fragments to return
  \param xmap The electron density map for scoring models.
  \param coords The coordinates of the model for use in clash scoring.
  \param wdense (optional) weight for the density score
  \param wclash (optional) weight for the clash score
  \param sig1 (optional) the sigma offset for density scores
  \param sig2 (optional) the sigma weight for density scores
  \param clashrad (optional) the radius for clash penalties
  \return A vector of chains, with the first chain representing the best score.
*/
  std::vector<Chain> ProteinDBSearch::search( const Chain& frag, const int nfrag, const clipper::Xmap<float>& xmap, const std::vector<clipper::Coord_orth>& coords, double wdense, double wclash, double sig1, double sig2, double clashrad )
{
  ScoreDensity score_rho( xmap, sig1, sig2 );
  ScoreClashes score_cls( coords, xmap.spacegroup(), xmap.cell(), clashrad );
  return search( frag, nfrag, score_rho, score_cls, wdense, wclash );
}