Skip to content

Commit

Permalink
Fixed minor issues with differences in consensus output
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewThe committed Apr 27, 2018
1 parent 79996a5 commit f31bd9b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.05
* Fixed several minor issues with race conditions resulting in differing consensus outputs
* Fixed problem with high memory usage in poisoned p-value clustering

v0.04.1
* Fixes consensus spectra merger with multiple bins

v0.04
* Fixed mzML issues with consensus spectra not retaining experiment configurations (#12)
* Added 'spectrum=123' as third option to detect scan numbers (#12)
Expand Down
4 changes: 2 additions & 2 deletions CommonCMake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ set(CMAKE_MODULE_PATH ${MARACLUSTER_SOURCE_DIR}/cmake)

# VERSION AND NAMESPACES
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "04")
set(CPACK_PACKAGE_VERSION_PATCH "1")
set(CPACK_PACKAGE_VERSION_MINOR "05")
set(CPACK_PACKAGE_VERSION_PATCH "0")

# UPDATE PATCH VERSION FOR INTERMEDIATE BUILDS
INCLUDE(VersionGen)
Expand Down
34 changes: 21 additions & 13 deletions src/MSFileMerger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,23 +331,25 @@ void MSFileMerger::splitSpecFilesByConsensusSpec(
}
int startFileIdx = batchNr*numMSFilePtrsPerBatch_;
int endFileIdx = (std::min)((batchNr+1)*numMSFilePtrsPerBatch_, fileList_.size());
std::vector<MSDataPtr> msDataPtrs;
std::vector<MSDataPtr> msDataPtrs(endFileIdx - startFileIdx);
int removeIdx = -1;
#pragma omp parallel for schedule(dynamic, 1)
for (int i = startFileIdx; i < endFileIdx; ++i) {
std::string filePath = fileList_.getFilePath(i);
if (filePath == spectrumOutFN_) continue;
if (filePath == spectrumOutFN_) {
removeIdx = i - startFileIdx;
continue;
}
std::cerr << "Splitting " << filePath
<< " (" << i*100 / (fileList_.size()-1) << "%)" << std::endl;

SpectrumListPtr sl;
MSReaderList readerList;
MSDataFile msd(filePath, &readerList);
#pragma omp critical (merge_meta_vector)
{
msDataPtrs.push_back(MSDataPtr(new MSDataFile(filePath, &readerList)));
sl = msDataPtrs.back()->run.spectrumListPtr;
msDataPtrs.back()->run.spectrumListPtr = SpectrumListSimplePtr(new SpectrumListSimple);
}
msDataPtrs.at(i - startFileIdx) = MSDataPtr(new MSDataFile(filePath, &readerList));
SpectrumListPtr sl = msDataPtrs.at(i - startFileIdx)->run.spectrumListPtr;

/* use a skeleton (i.e. without spectra data) in the msDatPtrs vector */
msDataPtrs.at(i - startFileIdx)->run.spectrumListPtr = SpectrumListSimplePtr(new SpectrumListSimple);

std::vector<SpectrumListSimplePtr> spectrumLists(numClusterBins_);
for (size_t k = 0; k < numClusterBins_; ++k) {
spectrumLists[k] = SpectrumListSimplePtr(new SpectrumListSimple);
Expand Down Expand Up @@ -378,7 +380,11 @@ void MSFileMerger::splitSpecFilesByConsensusSpec(
}
}
}


if (removeIdx >= 0) {
msDataPtrs.erase(msDataPtrs.begin() + removeIdx);
}

writeClusterBins(batchNr, msDataPtrs, spectrumListsAcc);
}
std::cerr << "Finished splitting ms2 files" << std::endl;
Expand Down Expand Up @@ -418,7 +424,9 @@ void MSFileMerger::mergeSplitSpecFiles() {

SpectrumListSimplePtr writeSpectra(new SpectrumListSimple);
writeSpectra->dp = dpPtr;


std::sort(mergedSpectra->spectra.begin(), mergedSpectra->spectra.end(), SpectrumHandler::lessScannr);

size_t idx = 0;
BOOST_FOREACH (SpectrumPtr& s, mergedSpectra->spectra) {
s->index = idx;
Expand Down Expand Up @@ -511,7 +519,7 @@ void MSFileMerger::writeClusterBins(unsigned int batchIdx,
if (spectrumLists[i]->spectra.size() == 0) {
continue; // in case there are so few spectra that not all bins are filled
}

size_t idx = 0;
BOOST_FOREACH (SpectrumPtr& s, spectrumLists[i]->spectra) {
s->index = idx++;
Expand Down
6 changes: 4 additions & 2 deletions src/SpectrumHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ const double PROTON_MASS = 1.00727646677;
class SpectrumHandler {
public:
SpectrumHandler() {}
inline static bool lessMZ(const MZIntensityPair& a, const MZIntensityPair& b) { return (a.mz < b.mz); }
inline static bool lessMZ(const MZIntensityPair& a, const MZIntensityPair& b) { return (a.mz < b.mz) || (a.mz == b.mz && a.intensity < b.intensity); }
inline static bool greaterIntensity(const MZIntensityPair& a, const MZIntensityPair& b) { return (a.intensity > b.intensity); }
inline static bool greaterMultiplicity(const MZIntensityPair& a, const MZIntensityPair& b) {
return ( (a.multiplicity > b.multiplicity) || ( (a.multiplicity == b.multiplicity) && (a.intensity > b.intensity) ) );
}
inline static bool lessIntensity(const MZIntensityPair& a, const MZIntensityPair& b) { return (a.intensity < b.intensity); }

inline static bool lessScannr(pwiz::msdata::SpectrumPtr s1, pwiz::msdata::SpectrumPtr s2) { return getScannr(s1) < getScannr(s2); }

inline static double calcMass(double precMz, unsigned int charge) {
return precMz * charge - PROTON_MASS * (charge - 1);
}
Expand Down

0 comments on commit f31bd9b

Please sign in to comment.