Beispiel #1
0
// returns number of peaks that were stored
int	PeakList::readPeaksToLocalAllocation(const SpectraAggregator& sa,
        const SingleSpectrumHeader* header)
{
    // create a basic PeakList read function
    header_ = header;

    if (localAllocationSize_>0 && peaks_)
        delete [] peaks_;

    localAllocationSize_ = header->getOriginalNumPeaks();
    peaks_ = new Peak[localAllocationSize_];
    if (! peaks_)
    {
        cout << "Error: couldn't allocate memory for spectrum!" << endl;
        exit(1);
    }

    const int numPeaksRead = sa.readPeakList(header, peaks_);
    numPeaks_ = numPeaksRead;

    if (header->getFileType() != IFT_MZXML &&
            ( numPeaksRead != header->getOriginalNumPeaks() ||
              peaks_[0].mass != header->getFirstPeakMass()) )
    {
        cout << "Error reading scan " << header->getScanNumber() << ": " << header_->getTitle()
             << " in file " << sa.getSpectraFile(header_->getSpectraFileIndexInList()).getFilePath() << endl;
        if (numPeaksRead != header->getOriginalNumPeaks())
            cout << "Num peaks read " << numPeaksRead << ", expecting " <<  header->getScanNumber() << endl;
        if (peaks_[0].mass != header->getFirstPeakMass())
            cout << setprecision(5) << "First peak mass " << peaks_[0].mass
                 <<", expecting " << header->getFirstPeakMass() << endl;
        cout << "Could possibly be a dos/unix problem with the files, try running dos2unix (or unix2dos)..." << endl;
        cout <<"Skipping spectrum..." << endl;

        const int numPeaksRead = sa.readPeakList(header, peaks_);

        return 0;
    }

    return numPeaks_;
}
Beispiel #2
0
// function assumes that the buffer is sufficently large for all peaks being read
// returns number of peaks that were stored
int	PeakList::readPeaksToBuffer(const SpectraAggregator& sa,
                                const SingleSpectrumHeader* header,
                                Peak*	peakBuffer)
{
    // create a basic PeakList read function
    header_ = header;

    if (localAllocationSize_>0 && peaks_)
        delete [] peaks_;

    localAllocationSize_ = 0;

    peaks_ = peakBuffer;
    const int numPeaksRead = sa.readPeakList(header, peaks_);
    numPeaks_ = numPeaksRead;

    return numPeaks_;
}