Ejemplo n.º 1
0
bool
fitter::operator()( MassSpectrum& ms ) const
{
    if ( coeffs_.empty() )
        return false;
    
    const double * masses = ms.getMassArray();

    if ( coeffs_.size() == 1 ) {
        // relative error correction
        for ( size_t i = 0; i < ms.size(); ++i ) {
            double mass = masses[ i ] - masses[ i ] * coeffs_[ 0 ];
            ms.setMass( i, mass );
        }

    } else {

        for ( size_t i = 0; i < ms.size(); ++i ) {
            double mass = masses[i] - adportable::polfit::estimate_y( coeffs_, masses[ i ] );
            ms.setMass( i, mass );
        }

    }

	return true;
}
Ejemplo n.º 2
0
bool
Targeting::find_candidate( const MassSpectrum& ms, int fcn, bool polarity_positive, const std::vector< charge_adduct_type >& list )
{
    double tolerance = (method_) ? method_->tolerance( method_->toleranceMethod() ) : 0.010;

    detail::target_finder< const double * > finder( ms.getMassArray(), ms.getMassArray() + ms.size(), tolerance );

    for ( auto& formula : active_formula_ ) {
        double target_mass = formula.second; // search 'M'
        if ( finder( target_mass ) )
            candidates_.push_back( Candidate( uint32_t( finder.pos_.second /*idx*/), fcn, 1/*charge*/, finder.pos_.first /*error*/, formula.first /*formula*/ ) );
    }

    (void)polarity_positive; // this will be necessary for account an electron mass, todo
    for ( auto& adduct : list ) {
        for ( auto& formula : active_formula_ ) {
            double target_mass = (formula.second /* M */ + std::get<0>( adduct /*mass*/ )) / std::get<2>( adduct /*charge*/ );
            if ( finder( target_mass ) )
                candidates_.push_back( Candidate( uint32_t( finder.pos_.second ), fcn, std::get<2>( adduct ), finder.pos_.first, formula.first + "+" + std::get<1>( adduct ) ) );
        }
    }
    return true;
}