This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Comet is an open-source tandem mass spectrometry (MS/MS) sequence database search engine written in C/C++. It searches experimental MS/MS spectra against protein sequence databases to identify peptides.
make # Full build (MSToolkit + AScorePro + CometSearch + Comet.exe)
make clean # Full clean including MSToolkit and AScorePro
make cclean # Quick clean: only CometSearch and root object files- Load
Comet.slnin Visual Studio 2022 (build tools v143) - Set configuration to Release / x64
- Right-click the Comet project → Build
- Output:
x64/Release/Comet.exe
The build requires Thermo's MSFileReader to be installed first (Windows only).
cd CometSearch && makeComet/ # Top-level: main entry point (Comet.cpp), solution files
CometSearch/ # Core C++ search library (compiled to libcometsearch.a)
CometWrapper/ # C++/CLI managed wrapper (CometWrapper.dll) bridging C++ to C#
RealtimeSearch/ # C# application layer for real-time (RTS) searches
AScorePro/ # AScore phosphosite localization library (git submodule-like)
MSToolkit/ # Mass spec file format reader library (Mike Hoopmann)
extern/ # Third-party dependencies (expat, zlib)
docs/ # Architecture docs, coding style, threading design records
The codebase has three layers:
-
Native C++ core (
CometSearch/): The search engine library. Key classes:CometSearchManager— implementsICometSearchManager; top-level orchestratorCometSearch— fragment index querying, XCorr scoring, peptide matchingCometPreprocess— spectrum preprocessing (binning, noise reduction)CometPostAnalysis— SP score, E-value, delta-Cn, AScorePro localizationCometFragmentIndex/CometPeptideIndex— index building and lookupCometSpecLib— MS1 spectral library loading and searchCometAlignment— MS1 RT alignment
-
C++/CLI wrapper (
CometWrapper/):CometSearchManagerWrapper(ref class) marshals data between managed C# and native C++.CometDataWrapper.hdefines managed wrapper types (ScoreWrapper,FragmentWrapper, etc.). -
C# application (
RealtimeSearch/):SearchMS1MS2.csdrives concurrent real-time searches by launching parallel C#Taskthreads that call into the wrapper.
| Global | Thread-safe? | Notes |
|---|---|---|
g_staticParams |
✅ Read-only after init | All search parameters |
g_iFragmentIndex, g_vFragmentPeptides, g_vRawPeptides |
✅ Read-only after init | Fragment index |
g_pvProteinNames, g_pvProteinsList |
✅ Read-only after init | |
g_vSpecLib |
✅ Read-only after init | MS1 spectral library |
g_pvQuery |
❌ Shared mutable | Batch search path only |
g_pvQueryMS1 |
❌ Shared mutable | Batch MS1 path only |
g_cometStatus |
❌ Shared mutable | Error reporting |
The real-time search (DoSingleSpectrumSearchMultiResults and DoMS1SearchMultiResults) is designed for concurrent calls from C# Task threads:
- MS2 RTS:
PreprocessSingleSpectrumThreadLocal()creates a caller-ownedQuery*;CometSearch::RunSearch(Query*, time_point)searches against the read-only fragment index; thread-localCalculateSP/CalculateEValue/CalculateDeltaCn(Query*)do post-analysis. Nog_pvQueryaccess. - MS1 RTS:
PreprocessMS1SingleSpectrumThreadLocal()creates a caller-ownedQueryMS1*;RunMS1Search(QueryMS1*, ...)scores against read-onlyg_vSpecLib. Nog_pvQueryMS1access. Reference library is loaded once inInitializeSingleSpectrumMS1Search(). - Batch search: Still uses
g_pvQuery/g_pvQueryMS1with the original mutex-guarded path.
From docs/CometCodingStyleGuidelines.md:
- Allman brace style: opening brace on its own line at the same indentation as the control structure
- 3 spaces per indentation level (no tabs)
- Windows-style line endings (
\r\n) - Use
//for inline comments (reserve/* */for commenting out blocks) - Systems Hungarian Notation for variable names (e.g.,
iCount,dMass,szName,bFlag,pprefix for pointers) - No trailing whitespace