Example #1
0
// static
bool
mslock::findReferences( mslock& lk,  const adcontrols::MassSpectrum& ms, int idx, int fcn )
{
    static ChemicalFormula formulaParser;

    if ( idx < 0 || fcn < 0 )
        return false;

    adcontrols::segment_wrapper< const adcontrols::MassSpectrum > segs( ms );
    if ( size_t(fcn) >= segs.size() )
        return false;

    auto& annots = segs[ fcn ].get_annotations();

    auto it = std::find_if( annots.begin(), annots.end(), [=]( const adcontrols::annotation& a ){ return a.index() == idx; });
    if ( it != annots.end() ) {
        const std::string& formula = it->text();
        auto list = adcontrols::ChemicalFormula::split( formula );
        double exactMass = formulaParser.getMonoIsotopicMass( list );
        double matchedMass = segs[ fcn ].getMass( it->index() );
        double time        = segs[ fcn ].getTime( it->index() );
        lk << reference( formula, exactMass, matchedMass, time );        

        return true;
    }
    return false;
}
Example #2
0
void
MSReference::impl::compute_mass()
{
    ChemicalFormula formula;
    exactMass_ = formula.getMonoIsotopicMass( formula_ );

    if ( ! adduct_or_loss_.empty() ) {
        auto adductlist = adcontrols::ChemicalFormula::split( adportable::utf::to_utf8( adduct_or_loss_ ) );
        exactMass_ += adcontrols::ChemicalFormula().getMonoIsotopicMass( adductlist );
    }
}
Example #3
0
void
MSReference::impl::compute_mass()
{
    ChemicalFormula formula;
    exactMass_ = formula.getMonoIsotopicMass( formula_ );
    if ( ! adduct_or_loss_.empty() ) {
        std::wstring::size_type sign = adduct_or_loss_.find_first_of( L"+-" );
        if ( sign != std::wstring::npos && adduct_or_loss_[ sign ] == L'-' ) {
            double lose = formula.getMonoIsotopicMass( adduct_or_loss_.substr( sign ) );
            exactMass_ -= lose;
        } else {
            double adduct = formula.getMonoIsotopicMass( adduct_or_loss_ );
            exactMass_ += adduct;
        }
        // handle electron mass
        // if ( polarityPositive_ ) subtract electron
    }
}
Example #4
0
// static
bool
mslock::findReferences( mslock& lk,  const adcontrols::MassSpectrum& ms )
{
    static ChemicalFormula formulaParser;

    lk.clear();
    adcontrols::segment_wrapper< const adcontrols::MassSpectrum > segs( ms );
    for ( auto& fms: segs ) {
        for ( const auto& a: fms.get_annotations() ) {
            if ( a.dataFormat() == annotation::dataFormula && a.index() >= 0 ) {
                const std::string& formula = a.text();
                double exactMass = formulaParser.getMonoIsotopicMass( formula );
                double matchedMass = fms.getMass( a.index() );
                double time = fms.getTime( a.index() );
                lk << reference( formula, exactMass, matchedMass, time );
            }
        }
    }
    return true;
}