Repository navigation
Conversation
| #------------------------------------------------------------------------------ | ||
| SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) | ||
|
|
||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -O1") |
| private: | ||
| std::vector<std::vector<PeptideIdentification>> peptide_ids; | ||
| }; | ||
| } No newline at end of file |
There was a problem hiding this comment.
| } | |
| } |
| } | |
| } | |
| void LayerData::updateCache_() | ||
| { | ||
| if (peak_map_->getNrSpectra() > current_spectrum_idx_ && (*peak_map_)[current_spectrum_idx_].size() > 0) | ||
| if (peak_map_->getNrSpectra() > current_spectrum_idx_ && (*peak_map_)[current_spectrum_idx_].first.size() > 0) |
There was a problem hiding this comment.
hmm not sure about the .first .second syntax.
| class PeptideIdentification; | ||
| class MSSpectrum; | ||
|
|
||
| class OPENMS_DLLAPI AnnotatedMSRawData : public MSExperiment |
There was a problem hiding this comment.
without inheritance might lead to a better design (but maybe some more changes)
e.g., one would need to write e.g. annot_ms_data.getMSExperiment()
| ~AnnotatedMSRawData() = default; | ||
|
|
||
| /// Get the peptide identifications for a single spectrum. | ||
| std::vector<PeptideIdentification>& getPeptideIds(); |
There was a problem hiding this comment.
size_t index probably missing
| return PairIterator(spectra_.cend(), peptide_ids.cend()); | ||
| } | ||
|
|
||
| inline Mapping operator[](size_t idx) |
There was a problem hiding this comment.
I kind of don't like the accession with .first .second that much as one always needs to remember what first and second is.
what would be the advantage for the user when he mainly writes something like:
annot_ms.getExperiment()[idx] or annot_ms.getIdentification()[idx]
but rarely needs both
There was a problem hiding this comment.
same concern here.
From what I see, the code will usually not compile anyway even if using inheritance, e.g.
spectrum.getPeptideIdentifications(); will fail. So we need to rewrite the callers anyway, which means we can go composition.
| /// Move constructor for efficiently loading a MSExperiment without a deep copy. | ||
| explicit AnnotatedMSRawData(MSExperiment&& experiment) : MSExperiment(std::move(experiment)) {}; | ||
| AnnotatedMSRawData(AnnotatedMSRawData&&) = default; | ||
| ~AnnotatedMSRawData() = default; |
There was a problem hiding this comment.
please add (and test) move assignment
| /// Get the peptide identifications for a single spectrum. | ||
| std::vector<PeptideIdentification>& getPeptideIds(); | ||
| /// Get all peptide identifications for all spectra. | ||
| std::vector<std::vector<PeptideIdentification>>& getAllPeptideIds(); |
There was a problem hiding this comment.
not sure about this function..
Its somewhat unclear how the indexing works (could be with gaps, i.e. the outer vector corresponds to the indices of ms spectra in the MSExperiment, or without gaps, i.e. just all PSMs, no empty inner vectors...)...
Also, it seems a bit dangerous to let the user modify this...
Maybe remove for now and see what use cases we have. Maybe some wrapper functions would be more appropriate...
There was a problem hiding this comment.
I'm also not sure how to handle indexing. I was thinking to use a 2d vector
std::vector<std::vector<PeptideIdentification>>
where, as you mentioned, the indices of spectra in the MSExperiment correspond to the indices of the outter vector. That means however that in order to add or edit peptide ids of a specific spectrum, you'd have to know the index. I can imagine that there are cases where the index is unknown. As of now peptide identification is stored within the spectra itself so indices are not used for storing these IDs, at least not directly. Also using indices feels a bit unsafe since accessing the correct spectrum cannot be guarantied by the interface itself but must be ensured by the user himself.
Maybe it would be better to use a std::map<MSSpectrum, std::vector<PeptideIdentification>> so accessing IDs is more straight forward. This would come at the disadvantage that upon the construction of AnnotatedMSRawData all spectra would need to be copied of into the map and the spectra vector in MSExperiment might no longer be the same as the keys in the map as things are added to the map. That means you'd have to prohibit accessing the MSExperiment::getSpectra function somehow.
Alternatively it might be possible to use a std::reference_wraper as key instead. This would complicate adding or removing spectra though because the map and actual vector of spectra always would need to be kept in sync.
I'm really unsure what correct way of implementing the mapping of spectra to peptide identification actually is. What are your thoughts on this? I'd appreciate your help on this.
There was a problem hiding this comment.
my take on what could work:
provide only std::vector - one PeptideIdentification (potentially empty) per spectrum
I think the vector of vector is not needed for all use cases we have (though the original design supported it)
| std::vector<std::reference_wrapper<const PeptideHit>> all_hits; | ||
|
|
||
| for (const auto& spec : layer_->getPeakData()->getSpectra()) | ||
| for (auto [spectra, peptide_ids] : *layer_->getPeakData()) |
There was a problem hiding this comment.
this is very nice to have!
|
|
||
| #include <OpenMS/OpenMSConfig.h> | ||
| #include <OpenMS/KERNEL/MSExperiment.h> | ||
| #include <boost/range/combine.hpp> |
There was a problem hiding this comment.
if you can get rid of boost, that would be very much appreciated :)
cbielow
left a comment
There was a problem hiding this comment.
nice approach, see comments above.
I'd go for composition though, since its cleaner and it seems that rewriting the calling code is required for most places anyway.
Getting rid of the pair also seems a good idea, as Timo mentioned.
Maybe return a struct with named members.
|
one note Julianus brought up. |
… identification is needed
…RawData" Build target "OpenMS" is successfully compiling now.
dc2fbdf to
3bf651b
Compare
|
still important to get revived and merged at some point. |
This PR aims to tackle the issue #4927; to separate identification data from spectra data. This involves removing
OpenMS/src/openms/include/OpenMS/METADATA/SpectrumSettings.h
Line 178 in d69467f
all
PeptideIdentificationfromSpectrumSettingsand maybe alsoOpenMS/src/openms/include/OpenMS/METADATA/ExperimentalSettings.h
Line 149 in d69467f
all
ProteinIdentificationfromExperimentSettings.Description
@timosachsenberg proposed to implement a new class that realizes the mapping between ID and spectra called
AnnotatedMSRawData(or something like that).The idea is to offer an interface to conveniently get both
MSSpectrumandPeptideIdentificationas astd::pairwhile also maintaining the functionality offered byMSExperiment. I decided to go with inheritance instead of composition because it simplifies calling functions fromMSExperimentsince you don't have to access aMSExperimentmember ofAnnotatedMSRawDataevery time.AnnotatedMSRawDataimplements iterator that returns astd::pairand can be used in e.g. range-based for loops.Aside from the design of the new class
AnnotatedMSRawData, the replacing ofMSExperimentoccurrences withMSAnnotatedMSRawDatawhere identification data is needed, obliviously requires a considerable amount of refactoring.I already started to do some of the refactoring but I would like to hear your thoughts and suggestions before proceeding further so that issues of any kind can be found early on and fixed easily.
Checklist:
How can I get additional information on failed tests during CI:
If your PR is failing you can check out
Note: