Ejemplo n.º 1
0
void rt_fast::scan()
{
  aproc_TimeStamp( scantime(), 5);

  for ( int i = 0; i < (int) objects.size(); i++)
    objects[i]->scan();
}
Ejemplo n.º 2
0
void rt_post::scan()
{
  pwr_tStatus sts = 1;

  while (ODD(sts))
    sts = mh_OutunitReceive();

  aproc_TimeStamp( scantime(), 5);
}
Ejemplo n.º 3
0
void rt_sysmon::scan()
{
  pwr_tStatus osts, sts;
  errh_eSeverity severity, oseverity;

  aproc_TimeStamp( scantime(), 5);

  // Find most severe status
  sts = PWR__SRUN;
  severity = errh_Severity( sts);
  for ( int i = 0; i < (int) objects.size(); i++) {
    objects[i]->scan();
    osts = objects[i]->status();
    oseverity = errh_Severity( osts);
    if ( oseverity > severity) {
      sts = osts;
      severity = oseverity;
    }
  }
  errh_SetStatus( sts);
}
Ejemplo n.º 4
0
void ElutionPeakDetection::detectElutionPeaks_(MassTrace & mt, std::vector<MassTrace> & single_mtraces)
{
    std::vector<DoubleReal> rts, ints;

    for (MassTrace::const_iterator c_it = mt.begin(); c_it != mt.end(); ++c_it)
    {
        rts.push_back(c_it->getRT());
        ints.push_back(c_it->getIntensity());
    }

    std::vector<DoubleReal> smoothed_data;


    LowessSmoothing lowess_smooth;
    Param lowess_params;

    // use dynamically computed window sizes

    // Size win_size = mt.getFWHMScansNum();

    // use one global window size for all mass traces to smooth
    DoubleReal scan_time(mt.getScanTime());
    Size win_size = std::ceil(chrom_fwhm_ / scan_time);

    // std::cout << "win_size elution: " << scan_time << " " << win_size << std::endl;

    // if there is no previous FWHM estimation... do it now
    //    if (win_size == 0)
    //    {
    //        mt.estimateFWHM(false); // estimate FWHM
    //        win_size = mt.getFWHMScansNum();
    //    }

    lowess_params.setValue("window_size", win_size);
    lowess_smooth.setParameters(lowess_params);

    lowess_smooth.smoothData(rts, ints, smoothed_data);

    mt.setSmoothedIntensities(smoothed_data);

    // debug intensities

    // Size i = 0;

    //    std::cout << "*****" << std::endl;
    //    for (MassTrace::const_iterator mt_it = mt.begin(); mt_it != mt.end(); ++mt_it)
    //    {
    //        std::cout << mt_it->getIntensity() << " " << smoothed_data[i] << std::endl;
    //        ++i;
    //    }
    //std::cout << "*****" << std::endl;

    std::vector<Size> maxes, mins;

    // mt.findLocalExtrema(win_size / 2, maxes, mins);

    findLocalExtrema(mt, win_size/2, maxes, mins);

    // if only one maximum exists: finished!
    if (maxes.size() == 1)
    {
        bool pw_ok = true;
        bool snr_ok = true;

        // check mass trace filter criteria (if enabled)
        if (pw_filtering_ == "fixed")
        {
            DoubleReal act_fwhm(mt.estimateFWHM(true));

            // std::cout << "act_fwhm: " << act_fwhm << " ";

            if (act_fwhm < min_fwhm_ || act_fwhm > max_fwhm_)
            {
                pw_ok = false;
            }

            // std::cout << pw_ok << std::endl;
        }

        if (mt_snr_filtering_)
        {
            if (computeApexSNR(mt) < chrom_peak_snr_)
            {
                snr_ok = false;
            }
        }


        if (pw_ok && snr_ok)
        {
            mt.updateSmoothedMaxRT();

            if (pw_filtering_ != "fixed")
            {
                mt.estimateFWHM(true);
            }

            // check for minimum/maximum trace length
            //          DoubleReal mt_length(std::fabs(mt.rbegin()->getRT() - mt.begin()->getRT()));

            //        if ((mt_length >= min_trace_length_) && (mt_length <= max_trace_length_))
            // if (mt_quality >= 1.2)
            //      {
#ifdef _OPENMP
#pragma omp critical
#endif
            single_mtraces.push_back(mt);

        }
    }
    else if (maxes.empty())
    {
        return;
    }
    else // split mt to subtraces
    {
        MassTrace::const_iterator cp_it = mt.begin();
        Size last_idx(0);

        for (Size min_idx = 0; min_idx < mins.size(); ++min_idx)
        {
            // copy subtrace between cp_it and splitpoint
            std::vector<PeakType> tmp_mt;
            std::vector<DoubleReal> smoothed_tmp;

            while (last_idx <= mins[min_idx])
            {
                tmp_mt.push_back(*cp_it);
                smoothed_tmp.push_back(mt.getSmoothedIntensities()[last_idx]);
                ++cp_it;
                ++last_idx;
            }

            // check if

//            if (tmp_mt.size() >= win_size / 2)
//            {
                DoubleReal scantime(mt.getScanTime());
                MassTrace new_mt(tmp_mt, scantime);

                // copy smoothed ints
                new_mt.setSmoothedIntensities(smoothed_tmp);


                // check filter criteria
                bool pw_ok = true;
                bool snr_ok = true;

                // check mass trace filter criteria (if enabled)
                if (pw_filtering_ == "fixed")
                {
                    DoubleReal act_fwhm(new_mt.estimateFWHM(true));

                    // std::cout << "act_fwhm: " << act_fwhm << " ";

                    if (act_fwhm < min_fwhm_ || act_fwhm > max_fwhm_)
                    {
                        pw_ok = false;
                    }

                    // std::cout << pw_ok << std::endl;
                }

                if (mt_snr_filtering_)
                {
                    if (computeApexSNR(mt) < chrom_peak_snr_)
                    {
                        snr_ok = false;
                    }
                }


                if (pw_ok && snr_ok)
                {

                    // set label of subtrace
                    String tr_num;
                    std::stringstream read_in;
                    read_in << (min_idx + 1);
                    tr_num = "." + read_in.str();

                    new_mt.setLabel(mt.getLabel() + tr_num);
                    //new_mt.updateWeightedMeanRT();
                    new_mt.updateSmoothedMaxRT();
                    //new_mt.updateSmoothedWeightedMeanRT();
                    new_mt.updateWeightedMeanMZ();
                    new_mt.updateWeightedMZsd();

                    if (pw_filtering_ != "fixed")
                    {
                        new_mt.estimateFWHM(true);
                    }
                    // DoubleReal mt_quality(computeApexSNR(new_mt));

                    // DoubleReal new_mt_length(std::fabs(new_mt.rbegin()->getRT() - new_mt.begin()->getRT()));

                    // if ((new_mt_length >= min_trace_length_) && (new_mt_length <= max_trace_length_))
                    //{
#ifdef _OPENMP
#pragma omp critical
#endif
                    single_mtraces.push_back(new_mt);
                }
          //  }
        }

        // don't forget the trailing trace
        std::vector<PeakType> tmp_mt;

        std::vector<DoubleReal> smoothed_tmp;

        while (last_idx < mt.getSize())
        {
            tmp_mt.push_back(*cp_it);
            smoothed_tmp.push_back(mt.getSmoothedIntensities()[last_idx]);
            ++cp_it;
            ++last_idx;
        }

//        if (tmp_mt.size() >= win_size / 2)
//        {
            DoubleReal scantime(mt.getScanTime());
            MassTrace new_mt(tmp_mt, scantime);

            // copy smoothed ints
            new_mt.setSmoothedIntensities(smoothed_tmp);

            // check filter criteria
            bool pw_ok = true;
            bool snr_ok = true;

            // check mass trace filter criteria (if enabled)
            if (pw_filtering_ == "fixed")
            {
                DoubleReal act_fwhm(new_mt.estimateFWHM(true));

                // std::cout << "act_fwhm: " << act_fwhm << " ";

                if (act_fwhm < min_fwhm_ || act_fwhm > max_fwhm_)
                {
                    pw_ok = false;
                }

                // std::cout << pw_ok << std::endl;
            }

            if (mt_snr_filtering_)
            {
                if (computeApexSNR(mt) < chrom_peak_snr_)
                {
                    snr_ok = false;
                }
            }


            if (pw_ok && snr_ok)
            {
                // set label of subtrace
                String tr_num;
                std::stringstream read_in;
                read_in << (mins.size() + 1);
                tr_num = "." + read_in.str();

                new_mt.setLabel(mt.getLabel() + tr_num);
                new_mt.updateSmoothedMaxRT();
                new_mt.updateWeightedMeanMZ();
                new_mt.updateWeightedMZsd();

                if (pw_filtering_ != "fixed")
                {
                    new_mt.estimateFWHM(true);
                }
                // DoubleReal mt_quality(computeApexSNR(new_mt));

                //                DoubleReal mt_length(std::fabs(new_mt.rbegin()->getRT() - new_mt.begin()->getRT()));

                //                if ((mt_length >= min_trace_length_) && (mt_length <= max_trace_length_))
                //                {
#ifdef _OPENMP
#pragma omp critical
#endif
                single_mtraces.push_back(new_mt);
            }
     //   }
    }
    return;
}