Repository navigation
feat: integrate BrukerTimsFile directly into OpenSwath chromatogram pipeline - #9019
Conversation
…ipeline Allow Bruker .d (TDF) files to be passed directly to OpenSwathWorkflow without prior mzML conversion. The integration bridges BrukerTimsFile's DIA-PASEF output into the existing SwathMap infrastructure. Key changes: - BrukerTimsFile::loadDIA_(): add "ion mobility lower/upper limit" meta values to MS2 spectra so PASEF windows sharing the same m/z range but differing in IM are correctly distinguished by countScansInSwath_() - SwathFile::loadBrukerTdf(): new method that loads .d via BrukerTimsFile, discovers SWATH windows, and partitions spectra via RegularSwathFileConsumer - OpenSwathBase::loadSwathFiles_(): dispatch BRUKER_TDF file type to the new loadBrukerTdf() method (both multi-file and single-file branches) - OpenSwathWorkflow: accept "d" as valid input format (WITH_OPENTIMS only) https://claude.ai/code/session_01QSsBJj9apkny9nrxgQNmrT
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds conditional Bruker TDF (TIMS) SWATH input support: new guarded API Changes
Sequence DiagramsequenceDiagram
participant User as "User / OpenSwathWorkflow"
participant OSB as "OpenSwathBase"
participant SF as "SwathFile"
participant BTF as "BrukerTimsFile"
participant Consumer as "RegularSwathFileConsumer"
User->>OSB: request load (file type: BRUKER_TDF)
OSB->>SF: loadBrukerTdf(file)
SF->>BTF: load(file)
BTF-->>SF: PeakMap (spectra with IM metadata)
SF->>SF: countScansInSwath_(spectra)
SF->>Consumer: setExperimentalSettings(...)
loop per spectrum
SF->>Consumer: consumeSpectrum(spectrum with IM bounds)
end
Consumer-->>SF: retrieveSwathMaps()
SF-->>OSB: return vector<SwathMap>
OSB-->>User: SWATH maps available
Possibly related PRs
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/include/OpenMS/FORMAT/SwathFile.h`:
- Around line 85-87: Add complete Doxygen for the public function loadBrukerTdf:
document the input file parameter with `@param`[in] file explaining it is the path
to a Bruker .d (TDF) directory, document the exp_meta parameter with `@param`[out]
exp_meta (or `@param`[in,out] if it is both read and modified) describing that it
will be filled with ExperimentalSettings metadata, and document the return value
with `@return` describing that the function returns a
std::vector<OpenSwath::SwathMap> representing the loaded Swath maps; place these
tags immediately above the loadBrukerTdf declaration in the header.
In `@src/openms/source/APPLICATIONS/OpenSwathBase.cpp`:
- Line 146: The error text in OpenSwathBase.cpp currently always advertises ".d
(Bruker TDF)" support even when OpenTIMS is disabled; update the two message
occurrences (the string literal used in the input-file validation around the
checks at/near the two occurrences) so that the ".d (Bruker TDF)" part is only
included when WITH_OPENTIMS is enabled — e.g. build the message conditionally
using `#ifdef` WITH_OPENTIMS or append the suffix at runtime only when the
WITH_OPENTIMS flag is true; apply the same conditional change to both
occurrences so the runtime message accurately reflects available formats.
In `@src/openms/source/FORMAT/SwathFile.cpp`:
- Line 292: Replace direct std::cout/std::cerr use with OpenMS logging macros:
change the std::cout line that prints "Loading Bruker TDF file " << file to use
the OpenMS logger (e.g. LOG_INFO << "Loading Bruker TDF file " << file << '\n';)
and likewise replace any uses of std::endl in this new TDF path with '\n' when
using the logging stream; update the statements in SwathFile.cpp (the
TDF-loading block that currently uses std::cout and std::endl) to use LOG_INFO
(or the project-standard OpenMS log macro) and newline characters instead of
std::endl.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1df2254e-b1cf-42b8-88b0-6475bb7dafae
📒 Files selected for processing (5)
src/openms/include/OpenMS/FORMAT/SwathFile.hsrc/openms/source/APPLICATIONS/OpenSwathBase.cppsrc/openms/source/FORMAT/BrukerTimsFile.cppsrc/openms/source/FORMAT/SwathFile.cppsrc/topp/OpenSwathWorkflow.cpp
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 3 file(s) based on 3 unresolved review comments. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 3 file(s) based on 3 unresolved review comments. Co-authored-by: CodeRabbit <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/source/APPLICATIONS/OpenSwathBase.cpp`:
- Around line 133-135: The BRUKER_TDF dispatch uses the extension-only
in_file_type (set via getTypeByFileName) which misclassifies directory-based .d
inputs; replace those checks that compare in_file_type to FileTypes::BRUKER_TDF
(e.g., the branch that calls swath_file.loadBrukerTdf and the similar block at
lines ~179-181) to instead call FileHandler::getType(path) (or use
FileHandler::getType(...) where in_file_type is derived) so directory validation
and trailing-slash handling are respected; update all occurrences where
getTypeByFileName is used for .d detection to use FileHandler::getType() before
invoking loadBrukerTdf.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2a60ffa3-362d-4604-82c4-a996c12e6f5d
📒 Files selected for processing (3)
src/openms/include/OpenMS/FORMAT/SwathFile.hsrc/openms/source/APPLICATIONS/OpenSwathBase.cppsrc/openms/source/FORMAT/SwathFile.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
- src/openms/source/FORMAT/SwathFile.cpp
- src/openms/include/OpenMS/FORMAT/SwathFile.h
| else if (in_file_type == FileTypes::BRUKER_TDF) | ||
| { | ||
| auto maps = swath_file.loadBrukerTdf(f, exp_meta); |
There was a problem hiding this comment.
Use FileHandler::getType() for .d dispatch to handle directory validation and trailing-slash inputs.
BRUKER_TDF loading here relies on in_file_type, but Line 103 and Line 157 still derive it with getTypeByFileName(...) (extension-only). For directory-based .d, this can misclassify valid paths (e.g., trailing /) and skip marker-file validation.
Suggested fix
- FileTypes::Type in_file_type = FileHandler::getTypeByFileName(f);
+ FileTypes::Type in_file_type = FileHandler::getType(f);
...
- FileTypes::Type in_file_type = FileHandler::getTypeByFileName(file_list[0]);
+ FileTypes::Type in_file_type = FileHandler::getType(file_list[0]);Also applies to: 179-181
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/openms/source/APPLICATIONS/OpenSwathBase.cpp` around lines 133 - 135, The
BRUKER_TDF dispatch uses the extension-only in_file_type (set via
getTypeByFileName) which misclassifies directory-based .d inputs; replace those
checks that compare in_file_type to FileTypes::BRUKER_TDF (e.g., the branch that
calls swath_file.loadBrukerTdf and the similar block at lines ~179-181) to
instead call FileHandler::getType(path) (or use FileHandler::getType(...) where
in_file_type is derived) so directory validation and trailing-slash handling are
respected; update all occurrences where getTypeByFileName is used for .d
detection to use FileHandler::getType() before invoking loadBrukerTdf.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
@coderabbitai Your auto-fix in 785cc6a replaced |
|
Tip For best results, initiate chat on the files or code changes.
I'm adding a precise learning to avoid this mistake in future reviews. ✏️ Learnings added
🧠 Learnings used |
singjc
left a comment
There was a problem hiding this comment.
The setup looks fine to me. I think we have a test diaPASEF mzML file that's used in the TOPP tests. I think we should add a class test to compare the swath loading from an mzML and bruker tdf, to make sure the data is the same.
Though I'm not sure how the test diaPASEF mzML file was generated actually, if it was simulated or sampled from a TDF file.
At some point, we probably also would want to try implement the option to stream the data (by swath maybe), because loading all the data into memory would probably require a fair amount of memory.
Add missing changelog entries for commits after the 2026-03-26 sync: - #9019: OpenSwathWorkflow direct Bruker .d (TDF) file input - #9018: IM_PEAK format checks in Resampler, FeatureFinderCentroided, FeatureFinderMultiplex, PeakPickerHiRes - #9003: TMT 32-plex and 35-plex quantitation support - #9007: IMPeakType enum added, IMFormat::CENTROIDED deprecated - #9011: BREAKING IMFormat::MIXED removed; determineIMFormat requires ms_level Co-authored-by: Copilot <[email protected]>
Add missing changelog entries for commits after the 2026-03-26 sync: - #9019: OpenSwathWorkflow direct Bruker .d (TDF) file input - #9018: IM_PEAK format checks in Resampler, FeatureFinderCentroided, FeatureFinderMultiplex, PeakPickerHiRes - #9003: TMT 32-plex and 35-plex quantitation support - #9007: IMPeakType enum added, IMFormat::CENTROIDED deprecated - #9011: BREAKING IMFormat::MIXED removed; determineIMFormat requires ms_level Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Allow Bruker .d (TDF) files to be passed directly to OpenSwathWorkflow
without prior mzML conversion. The integration bridges BrukerTimsFile's
DIA-PASEF output into the existing SwathMap infrastructure.
Key changes:
values to MS2 spectra so PASEF windows sharing the same m/z range but
differing in IM are correctly distinguished by countScansInSwath_()
discovers SWATH windows, and partitions spectra via RegularSwathFileConsumer
new loadBrukerTdf() method (both multi-file and single-file branches)
https://claude.ai/code/session_01QSsBJj9apkny9nrxgQNmrT
Summary by CodeRabbit