Exemplo n.º 1
0
void Pipeline::run()
{
    while (!pipelineQueue_.empty()) {
        Request tempReq = requestQueue_.front();
        std::string tempStr;
        if (Pipeline::getTraceFlag()) {
            if (tempReq.getType() == libpipe::Request::UPDATE) {
                tempStr = "Starting Update Request";
            } else if (tempReq.getType() == libpipe::Request::DELETE) {
                tempStr = "Starting Delete Request";
            }
        }

        LIBPIPE_PIPELINE_TRACE(tempStr);
#ifdef ENABLE_THREADING
        boost::exception_ptr error;
        pipelineQueue_.front()->processThreadedRequest(tempReq, error);
        if (error) {
            boost::rethrow_exception(error);
        }
#else

        pipelineQueue_.front()->processRequest(tempReq);
#endif

        pipelineQueue_.pop();
        requestQueue_.pop();
    }
}
    void update(libpipe::Request& req)
    {

        boost::shared_ptr<libpipe::rtc::SharedData<mgf::MgfFile> > mgfInputFile =
            boost::dynamic_pointer_cast<
            libpipe::rtc::SharedData<mgf::MgfFile> >(
                this->getPort("MGFInputFile"));
        boost::shared_ptr<libpipe::rtc::SharedData<mgf::MgfFile> > mgfParsedFile =
            boost::dynamic_pointer_cast<
            libpipe::rtc::SharedData<mgf::MgfFile> >(
                this->getPort("MGFParsedFile"));
        LIBPIPE_PIPELINE_TRACE(req, "Starting TopXInYRegions");

        mgfInputFile->shared_lock();
        mgfParsedFile->lock();
        // copy the file so that input is not changed.
        mgfParsedFile->set(new mgf::MgfFile(*mgfInputFile->get()));
        mgfInputFile->unlock();

        // Top X in Y regions

        for (mgf::MgfFile::iterator i = mgfParsedFile->get()->begin();
                i != mgfParsedFile->get()->end(); ++i) {
            // get a temporary object and make sure it is big enough
            mgf::MgfSpectrum m;
            m.resize(2 * i->size());
            // get the top X in Y regions, including duplicated from overlaps
            mgf::MgfSpectrum::iterator sEnd = run(i->begin(), i->end(),
                                                  m.begin(), LessThanMass(), LessThanAbundance());
            // make sure we have enough space in the original object
            i->resize(std::distance(m.begin(), sEnd));
            // unique copy expectes a sorted range
            std::sort(m.begin(), sEnd, LessThanMass());
            // copy all unique peaks back into the original MgfSpectrum
            mgf::MgfSpectrum::iterator iEnd = std::unique_copy(m.begin(),
                                              sEnd, i->begin());
            // crop to fit
            i->resize(std::distance(i->begin(), iEnd));
        }

        mgfParsedFile->unlock();

        LIBPIPE_PIPELINE_TRACE(req, "TopXInYRegions is finished");

    }