Ejemplo n.º 1
0
 permutations_iterator<T>& permutations_iterator<T>::operator++()
 {
     if(_size!=pool.size())
     {
         // Slow path, the iterator is a "view" of a prefix smaller
         // than the the pool size
         // FIXME a better implementation would be to avoid
         // std::next_permutation, but only in the slow path
         types::list<int> prev_permut(curr_permut.begin(), curr_permut.begin()+_size);
         types::list<int> new_permut;
         while((end = std::next_permutation(curr_permut.begin(), curr_permut.end())))
         {
             // Check if the prefix of the new permutation is
             // different of the previous one
             types::list<int> new_permut(curr_permut.begin(), curr_permut.begin()+_size);
             if(!(prev_permut==new_permut))
                 break;
         }
     } else
         end = std::next_permutation(curr_permut.begin(), curr_permut.end());
     return *this;
 }
Ejemplo n.º 2
0
void CompNovoIdentificationCID::reducePermuts_(set<String> & permuts, const PeakSpectrum & CID_spec, double prefix, double suffix)
{
    if (permuts.size() < max_subscore_number_)
    {
        return;
    }

    vector<Permut> score_permuts;

    Size i(0);
    for (set<String>::const_iterator it = permuts.begin(); it != permuts.end(); ++it, ++i)
    {
#ifdef REDUCE_PERMUTS_DEBUG
        if (i % 1000 == 0)
        {
            cerr << (double)i / permuts.size() * 100 << "%" << endl;
        }
#endif

        PeakSpectrum CID_sim_spec;
        getCIDSpectrumLight_(CID_sim_spec, *it, prefix, suffix);
        //getCIDSpectrum_(CID_sim_spec, *it, 1, prefix, suffix);

        double score = zhang_(CID_sim_spec, CID_spec);

        if (boost::math::isnan(score))
        {
            score = 0;
        }

        score /= it->size();

        if (boost::math::isnan(score))
        {
            score = 0;
        }


#ifdef REDUCE_PERMUTS_DEBUG
        cerr << "Subscoring: " << *it << " " << cid_score << " (CID=";
        /*      for (PeakSpectrum::ConstIterator pit = CID_sim_spec.begin(); pit != CID_sim_spec.end(); ++pit)
                {
                cerr << pit->getPosition()[0] << "|" << pit->getIntensity() << "; ";
                }*/
        cerr << endl;
#endif

        Permut new_permut(it, score);
        score_permuts.push_back(new_permut);
    }

    sort(score_permuts.begin(), score_permuts.end(), Internal::PermutScoreComparator);

    set<String> new_permuts;
    Size count(0);
    for (vector<Permut>::const_iterator it = score_permuts.begin(); it != score_permuts.end() && count < max_subscore_number_; ++it, ++count)
    {
        new_permuts.insert(*it->getPermut());
#ifdef REDUCE_PERMUTS_DEBUG
        cerr << "Subscore winner: " << it->getPermut() << " " << it->getScore() << endl;
#endif
    }

    permuts = new_permuts;
    return;
}