Repository navigation
Added support for more Data-field - #7914
Conversation
WalkthroughThe changes introduce multiple new conditional branches within the Changes
Sequence Diagram(s)sequenceDiagram
participant Reader as File Reader
participant Parser as MascotGenericFile
participant Spectrum as Spectrum Object
Reader->>Parser: Read next line
Parser->>Parser: Check if line starts with "IONMODE"
alt Line is "IONMODE"
Parser->>Parser: Extract substring from index 8
Parser->>Spectrum: Set metadata {"IONMODE": extracted value}
end
Parser->>Parser: Check if line starts with "MSLEVEL"
alt Line is "MSLEVEL"
Parser->>Parser: Extract substring from index 9
Parser->>Spectrum: Set metadata {"MSLEVEL": extracted value}
end
Parser->>Parser: Check if line starts with "SOURCE_INSTRUMENT"
alt Line is "SOURCE_INSTRUMENT"
Parser->>Parser: Extract substring from index 19
Parser->>Spectrum: Set metadata {"SOURCE_INSTRUMENT": extracted value}
end
Parser->>Parser: Check if line starts with "ORGANISM"
alt Line is "ORGANISM"
Parser->>Parser: Extract substring from index 9
Parser->>Spectrum: Set metadata {"ORGANISM": extracted value}
end
Parser->>Parser: Check if line starts with "PI"
alt Line is "PI"
Parser->>Parser: Extract substring from index 3
Parser->>Spectrum: Set metadata {"PI": extracted value}
end
Parser->>Parser: Check if line starts with "DATACOLLECTOR"
alt Line is "DATACOLLECTOR"
Parser->>Parser: Extract substring from index 15
Parser->>Spectrum: Set metadata {"DATACOLLECTOR": extracted value}
end
Parser->>Parser: Check if line starts with "LIBRARYQUALITY"
alt Line is "LIBRARYQUALITY"
Parser->>Parser: Extract substring from index 16
Parser->>Spectrum: Set metadata {"LIBRARYQUALITY": extracted value}
end
Parser->>Reader: Return processed spectrum
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here. PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/openms/include/OpenMS/FORMAT/MascotGenericFile.h(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (windows-2022, cl.exe, default)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (macos-13, xcode, 14.2)
- GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
🔇 Additional comments (1)
src/openms/include/OpenMS/FORMAT/MascotGenericFile.h (1)
302-306: Implementation of IONMODE field looks goodThe implementation correctly follows the pattern used for similar metadata fields in the surrounding code. The substring extraction at position 8 aligns with the "IONMODE" prefix length.
|
Nice. Can you add the other ones above as suggested? |
|
Hello @timosachsenberg. I am sorry for the late response. My laptop had display issues and I got it back today after repairs. I have added the changes to the PR and would like to request a review again. |
| else if (line.hasPrefix("MSLEVEL")) | ||
| { | ||
| String tmp = line.substr(8); | ||
| spectrum.setMetaValue("MSLEVEL", tmp); |
There was a problem hiding this comment.
Check if the MS level could also be stored in a member of spectrum.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/openms/include/OpenMS/FORMAT/MascotGenericFile.h (1)
307-325: Great implementation of MSLEVEL with error handling, but could be more consistent.The MSLEVEL implementation correctly sets both the MS level and metadata, with proper error handling for invalid input. However, there's an inconsistency between the two catch blocks:
- In the
std::invalid_argumentblock, you set both the MS level and metadata.- In the
std::out_of_rangeblock, you only set the MS level, without updating metadata.catch (const std::out_of_range& /*e*/) { spectrum.setMSLevel(2); + spectrum.setMetaValue("MSLEVEL", "2"); }Additionally, I noticed a minor indentation issue in line 309 that could be fixed for consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/openms/include/OpenMS/FORMAT/MascotGenericFile.h(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: build-and-test (windows-2022, cl.exe, default)
- GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (macos-13, xcode, 14.2)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
🔇 Additional comments (2)
src/openms/include/OpenMS/FORMAT/MascotGenericFile.h (2)
326-350: Successfully implemented all required metadata fields.You've correctly implemented all the metadata fields mentioned in the PR objectives (SOURCE_INSTRUMENT, ORGANISM, PI, DATACOLLECTOR, LIBRARYQUALITY) with appropriate substring extraction from the input line.
For future maintenance, consider refactoring these similar metadata handling blocks into a helper method to reduce code duplication, especially if more fields will be added in the future.
302-350:Details
✅ Verification successful
Verify if MS level should be stored both as a property and metadata.
The code now stores MSLEVEL both as a spectrum property (via
setMSLevel()) and as a metadata entry, which is a good approach for backward compatibility. However, this pattern is unique compared to other fields.
🏁 Script executed:
#!/bin/bash # Check if there are other places in the codebase where this dual storage pattern is used # or if other special fields are treated differently from regular metadata # Look for other usages of setMSLevel along with setMetaValue echo "Checking for patterns of setting both MS level and metadata:" rg -A 2 "setMSLevel\(" | rg "setMetaValue" # Look for how MSLEVEL is used elsewhere echo "Checking how MSLEVEL is used in the codebase:" rg "MSLEVEL" --type cppLength of output: 2042
MSLEVEL Dual Storage Verified
After reviewing the code and verifying against the codebase, it appears that storing the MS level both as a spectrum property (via
setMSLevel()) and as a metadata entry (viasetMetaValue("MSLEVEL", ...)) is intentional and aimed at ensuring backward compatibility. This dual storage pattern is unique to MSLEVEL—other fields (e.g., IONMODE, ORGANISM) do not use the same approach—which suggests that its special treatment was deliberate.
- The dual storage is isolated to the
MascotGenericFile.himplementation.- No similar dual pattern was found elsewhere in the codebase for other fields.
- The use of
"MSLEVEL"in bothsetMSLevel()andsetMetaValue()aligns with legacy expectations.No changes are required unless you feel adding a clarifying inline comment would improve maintainability.
User description
Description
ISSUE: #6272
Added changes mentioned in the issue but also want to add the following
data fields :
else if (line.hasPrefix("MSLEVEL="))
{
String tmp = line.substr(8);
int mslevel = tmp.toInt();
spectrum.setMSLevel(mslevel);
}
else if (line.hasPrefix("SOURCE_INSTRUMENT="))
{
String tmp = line.substr(18);
spectrum.setMetaValue("SOURCE_INSTRUMENT", tmp);
}
else if (line.hasPrefix("ORGANISM="))
{
String tmp = line.substr(9);
spectrum.setMetaValue("ORGANISM", tmp);
}
else if (line.hasPrefix("PI="))
{
String tmp = line.substr(3);
spectrum.setMetaValue("PRINCIPAL_INVESTIGATOR", tmp);
}
else if (line.hasPrefix("DATACOLLECTOR="))
{
String tmp = line.substr(14);
spectrum.setMetaValue("DATA_COLLECTOR", tmp);
}
else if (line.hasPrefix("LIBRARYQUALITY="))
{
String tmp = line.substr(15);
spectrum.setMetaValue("LIBRARY_QUALITY", tmp);
}
please check and verify if these changes can be added or not.
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsPR Type
Enhancement
Description
Added support for parsing
IONMODEmetadata in MGF files.Added support for parsing
SPECTRUMIDmetadata in MGF files.Enhanced metadata extraction for better GNPS compatibility.
Changes walkthrough 📝
MascotGenericFile.h
Add parsing for IONMODE and SPECTRUMID metadatasrc/openms/include/OpenMS/FORMAT/MascotGenericFile.h
IONMODEmetadata.SPECTRUMIDmetadata.Summary by CodeRabbit