Esempio n. 1
0
  void IDFilter::filterIdentificationsByBestHits(const PeptideIdentification& identification,
                                                 PeptideIdentification& filtered_identification,
                                                 bool strict)
  {
    vector<PeptideHit> filtered_peptide_hits;
    PeptideHit temp_peptide_hit;
    vector<Size> new_peptide_indices;

    filtered_identification = identification;
    filtered_identification.setHits(vector<PeptideHit>());

    if (!identification.getHits().empty())
    {
      Real optimal_value = identification.getHits()[0].getScore();
      new_peptide_indices.push_back(0);

      // searching for peptide(s) with maximal score
      for (Size i = 1; i < identification.getHits().size(); i++)
      {
        Real temp_score = identification.getHits()[i].getScore();
        bool new_leader = false;
        if ((identification.isHigherScoreBetter() && (temp_score > optimal_value))
           || (!identification.isHigherScoreBetter() && (temp_score < optimal_value)))
          new_leader = true;

        if (new_leader)
        {
          optimal_value = temp_score;
          new_peptide_indices.clear();
          new_peptide_indices.push_back(i);
        }
        else if (temp_score == optimal_value)
        {
          new_peptide_indices.push_back(i);
        }
      }
      if (!strict || new_peptide_indices.size() == 1)
      {
        for (Size i = 0; i < new_peptide_indices.size(); i++)
        {
          filtered_peptide_hits.push_back(identification.getHits()[new_peptide_indices[i]]);
        }
      }
    }

    if (!filtered_peptide_hits.empty())
    {
      filtered_identification.setHits(filtered_peptide_hits);
      filtered_identification.assignRanks();
    }
  }
  // list of peptide hits in "peptide" will be sorted
  bool MapAlignmentAlgorithmIdentification::hasGoodHit_(PeptideIdentification &
                                                        peptide)
  {
    if (peptide.empty() || peptide.getHits().empty())
      return false;

    peptide.sort();
    DoubleReal score = peptide.getHits().begin()->getScore();
    if (peptide.isHigherScoreBetter())
      return score >= score_threshold_;

    return score <= score_threshold_;
  }