Example #1
0
  double SimplePairFinder::similarity_(ConsensusFeature const & left, ConsensusFeature const & right) const
  {
    double right_intensity(right.getIntensity());
    if (right_intensity == 0)
      return 0;

    double intensity_ratio = left.getIntensity() / right_intensity;
    if (intensity_ratio > 1.)
      intensity_ratio = 1. / intensity_ratio;

    // if the right map is the transformed map, take the transformed right position
    DPosition<2> position_difference = left.getPosition() - right.getPosition();

    for (UInt dimension = 0; dimension < 2; ++dimension)
    {
      // the formula is explained in class doc
      if (position_difference[dimension] < 0)
      {
        position_difference[dimension] = -position_difference[dimension];
      }
      position_difference[dimension] *= diff_intercept_[dimension];
      position_difference[dimension] += 1.0;
      position_difference[dimension] = pow(position_difference[dimension], diff_exponent_[dimension]);
    }

    return intensity_ratio / position_difference[Peak2D::RT] / position_difference[Peak2D::MZ];
  }