Repository navigation
FileInfo: Add sequence length stats and nucleic acid support for FASTA - #8643
Conversation
- Add sequence length distribution (Min, 25%ile, Median, 75%ile, Max)
- Detect nucleic acid vs amino acid sequences automatically
- Use appropriate labels ("nucleotide" vs "amino acid")
- Report IUPAC ambiguity codes for nucleic acid files
Closes #8638
Co-Authored-By: Claude Opus 4.5 <[email protected]>
📝 WalkthroughWalkthroughThe FileInfo tool now detects sequence type (nucleic acid vs amino acid), generalizes residue counting into a map, accumulates per-sequence lengths for distribution statistics, and adds type-specific ambiguity handling and reporting. Output and duplicate-header/sequence logic were adapted accordingly. Changes
Sequence Diagram(s)(Skipped — changes are internal to a single CLI component and do not introduce multi-component interaction flows.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (2)**📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/tests/topp/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
🔇 Additional comments (1)
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: 0
🧹 Nitpick comments (2)
src/topp/FileInfo.cpp (2)
894-908: Consider edge case for empty FASTA files.The nucleic acid detection logic is correct and efficiently breaks early when a non-nucleotide character is found. However, if the FASTA file has no entries,
is_nucleic_acidwill remaintrueby default. This is a minor edge case since the subsequent output would show zero sequences anyway, but it may produce misleading labels if someone parses the output programmatically.Optional: Handle empty FASTA explicitly
+ // Detect if sequences are nucleic acid (vs amino acid) + // If ANY character is not a valid nucleotide code, it's an amino acid sequence - bool is_nucleic_acid = true; + bool is_nucleic_acid = !entries.empty(); // Default to false if no entries for (const auto& entry : entries) {
1011-1017: Minor: Direct map access may insert default keys.Using
operator[]onresidue_counts(line 1013) will insert keys 'N' and 'n' with value 0 if they don't exist. While this doesn't affect the correctness of the output, it modifies the map as a side effect. Consider usingfind()or the existingcount_residueshelper for consistency.Suggested fix using count_residues helper
if (is_nucleic_acid) { - size_t amb_N = residue_counts['N'] + residue_counts['n']; + size_t amb_N = count_residues(residue_counts, "Nn"); size_t amb_all = count_residues(residue_counts, NA_AMBIGUOUS); os << "Ambiguous nucleotides (N) : " << amb_N << " (" << Math::percentOf(amb_N, number_of_residues, 2) << "%)\n"; os << "All IUPAC ambiguity codes : " << amb_all << " (" << Math::percentOf(amb_all, number_of_residues, 2) << "%)\n\n"; }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/topp/FileInfo.cpp
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{h,cpp}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{h,cpp}: Use 2-space indentation for C++ and header files; no tabs; Unix line endings (LF)
All non-template exported classes, structs, functions, and variables must useOPENMS_DLLAPImacro; templates are exempt
One class per file; class name must match file name exactly
Always pair.hheader files with.cppimplementation files
Class and type names must use PascalCase; methods must use lowerCamelCase; variables must use snake_case
Private and protected member variables must end with trailing underscore_
Enum names and macro definitions must use UPPER_SNAKE_CASE; preferenum classover C-style enums
Use OpenMS primitive types fromOpenMS/CONCEPT/Types.hinstead of standard C++ types
UseSize/SignedSizetypes for STL.size()values instead of standard integer types
Prefer references over pointers in C++ code
Use Rule-of-0 (no explicit copy/move) or Rule-of-6 (all copy/move/destroy); never use Rule-of-5
Accessor methods must use get/set pairs for protected/private members; do not return references to primitive types
All exceptions must derive fromException::Base; throw with file, line, andOPENMS_PRETTY_FUNCTION; catch by reference
Code comments must use//style; should comprise at least ~5% of code; describe the next few lines in plain English
Use.clang-formatconfiguration from repository root for code formatting; check withclang-format --dry-run -Werror
Use OpenMS logging macros andOpenMS::LogStream; avoidstd::coutandstd::cerr
Avoidstd::endl; prefer\nfor better performance
PreferOpenMS::Stringfor numeric formatting and parsing
Braces must be on their own lines and aligned; always use braces even for single-line blocks (trivial one-liners may remain single-line)
Space required after keywords (if,for,while) and around binary operators
Files:
src/topp/FileInfo.cpp
src/topp/*.cpp
📄 CodeRabbit inference engine (AGENTS.md)
src/topp/*.cpp: UseProgressLoggerin TOPP tools for progress reporting
TOPP tool source files must be registered insrc/topp/executables.cmakeand added tosrc/openms/source/APPLICATIONS/ToolHandler.cpp
TOPP tools must define parameters inregisterOptionsAndFlags_()and read withgetStringOption_and related helpers
Files:
src/topp/FileInfo.cpp
**
📄 CodeRabbit inference engine (AGENTS.md)
File extensions must be lowercase except for
ML,XML, andmzData
Files:
src/topp/FileInfo.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build-and-test (ubuntu-24.04-arm, g++, 13)
- GitHub Check: build-lnx-arm
- GitHub Check: build-macos-arm
- GitHub Check: build-and-test (windows-2025, cl.exe, 14.44)
- GitHub Check: build-win
- GitHub Check: build-lnx
- GitHub Check: build-and-test (macos-14, xcode, 15.4)
- GitHub Check: build-and-test (ubuntu-24.04, g++, 13)
- GitHub Check: build-and-test (ubuntu-24.04, clang++, 17)
- GitHub Check: cppcheck-test
🔇 Additional comments (4)
src/topp/FileInfo.cpp (4)
858-881: LGTM!The generalization from a fixed-size array to a map-based approach for residue counting is a clean design that supports both amino acids and nucleotides. The
count_residueslambda correctly handles missing keys and usesstd::string_viewfor efficient character set lookups.
947-970: LGTM!The before/after comparison pattern for detecting sequences with ambiguous residues is correct. The approach efficiently determines whether each individual sequence contributed any ambiguous characters without needing a separate per-sequence counter.
1005-1008: LGTM!The structured binding iteration over
residue_countsis clean and idiomatic C++17. The alphabetical ordering fromstd::mapprovides consistent, predictable output.
980-996: The Math function signatures are verified and the code is correct. All three functions (Math::median,Math::quantile1st, andMath::quantile3rd) accept abool sortedparameter with a default value offalse. The code on line 983 sorts the data and then correctly passestrueto these functions to indicate the data is pre-sorted, which is the proper usage.
Add sequence length distribution to expected output files. Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/tests/topp/FileInfo_17_output.txt (1)
22-44: Add nucleic acid test coverage for FileInfo.FileInfo_17 and FileInfo_18 test amino acid FASTA files only. No nucleic acid FASTA tests exist for FileInfo. If the PR adds nucleic acid support with automatic sequence type detection, corresponding test cases are needed to validate:
- Automatic detection of nucleic acid sequences
- Correct "nucleotide"/"nucleic acid" labeling (vs "amino acid")
- IUPAC nucleotide ambiguity code reporting (N and others)
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/tests/topp/FileInfo_17_output.txtsrc/tests/topp/FileInfo_18_output.txt
🧰 Additional context used
📓 Path-based instructions (2)
**
📄 CodeRabbit inference engine (AGENTS.md)
File extensions must be lowercase except for
ML,XML, andmzData
Files:
src/tests/topp/FileInfo_18_output.txtsrc/tests/topp/FileInfo_17_output.txt
src/tests/topp/**
📄 CodeRabbit inference engine (AGENTS.md)
TOPP tests must be registered in
src/tests/topp/CMakeLists.txtand placed alongside test data
Files:
src/tests/topp/FileInfo_18_output.txtsrc/tests/topp/FileInfo_17_output.txt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build-and-test (ubuntu-24.04-arm, g++, 13)
- GitHub Check: build-and-test (ubuntu-24.04, g++, 13)
- GitHub Check: build-and-test (ubuntu-24.04, clang++, 17)
- GitHub Check: build-and-test (windows-2025, cl.exe, 14.44)
- GitHub Check: build-and-test (macos-14, xcode, 15.4)
- GitHub Check: build-win
- GitHub Check: build-lnx
- GitHub Check: build-lnx-arm
- GitHub Check: build-macos-arm
- GitHub Check: cppcheck-test
🔇 Additional comments (1)
src/tests/topp/FileInfo_17_output.txt (1)
11-16: Sequence length distribution looks correct.The statistics are properly ordered and the tight clustering (174-177) is reasonable for similar sequences. Format is consistent with other test outputs.
Added 19 missing PRs to OpenMS 3.6.0 changelog: PyOpenMS: - #8530: Build system modernization with py-build-cmake - #8633: SpectrumNativeIDParser wrapper - #8655: Arrow/Parquet export with DataFrame methods (BREAKING: method renames) - #8661: Build dependency docs - #8664: Biosaur2Algorithm wrap-inherits - #8668: wrap-doc documentation - #8674: Docstring validation tests TOPP tools: - #8643: FileInfo FASTA stats - #8650: FileConverter MSP support - #8649: PeakPickerHiRes parameter OpenMS Library: - #8633: SpectrumNativeIDParser class - #8655: ArrowExport helper - #8651, #8656, #8659, #8660, #8662: Performance optimizations Fixes: - #8645: DataArray handling in filters - #8672: Test file correction - #8678: UniqueIdGenerator seed collision fix Build System: - #8675, #8676: Claude CI workflows Also reorganized misplaced entries from lines 122-129. Co-authored-by: Timo Sachsenberg <[email protected]>
* Add comprehensive changelog for OpenMS 3.6.0 Includes changes from 96 merged PRs since version 3.5.0: - General: macOS Intel discontinued, Ubuntu 24.04, notarization in CI - Dependencies: Autowrap >= 0.26.0, Eigen minimum 3.4.0 - PyOpenMS: Pythonic methods (__len__, __str__, __repr__, __hash__), DataFrame support, new wrappers, string handling improvements - TOPP tools: MapAligner spectra transformation, FileInfo improvements, IsobaricWorkflow fixes, SageAdapter thread handling - OpenMS Library: PeakFileOptions, ParamIterator, SpectrumAnnotator - Breaking changes: Matrix<T> Eigen decoupling, API renames, FileWatcher move - Bug fixes: NucleicAcidSearchEngine, LogConfigHandler, decoy generation - Documentation: Targeted Quantitation, parameter annotations, AGENTS.md - Build: macOS notarization, Parquet support, pytest fixtures Co-Authored-By: Claude Opus 4.5 <[email protected]> * Add missing changelog entries for recently merged PRs Added 19 missing PRs to OpenMS 3.6.0 changelog: PyOpenMS: - #8530: Build system modernization with py-build-cmake - #8633: SpectrumNativeIDParser wrapper - #8655: Arrow/Parquet export with DataFrame methods (BREAKING: method renames) - #8661: Build dependency docs - #8664: Biosaur2Algorithm wrap-inherits - #8668: wrap-doc documentation - #8674: Docstring validation tests TOPP tools: - #8643: FileInfo FASTA stats - #8650: FileConverter MSP support - #8649: PeakPickerHiRes parameter OpenMS Library: - #8633: SpectrumNativeIDParser class - #8655: ArrowExport helper - #8651, #8656, #8659, #8660, #8662: Performance optimizations Fixes: - #8645: DataArray handling in filters - #8672: Test file correction - #8678: UniqueIdGenerator seed collision fix Build System: - #8675, #8676: Claude CI workflows Also reorganized misplaced entries from lines 122-129. Co-authored-by: Timo Sachsenberg <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Timo Sachsenberg <[email protected]>
Summary
Closes #8638
Example Output
Amino acid FASTA:
Nucleic acid FASTA:
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.