Repository navigation
Claude/round three - #405
Merged
percolator merged 197 commits intoNov 13, 2026
Merged
Conversation
Percolator always split the PSMs into three cross-validation folds. The new option --num-folds N sets the number of folds: the PSMs are split by spectrum into N parts, and each part is scored by the SVMs trained on the other N-1. The default stays 3 and gives the same output as before. With N = 1 the only training set and the only test set both hold all PSMs, which Scores::createXvalSetsBySpectrum already did for the single fold of RESET, so the SVM is trained and evaluated on the same PSMs. This overfits and is meant for inputs too small to split; the help text says so and gives the measurements below. The places that depend on the number of folds were checked: - the weights file (-w) has one block per fold, and --init-weights reads the raw weights of the first block (SanityCheck::readWeights), so a file written with any N can be read; - -N scores all PSMs with the average of the weights of all folds (CrossValidation::getAvgWeights); - nested cross-validation splits the training set of each fold, also of the single one; - the estimated number of positives, which the stopping rule compares between iterations, divides the sum over the training sets by N - 1, or by 1 for one fold; - --quick-validation, --train-best-positive, --static, --init-weights and the initial direction (SanityCheck) loop over all folds; - the per-split messages print N; "one thread per CV fold" is removed from the help of --num-threads. RESET still trains on a single fold and warns that --num-folds is ignored when it is given with another N. N must be between 1 and 1000 and at most the number of spectra in the input. A fold that receives no PSMs, which can still happen when N is close to the number of spectra, is now reported as such right after the split; before, the merge of the folds stopped with "too good separation between target and decoy PSMs" (with --no-terminate the run continues as before). Overfitting, measured on marked synthetic inputs (make_synthetic_pin.py --mark-correct; target_i_ PSMs are incorrect, pep_calibration.py): accepted target PSMs at q < 0.01 and the fraction of them that are incorrect, for --num-folds 1, 2, 3, 5 and 10. input N=1 N=2 N=3 N=5 N=10 200k_sep_marked (sep.) 28619 0.80% 28640 0.85% 28606 0.83% 28610 0.85% 28622 0.88% 1M_marked (concat.) 141484 0.72% 141340 0.70% 141398 0.71% 141403 0.71% 141391 0.71% 10,000 PSMs, 6 inputs 8566 1.1% 7983 0.6% 8034 0.5% 7957 0.6% 7091 0.6% 2,000 PSMs, 6 inputs 1858 7.8% 905 1.1% 108 2.8% 104 1.0% 104 1.0% The 10,000- and 2,000-PSM rows pool three seeds each of the concatenated and the separate mode; per input, N = 1 gave 0.8-1.8% incorrect at 10,000 PSMs and 3.8-12.4% at 2,000 PSMs. With 2,000 PSMs and N >= 3, five of the six inputs accept nothing at q < 0.01, because a test fold then holds too few targets for the decoys+1 q values to go below 0.01 and the trained weights are replaced by the default direction. From 100 to 500 PSMs, N = 1 with --testFDR 0.05 gave 22-50% incorrect among the targets with q < 0.05. Large N does not help small inputs either: on 10,000 PSMs, N = 10 accepts about 12% fewer PSMs than N = 3, and with -N 4000 its test folds of 400 PSMs find no targets at q < 0.01. Verification: built with -DGOOGLE_TEST=ON; the unit tests pass, among them new ones: createXvalSetsBySpectrum with 1, 2, 3, 5 and 10 folds puts every PSM in exactly one test set and in N-1 training sets (all PSMs in both sets for one fold), keeps the PSMs of a spectrum in one fold and gives folds of at most ceil(n/N) + 3 PSMs (spectra of up to 4 PSMs); doStep estimates about the number of positives for 1, 3, 5 and 10 folds; three folds for two spectra are an error. gate2.sh prints ALL IDENTICAL, and --num-folds 3 gives the same files as the default on 100k_concatenated.pin. The output is identical with 1 and 3 threads for --num-folds 5 on 100k_concatenated.pin, and with 1 and 4 threads for --num-folds 10 on a 10,000-PSM input. --num-folds 1, 2, 5 and 10 run with --nested-xval-bins 2, --quick-validation, --train-best-positive, -N, --classic-training, -W from a 5-fold weights file and --static; --reset-algorithm --num-folds 5 warns and gives the same output as without the option; --num-folds 0 and 1001, and more folds than spectra, are rejected. Interface: new option --num-folds, long only, since -k was the XML input option until eb157f7. Without it the output is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
When the trained weights give no target PSM with q below --testFDR in
any test fold, SanityCheck::validateDirection prints "No targets found
with q<..." and replaces the weights by the default direction. With
several folds this is what inputs of up to a few thousand PSMs get: a
test fold of a few hundred targets cannot reach q < 0.01 with the
decoys+1 q values. The message did not say why, or what can be done.
Two lines on stderr now follow the reset message: each test fold may be
too small to reach that q value; --num-folds 1 trains and evaluates on
the same PSMs, so its q values and PEPs are optimistic, and wrong for
inputs without signal; a larger --testFDR is an alternative. They are
printed only with more than one fold and only when the weights are
reset, so not with --override, with --num-folds 1 or with RESET, and not
when the weights are reset for another reason ("Less identifications",
wrong sign of the default direction). One fold stays an explicit choice:
nothing is switched automatically, and the result files do not change.
Evidence, on a 20,000-PSM input without correct targets
(make_synthetic_pin.py -n 20000 -f 120 --correct-fraction 0
--mark-correct): the default run accepts no PSM at q < 0.01, as at
b986955, and prints the hint; --num-folds 1 accepts 204 PSMs at
q < 0.01, all of them incorrect.
Verification: on that input the PSM, decoy PSM, peptide, decoy peptide
and weights files and stdout are identical to those of b986955, and the
filtered stderr differs only by the two lines; with --override and with
--num-folds 1 they are not printed. On the 98 small inputs of 10 to
100,000 PSMs used for the review (cuts of 100k_concatenated.pin and
percolatorTab, synthetic inputs with and without correct targets), all
output files and exit codes are identical to b986955 with default
options; the 79 runs that print "No targets found" gain the two lines,
and nothing else changes on stderr. No case of gate2.sh reaches this
path (x_Vneg and x_W reset the weights for the other two reasons), so
no reference file changes, and gate2.sh prints ALL IDENTICAL at the end
of this series. The unit tests pass.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
The help of --num-folds gave four measured ranges, among them 0.8-1.8% incorrect target PSMs at q < 0.01 for 10,000 PSMs with N = 1. That range held only for the synthetic inputs with 30 features: with 10 features, of which two are informative, one fold gave 5.7%, and on inputs without correct targets every accepted PSM is incorrect. The help now says that with N = 1 the SVM is trained and evaluated on the same PSMs, so the reported q values and PEPs are optimistic, and gives the measurements in one sentence: about 1% observed FDR at q < 0.01 for 10,000 PSMs with many features, 6-8% for small or weakly separating inputs (5.7% for the 10-feature inputs, 3.8-12.4% and 7.8% pooled for the 2,000-PSM inputs), and all incorrect without signal (on a 20,000-PSM input without correct targets, --num-folds 1 accepts 204 PSMs at q < 0.01). It also says that N = 1 is meant for inputs too small to split and is never switched on automatically, which holds: only --num-folds 1 and RESET train on one fold. Only the help text changes; percolator -h shows the new text. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
More folds than spectra stopped the run with an error and exit status 1
also with --no-terminate (-o), which elsewhere turns input errors into
warnings. With -o, the number of folds is now capped at the number of
spectra, with a warning ("--num-folds 3 is larger than the number of
spectra (2). No-terminate flag set: using 2 folds."). Without -o it
stays an error.
The cap does not go below two folds, since one fold, which trains and
evaluates on the same PSMs, is used only when asked for. For an input
of a single spectrum two folds are used, one of which stays empty; the
empty-fold check after the split reports it, and -o ignores it, as it
does for the default three folds on such an input.
Verification: on two spectra of percolatorTab (8 PSMs),
-o --num-folds 3 now exits with status 0 and uses two folds; without -o
the run stops with the error as before. On one spectrum (6 PSMs, and an
input of a single PSM), -o --num-folds 3 uses two folds, reports the
empty fold and exits with status 0. Runs without -o, and with -o and at
most as many folds as spectra, give the same files and exit status as
before on these inputs. gate2.sh prints ALL IDENTICAL at the end of
this series; the unit tests pass.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Before the cross-validation bins are merged, Scores::normalizeScores rescales the scores of each bin so that the score at the --trainFDR threshold is 0 and the median decoy is -1. When the median decoy does not score below that threshold, it stops with "median decoy score <= score at 1% FDR. Cannot rescale scores to merge cross validation bins". Tiny inputs run into this: when no target reaches q < 0.01, the threshold score is the top score, so it is enough that the median decoy ties with the top PSM, and with a single decoy there is no median decoy at all. On one and two spectra of percolatorTab, a decoy whose row is repeated scores highest with the default direction and is the median of the three or four decoys. With --num-folds 1 and with RESET, which both train on a single bin, such inputs exited with status 1, although nothing has to be merged. When there is exactly one bin, the raw SVM scores and weights are now kept with a warning instead. With several bins it stays an error, and with --no-terminate the offset is applied as before. Scores::merge passes whether it merges a single bin. With -N, Caller::run rescales the scores of all PSMs once more; with one fold they come from the weights of that fold alone, and that call passes the same. Only runs that exited with status 1 change. normalizeScores is the only place that needs this. On one spectrum of percolatorTab (6 PSMs), --num-folds 1 and --reset-algorithm, and on two spectra (8 PSMs) also --num-folds 1 -N 4, now go through the merge, the q values, the PEPs and the peptide level and exit with status 0; on three spectra (10 PSMs) --reset-algorithm does, while --num-folds 1 already did. The SVM is trained, but with three or four targets no target can reach q < 0.01 (the lowest q value is 1/3 or 1/4), so SanityCheck replaces the weights by the DefaultDirection row of the input, and all PSMs get q = 1 and PEP = 1. With --testFDR 0.5 --trainFDR 0.5 the trained weights are kept and rescaled; they put all targets above all decoys (q = 1/4 and PEP 0.37 on two spectra, q = 1/3 and PEP 0.50 on one). An input of a single PSM still stops earlier, with "no decoy PSMs were provided", and on three spectra two and three folds still stop with the error. Verification: on these inputs, all runs that exited with status 0 before give identical files, among them all runs with -o. gate2.sh prints ALL IDENTICAL at the end of this series, and none of its outputs contains the warning. The unit tests pass; the next commit adds one for this case. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
A unit test for the previous commit: a bin of one decoy above three targets cannot be rescaled, as there is no median decoy below the top score. normalizeScores throws for it by default and keeps the scores and weights unchanged with singleBin; Scores::merge keeps them for one such bin and throws for two. A bin of ten targets above ten decoys is rescaled to the same scores and weights with and without singleBin. The tests of 6c12cab are kept. Verification: built with -DGOOGLE_TEST=ON, all 49 unit tests pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Follow-ups from the review of the previous commits: - The check against the number of spectra, and the cap under --no-terminate, applied whenever --num-folds was given. An explicit --num-folds 3 therefore behaved differently from the default on inputs with fewer than three spectra (two weight blocks instead of three under -o). The default has never been checked, so an explicit 3 is now treated like it. - When the cap cannot lower the number of folds (one spectrum, at least two folds), the warning says that the folds are kept and at least one stays empty, instead of claiming a cap. - The help text gave pooled figures as a range. Per input, one fold left 1-2% incorrect targets at q < 0.01 for 10,000 PSMs with many features, 4-19% for 1,000-5,000 PSMs or weakly separating inputs, and 100% for inputs without signal; the help text now says so. Known limitation, not changed here: the spectrum count used by the check counts (file, scan) pairs, while the cross-validation split starts a new fold only when the scan number changes between neighbouring PSMs in its order, so two spectra of different files with the same scan number can share a fold. The empty-fold error then reports it. Changing the split would change fold assignments of multi-file inputs. Output files of the byte-identity gate are unchanged; 49 unit tests pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Tolerance mode joined the rows of both files on the first column. In a peptide-level file that is the PSMId of the peptide's best PSM, which can differ between two runs, and inputs that repeat a SpecId give repeated PSMIds. A benchmark on Pandey25M reported max|dq| = 1 and max|dPEP| = 1 at peptide level for this reason, although the accepted peptides agreed within 0.03%. The rows are now joined, by default, on the peptide when every row of both files has a different peptide (peptide level), on the PSMId and the peptide otherwise (PSM level), and on the first column when there is no peptide column (protein level). --key first|psm|peptide forces a choice, and the "rows" line names the key used. Verified on Percolator outputs: - percolatorTab peptides compared with themselves: all 5268 rows are compared, against 3682 before (1586 rows were dropped as repeated PSMIds); - 1M synthetic PSMs, peptide level, default against -N 200000: 93749 common rows and Jaccard 0.9916, against 93082 and 0.9718 before; - a peptide file with a third of its PSMIds renamed: PASS with Jaccard 1, against FAIL with Jaccard 0.50 before; - PSM-level and protein-level pairs give the same numbers as before; percolatorTab PSMs repeat 149 (PSMId, peptide) keys instead of 1916 PSMIds. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6 (cherry picked from commit 9bf37317178f2c9c1a848c1d51751478ef0f6e5a)
StdvNormalizer::setSet sums the raw feature values and their squared deviations without any guard; readPsm only rejects values that are not finite themselves. Two Xcorr values of 1e308 made the mean and the standard deviation infinite, so every normalised Xcorr, every weight and every score became NaN, with 0 PSMs at q < 0.01 and exit status 0. A single value of 1e200 overflowed the squared deviation: the standard deviation became inf and Xcorr was 0 for every PSM, so the best feature silently dropped out (960 instead of 1,172 PSMs at q < 0.01 on percolatorTab). UniNormalizer has the same problem with a range that overflows. Both normalizers now check the mean and standard deviation (minimum and range) of every feature after computing them, in setSet and updateSet, and throw a MyException that names the feature and the two values. CrossValidation::train checks after the last iteration that every weight of every split is finite and names the split and the feature otherwise; with --no-terminate it reports this and continues. FeatureNames::describeFeature gives the name of a feature, or its number, for such messages. The checks cost O(features) per run. On adv/huge_feat.pin (two 1e308) and adv/big_feat.pin (one 1e200) the run now stops with "ERROR: Cannot normalize feature Xcorr: its mean is inf and its standard deviation is inf, ...". New unit tests cover both overflows and the range of the UniNormalizer. Output files are byte-identical. Interface: Normalizer::setSet and updateSet throw MyException for a feature whose factors overflow. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
getPeptideSequenceView returned peptide.substr(2, size - 4), assuming the X.PEPTIDE.Y form, but only protein inference checked that form. - A peptide without flanks lost two characters at each end, so different peptides with the same middle were merged: on percolatorTab with the flanks removed (adv/noflank.pin), the peptide level had 8,785 instead of 8,928 peptides, with exit status 0. - A peptide shorter than 2 characters made substr throw std::out_of_range inside the GCC parallel-mode sort of the peptide level, so std::terminate aborted the run (exit status 134) without an error message or the cleanup of temporary files. - The check for protein inference used && and size()-1, so K.PEPTIDE passed it. - A line with one feature column more than the first PSM line was read with the extra value as its peptide (0.5) and the real peptide as a protein. getPeptideSequenceView now removes the flanks only from a peptide of the form X.PEPTIDE.Y (PSMDescription::hasFlanks: at least 5 characters, '.' second and second to last) and returns any other peptide as it is, so it never throws and distinct unflanked peptides stay distinct. The existing unit tests read unflanked and empty peptides as legal input, so such peptides are accepted, with one warning per run on stderr that names the PSM and line. readPsm stops with an error that names the PSM and line when the peptide column holds a number (an extra feature column), and, with protein inference, when the peptide has no flanks. Changed results, only for input whose peptides are not of the form X.PEPTIDE.Y: on adv/noflank.pin the PSM and peptide result files are now identical to those of percolatorTab with the flanks removed from the peptide column (8,928 peptides; scores, q values and PEPs equal), and adv/shortpep.pin finishes. adv/extra_col.pin stops with "the peptide column of PSM ... on line 10 holds the number 0.5. The line has more feature columns than the first PSM line (19 features)." The check costs 3 character comparisons per PSM and per call of getPeptideSequenceView. New unit tests cover getPeptideSequenceView on peptides of 0 to 11 characters (the PSMDescription test file is now built) and the peptide checks of readPsm; a test that read extra columns as proteins now sets the number of features. Output files are byte-identical for input with flanked peptides. Interface: getPeptideSequenceView and getPeptideSequence return an unflanked peptide unchanged; new PSMDescription::hasFlanks and DataSet::resetWarnings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
The number of features comes from the first PSM line and their names from the header, without a check that the two agree: - A header with one feature name missing named the last feature "Peptide" (adv/short_header.pin), and a first PSM line with a non-numeric feature (NA) silently cut the features to the ones before it (6 of 30 on 3,000 PSMs of 100k_concatenated.pin); both runs exited with status 0. - With several input files, a file with only a header added an empty line to the concatenated input, which failed with "error reading PSM on line 50002", a line of the temporary file that the user never sees. Every other error that names a line had the same problem. - Each PSM with a label other than 1 and -1 printed one warning line: about 10M lines (800 MB of stderr) for 100M PSMs of which 10% have label 0. SetHandler::readAndScoreTab now finds the Peptide column of the header (case-insensitive) and requires that it follows the features of the first PSM line; otherwise it stops with "the header line has 18 feature columns before its Peptide column, but the first PSM, on line 3, has 19 features", or warns with --no-terminate. A header without a Peptide column is not checked. concatenateMultiplePINs skips a file without PSM lines with a warning and records where the lines of each file start (InputSegment). The read loops of SetHandler add "Line 50005 of the concatenated input is line 5 of part_nanmass.pin." to any error raised while reading a line of a concatenated input, and the label warning names the file and line as well (SetHandler::describeLine). The label warnings stop after 1,000 lines, followed by one line with the total; the 400 warnings of label0.pin are printed as before. Verified: adv/short_header.pin and a first line with NA stop with the error above (exit status 1); part1.pin followed by a header-only file now runs with a warning; a NaN mass on line 5 of the second of two files is reported with that line and file, also with -N; 1,500 label-0 PSMs give 1,000 warning lines and the total. The temporary directory is removed in all these runs. New unit tests cover the header check, describeLine and the concatenation of a header-only file. Output files are byte-identical. Interface: ValidateTabFile::concatenateMultiplePINs takes an optional std::vector<InputSegment>*; new SetHandler::setInputSegments and describeLine. ValidateTabFile.h has an include guard. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
No output stream was checked after writing; checkIsWritable only tests that a file can be opened when the options are parsed. Every one of these runs wrote nothing and still exited with status 0: percolator with -m, -M, -r, -U -r, -w, -J or -l set to /dev/full, or with its standard output going to /dev/full, and qvality with -o /dev/full or its standard output going to /dev/full. At 10M to 100M PSMs the result files are 1 to 10 GB, so a full disk is a realistic failure, and a pipeline would take the truncated files for a result. The new closeOutputFile closes an output file and throws a MyException that names the file if the stream failed; flushStandardOutput does the same for standard output. They are called after the PSM and peptide result files (Caller::writeResults), the weights (-w), the tab output (-J, SetHandler::writeTab), the protein result files (ProteinProbEstimator::printOut) and the qvality results (PosteriorEstimator::finishStandalone). qvality wrote std::endl after every line, which flushes the stream: 2M targets took 2,000,001 write() calls. It now writes '\n', and the same output takes 6,173 write and writev calls; system time 0.24-0.29 s instead of 0.69-0.90 s (3 runs each, wall time dominated by noise on the shared machine: 8.8-13.6 s both). Verified: all the runs above now exit with status 1 and "ERROR: Could not write the file /dev/full. Check that the disk is not full and that the file is writable." or "ERROR: Could not write the results to standard output."; qvality -o on 2M targets writes a byte-identical file. Output files are byte-identical. Interface: new closeOutputFile and flushStandardOutput (MyException.h); ProteinProbEstimator::printOut and PosteriorEstimator::finishStandalone throw MyException on a write error. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
PosteriorEstimator::run read both files with istream_iterator<double> and checked neither that they opened nor why reading stopped: - A missing target file gave 0 target scores and then the misleading "too good separation between target and decoy PSMs". - A missing or empty null file gave exit status 0 with q = 1.1e-4 and PEPs of 1.4e-4 to 1.6e-4 for all 9,122 targets, i.e. everything reported as correct. - A "nan" or "abc" token on line 100 of the target file stopped the reading silently: 99 of 9,122 scores were used, exit status 0. The new PosteriorEstimator::readScores reads each whitespace-separated token and converts it with strtod, which is the conversion that operator>> uses, so valid files give the same values. It throws a MyException that names the file if it cannot be opened or holds no value, and that names the 1-based position and the token if a token is not a finite number (nan, inf and overflowing values included). Verified with the qv/ inputs of the correctness lens: missing target or null file, empty target, null or p-value file, and a nan or abc token now exit with status 1 and e.g. "ERROR: Value 100 of the target score file t_nan.txt is not a finite number: "nan"."; the outputs for t.txt/n.txt, data/qvality and a p-value file, and the 2M-target output with -o, are byte-identical to the base. A new unit test covers readScores. Output files are byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
SanityCheck::readWeights skipped every line up to the first numeric one and then read the number of features plus one values with operator>>, without looking at the line of feature names that -w writes or at the stream state. The weights are used by position: the 19-feature weights of percolatorTab, given with -W and --static to the 30-feature 100k_concatenated.pin, were applied to features 0-19 while features 20-30 got 0 from the failed reads, giving 924 instead of 14,103 PSMs at q < 0.01 with exit status 0. The same happens silently when the columns are in another order, and a file with only one line of weights gave all-zero weights. readWeights now compares the last line of names before the weights, if there is one, with the names that -w writes for the input (its feature names and m0), and stops at the first column that differs with an error that names the column, both names and both counts. It reads the raw weights from the line after the normalized weights and requires one finite number per feature plus m0 on that line. Files without a line of names, e.g. written by hand, are accepted when the number of weights matches. Verified: multi/wrongw (19-feature weights on the 30-feature input) stops with "The weights file w.txt has 20 columns, but the input has 31 (its features and m0). Column 1 is "lnrSp" in the weights file and "feat0" in the input. ...". -w on percolatorTab followed by -W --static on the same input gives byte-identical results and the same "Read weights from file" lines as the base. New unit tests cover the -w format, a file without names, other orders and counts, and missing or non-finite weights. Output files are byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
When a cross validation split has no training examples (m == 0), L2_SVM_MFN still ran its loop and called memcpy(o_bar, o, 0) with the null data pointers of the empty output vectors, which is undefined behaviour: UBSan reported "null pointer passed as argument 1" at ssl.cpp:415 for adv/two_psm.pin (one target and one decoy PSM of the same spectrum), and for adv/one_psm.pin and adv/header_only.pin with -o. The user then only saw the unrelated "too good separation between target and decoy PSMs" at the end. L2_SVM_MFN now returns at once for m == 0 with zero weights, which is the minimum of its objective without examples and the result the iterations reached before (the direct solve and CGLS both give w = 0 for an empty active set). CrossValidation::preIterationSetup warns on stderr when the training set of a split is empty because all PSMs fall into its test set: "Warning: cross validation split 3 of 3 has no PSMs to train on, as all 2 PSMs fall into its test set. The input has too few spectra for 3-fold cross validation." This is a warning and not an error, so that very small inputs still give a model; it only appears for inputs with a handful of spectra. Output files are byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
CommandLineParser::defineOption gave an option without a short name the short name "-" + "" = "-". Seven Percolator options are defined that way (--stdinput-tab, --classic-training, --no-analytics, --irls-pep, --rank-pep, --pava-pep and --tdc-pep), and as options are searched from the last one defined, a lone "-", which many tools take for standard input, set --tdc-pep: "percolator -U - percolatorTab" gave output byte-identical to --tdc-pep with exit status 0, and in qvality "-" set --irls-pep. The help text showed a line " -" above each of these options. The checks for options defined twice compared the stored "-x" and "--name" with the bare names, so they never matched. An empty short name now means Option::NO_SHORT_OPT, the duplicate checks compare the names with their dashes, and parseArgs takes a lone "-" as an argument (percolator then stops with "ERROR: Unable to read -, check if the file exists."). "percolator --version" printed "Exception caught:", the banner and the whole usage text, then 'ERROR: the option --version is invalid. Please run "command --help."' with a literal "command", and exited with status 1. Percolator and qvality now have --version, which prints "Percolator version 3.09.0" (or "qvality version ...") on standard output and exits with status 0; Caller::run and PosteriorEstimator::run then do nothing. The error for an unknown option no longer repeats the usage text and names the program: 'ERROR: the option --nosuch is invalid. Run "percolator --help" for the list of options.' Verified as described; the help texts have no " -" lines left (6 before). New unit tests cover a lone "-", the duplicate checks and the error message. Output files are byte-identical. Interface: CommandLineParser::defineOption treats an empty short name as NO_SHORT_OPT and now detects duplicate names; parseArgs keeps a lone "-" as an argument; CommandLineParser::error no longer prepends the usage text. New options --version for percolator and qvality. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Crux links Percolator as a library, so one process can run it more than once, but about 20 settings are process-wide statics, and only the spectrum file names and the feature names were reset between runs. A run with protein inference followed by a plain --irls-pep run in the same process (brainstorm micro/tworuns.cpp on 100k_concatenated.pin) differed from a fresh process and then crashed: - PseudoRandom's seed is only set with --seed, so the second run went on from the random numbers the first one had drawn, e.g. in the pi0 bootstrap, and got another cross validation split: scores and q values off by up to 0.197. - PickedProteinInterface set PosteriorEstimator::reversed for good, so the second run's PEP estimation took its list as reversed: with --seed 1, PEPs off on 15,646 of 50,076 PSMs. - ProteinProbEstimator's protein-level flag stayed set, and the second run dereferenced its missing protein estimator (segmentation fault). The Caller constructor now sets these back to their initial values: the seed (1), the flags of PosteriorEstimator (new resetToDefaults, which also restores qvality's number of bins), the protein-level flag, the protein name separator, the spectrum file names, the feature names and the warnings that are printed once per run. PickedProteinInterface restores PosteriorEstimator's reversed flag after its PEP estimation. A new unit test runs Percolator four times in one process on a synthetic input of 2,000 PSMs: --irls-pep, protein inference (-f auto), --irls-pep, protein inference. The PSM, peptide and protein result files of the second run of each kind must equal those of the first. Without this change the test crashes in the third run, and without the reset of the seed alone it fails on all five files. gtest_unit now links picked_protein, which the Caller needs; the test takes about 3 s. Output files are byte-identical. Interface: constructing a Caller resets the process-wide settings listed above, so a library user must set them after the constructor (the options of parseOptions do). New PosteriorEstimator::getReversed and resetToDefaults. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Caller::checkIsWritable opened each output file with the default mode, which truncates it, while the options were parsed. "percolator -m x.pin x.pin" therefore emptied the input (3,869,097 bytes to 0 for a copy of percolatorTab) and then failed with "Unable to read x.pin". Two outputs on the same file, e.g. -m a.txt -M a.txt, ran with exit status 0 and left only the decoy PSMs, as the second write replaced the first. checkIsWritable now opens the file in append mode, which creates it but does not truncate it; the results are written with the default mode as before. At the end of parseOptions, the new Caller::checkOutputFiles compares every output that will be written (-m, -M, -r, -B, -l, -L, -J, -w, after the -U redirections) with the input files, the -j input, the -W weights, the -f FASTA file and the parameter file, and with the other outputs. Existing paths are compared with std::filesystem::equivalent, but only for regular files, so that /dev/ null, /dev/stdout or a pipe can still take several outputs; paths that do not exist yet are compared after weakly_canonical. A conflict is a MyException that names both roles and the file: "The PSM results would be written to x.pin, which is the input file x.pin." or "The PSM results and the decoy PSM results would both be written to a.txt." Verified with both cases above (the input now keeps its 3,869,097 bytes) and with all four result files on /dev/null, which runs as before. A new unit test covers outputs on the input, on each other (also as ./out.txt) and on /dev/null. Output files are byte-identical. Interface: Caller::parseOptions throws MyException for such conflicts; new Caller::checkOutputFiles. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
A concatenated target-decoy search that reports several candidates per spectrum has spectra with both target and decoy PSMs, so the automatic detection takes it for separate searches, and mix-max then keeps every candidate. On a top-2 input made from 100k_concatenated.pin (30,000 spectra with two PSMs of random label each) Percolator selected pi0 = 0.585 and reported all 29,885 target PSMs without any hint, against 17,160 with -Y. Separate searches have one target and one decoy PSM per spectrum. SetHandler::readPSMs now also records, for the spectra (ScanNr and ExpMass) of the first 100,000 PSM lines, which labels they have and whether a label occurs twice. The map that detects separate searches already holds these spectra; it now keeps one byte of label flags instead of one bool and is cleared after the sample instead of at the detection, so it holds at most 100,000 spectra more. The detection itself is unchanged: a spectrum gets a second label exactly when a PSM differs from its first one. When mix-max is chosen because separate searches were detected and more than 10% of the sampled spectra have a repeated label, Caller prints on stderr: "Warning: 15009 of the 30000 spectra (ScanNr and ExpMass) of the first 60000 PSMs have more than one target or more than one decoy PSM. Mix-max assumes one target and one decoy PSM per spectrum. If the input comes from a concatenated target-decoy search that reports several candidates per spectrum, use -Y/--post-processing-tdc, which keeps the best-scoring PSM of each spectrum." percolatorTab, a real separate search, has 9 such spectra of 9,921 and gets no warning. "-Y -I concatenated" silently dropped -Y, as -I concatenated turns off target-decoy competition (29,885 instead of 17,160 PSMs on the input above). parseOptions now warns: "Warning: -I concatenated turns off target-decoy competition, so -Y/--post-processing-tdc is ignored. Without -I concatenated, -Y applies target-decoy competition to the Percolator scores of any input." The results are unchanged. Verified on the top-2 input with and without -N, with -Y (no warning) and with -Y -I concatenated. A new unit test checks the counts in both reading paths and that the detection is unchanged. Output files are byte-identical. Interface: new SetHandler::getSampledLines, getSampledSpectra and getSampledSpectraWithRepeatedLabel. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Three follow-ups of the earlier input checks: - SetHandler::checkPeptideColumn compared the header with the features of an empty first PSM line when the input has only a header, so adv/header_only.pin stopped with "the header line has 19 feature columns before its Peptide column, but the first PSM, on line 2, has 0 features" instead of the existing "too few features present". The check is now skipped for an input without PSMs. - It also passed plain char values to ::tolower, which is undefined for the negative values of non-ASCII bytes; it now converts through unsigned char. - DataSet::checkUnflankedPeptide copied every unflanked peptide into a std::string and converted it to test for a number, which would cost one allocation and conversion per PSM for an input whose peptides all lack flanks. Only a field that starts with a digit, a sign or a point and contains a digit is now converted. Verified: adv/header_only.pin, with and without -o, prints the same messages as the base; adv/extra_col.pin stops with the same error as before, and the peptide results of adv/noflank.pin are byte-identical to those of the previous commit. Unit tests pass. Output files are byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
The checks added by the validation thread called std::isfinite in Normalizer::checkFactorsFinite, CrossValidation::checkWeightsFinite, PosteriorEstimator::readScores and SanityCheck::readWeights. On MSVC, Globals.h defines isfinite as _finite, which turns std::isfinite into the undefined std::_finite and breaks the Windows build, as fixed for SetHandler::getScanId in 27b5c0f. The calls are now unqualified, which resolves to std::isfinite with GCC and Clang and to _finite on MSVC. No change in behaviour; msvc_check.sh prints clean again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
doStepTest draws its folds from the process-wide PseudoRandom generator and checks the estimated number of positives against bounds that hold for the folds drawn from seed 1. The validation thread's SetHandlerTest.TestCountSpectraWithRepeatedLabels reads with -N, which draws from the same generator, and it runs before doStepTest. The 3-fold estimate then became 103, above the bound of 102, although the test passes on its own. The test now sets the default seed first, so it no longer depends on the tests that run before it. Test-only change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Both SVM training loops (the grid of Cpos/Cneg pairs and the nested cross-validation retraining) were declared with "ordered", but neither has an "omp ordered" region. With libgomp, a thread of an ordered loop waits before it takes its next iteration until all earlier iterations have been handed out after theirs, so once the grid is fixed, from iteration 4 on, the one trained pair per fold ran after the other: the SVM training stage had equal wall and CPU time. The clause is removed. Each iteration writes only its own pair's weights, or weights_ of its own fold, and L2_SVM_MFN keeps its work space in local variables, so the result does not depend on the order. SVM training of the fixed-grid iterations, -v 3, interleaved with the base on the shared 4-vCPU machine (wall/CPU): - 1M_marked, iterations 4-6, three rounds at a load average of 4 to 5: 0.93/1.75, 0.88/1.85 and 1.01/1.95 s against 1.82/1.77, 1.85/1.79 and 1.97/1.99 s. - 4M set, iterations 4-9, at a load average of 11 to 13, when the solves could seldom run at the same time: 15.8/12.6 s against 13.3/12.5 s in the same round; in a second round, with all commits of this series, 10.5/11.9 s against 17.3/13.1 s. Output files are byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
From iteration 4 on, each fold trains only its selected (Cpos, Cneg) pair, yet the grid evaluation still sorted the row list of every validation set by address, scored each set with the trained pair and counted its targets below the test FDR. The count was not used: the other pairs get -1, and the selection picks the trained pair for any count >= 0, both without nested cross validation (tp >= 0, the initial best) and with it (a sum of counts >= 0 against the others' -nestedXvalBins). The same holds when there is a single candidate pair, with --quick-validation or with both -p and -n. In these cases the row lists and counts are not computed and the trained pair gets a count of 0. The weights, the selected pairs and the "Estimated N PSMs" line, which comes from the final scoring of the training sets, are unchanged. Grid evaluation of the fixed-grid iterations, -v 3, interleaved with the previous commit on the shared 4-vCPU machine at a load average of 10 to 15 (wall/CPU): - 1M_marked, iterations 4-6, two rounds: 4.9/3.8 and 3.9/3.6 s against 7.1/5.4 and 4.0/5.2 s. - 4M set, iterations 4-9: 42.1/26.8 s against 56.5/43.6 s. Output files are byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
In the grid iterations, each of the 27 trained pairs (9 per fold) was validated by scoring its validation set, fully sorting the (score, label) pairs and computing a q value per PSM, only to count the targets with q below the test FDR. A new vector of pairs was allocated for each pair, and the row lists took 16 bytes per row. Without the mix-max correction (pi0 = 1) the count only depends on the best PSMs. Let K be the smallest number of decoys whose FDR estimate with all targets of the set, computed with the expression of getQValues, is not below the threshold. Every cut-off with at least K decoys has at most all targets, and IEEE division and multiplication are monotone, so its estimate is not below the threshold either, and the q values from there on are not below it. Only the PSMs with a better score than the K-th best decoy can count. The new Scores::countTargetsBySelection finds that decoy with nth_element over the decoy scores, sorts only the PSMs ahead of it and walks them as getQValues does, groups of tied scores included. K comes from a binary search over the decoy count. The mix-max counts, NaN scores and null target win probabilities without a finite decoy factor keep the full sort. The function counts in either direction, for the initial direction in a later commit. Each thread keeps its buffers (Scores::CountBuffers) for all its pairs, and a row is one word: the feature address with the label in its lowest bit. Sorts and nth_element inside the parallel regions run on the calling thread (src/SequentialSort.h), since GCC's parallel mode would start a nested team for every call. New unit tests compare both counts with the full sort and getQValues for every label sequence of up to 10 PSMs, with distinct, all tied and block tied values, at thresholds the estimates reach exactly, with both decoy offsets and the null target win probabilities 0, 1/2, 2/3 and 3/4, and on random sets of up to 4,000 PSMs with ties, signed zeros, infinities, and all-target and all-decoy sets. Grid evaluation of iterations 1-3, -v 3, interleaved with the previous commit on the shared 4-vCPU machine at a load average of 10 to 15 (wall/CPU): - 1M_marked, two rounds: 11.9/9.3 and 10.1/9.5 s against 17.9/14.2 and 11.2/13.6 s; peak RSS 995 and 990 MB against 1026 and 1016 MB. - 4M set: 57/38 s against 95/64 s. The 4M peak (3.7-3.8 GB) is set by a later stage. Output files are byte-identical. Interface: Scores::FeatureRows is a vector of Scores::FeatureRow words (see Scores::makeFeatureRow, rowFeatures and rowIsTarget) instead of (const double*, bool) pairs; Scores::countTargetsBelowFdr(rows, w, ...) takes a Scores::CountBuffers instead of a vector of pairs; new static Scores::countTargetsBySelection. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
For each fold and each of the features, getInitDirection read
scores_[ix].pPSM->features[featNo] for all PSMs, two dependent loads
per value in the hash order of the cross-validation split, allocated a
vector of (value, label) pairs, sorted it fully, computed a q value per
PSM, reversed the vector and computed them again, to count the targets
below the initial FDR with low values first and with high values first.
The feature rows of the training set are now listed once in memory
order (getFeatureRows), and each thread reads a column along them into
a buffer it keeps for all its features. Without the mix-max correction
countTargetsBySelection gives both counts from one pass: the K-th
smallest and K-th largest decoy values come from nth_element over the
decoy values, one scan collects the PSMs below the first and above the
second, and only these two tails are sorted. NaN values and mix-max
counts keep the full sort, which reads the column in the order of the
PSMs as before. The selected feature and the counts are the same, so
the "Selected feature N ... Could separate M" lines are unchanged.
The RESET pre-step, which looks for the initial direction on all PSMs
before the best PSM per peptide is selected, uses the same function.
A new unit test compares the selected feature, direction and count with
the full sort of each column, with ties, constant and NaN columns, and
null target win probabilities 1/2 and 3/4.
Initial direction stage, -v 3, interleaved with the previous commit on
the shared 4-vCPU machine at a load average of 9 to 15 (wall/CPU):
- 1M_marked, two rounds: 3.2/3.1 and 4.8/3.3 s against 14/11 and
11/11 s.
- 4M set: 19/12 s against 83/56 s.
- The RESET pre-step on all PSMs, which also scores and sorts them once
("Stage RESET initial direction", added later in this series; binary
of the whole series against the base with the same stage lines):
1M 1.6/1.6 and 1.6/1.7 s against 5.2/5.3 and 5.6/5.6 s; 4M 5.5/6.0 s
against 23/22 s.
Output files are byte-identical.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
line_search sorted all breakpoints of the step and then visited them in increasing order until the derivative was no longer negative. In a 1M_marked run the 485 line searches had on average 102k breakpoints, of which 26k were visited: 49% of the searches stopped within the first 1/16 of the breakpoints and 29% between 7/16 and 15/16. The breakpoints are now sorted chunk by chunk: nth_element moves the smallest of the remaining ones into the next chunk, which is sorted and visited; the first chunk holds p/16 breakpoints (at least 256), and each further chunk twice as many. operator< of Delta is a total order (value, then index), so the breakpoints are visited in the same order as after a full sort, and L, R and the step are the same bits. The calls run on the calling thread (sequentialSort and sequentialNthElement), as line_search runs inside the parallel training loop. A new unit test compares the step with the earlier full-sort implementation on 200 random problems of up to 40,000 examples, with tied breakpoints and with searches that stop in the first chunk, stop in a later one or visit all breakpoints. A micro-benchmark that replays the breakpoint counts and visits of the 485 traced searches takes 2.74 and 2.62 s for the ordering, against 6.65 and 6.29 s for the full sort. In the runs (-v 3, interleaved with the previous commit on the shared 4-vCPU machine at a load average of 10 to 15), SVM training CPU time, iterations 1-3 plus the later ones: - 1M_marked, two rounds: 24.6 + 1.54 and 25.3 + 1.50 s against 26.2 + 1.83 and 25.1 + 1.68 s. - 4M set: 89 + 11.0 s against 99 + 14.0 s. Output files are byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
After training, the test sets are scored and sorted with the final weights (CrossValidation::train). SanityCheck::validateDirection then scores and sorts them again with the same weights, and Scores::merge sorts each of them once more before the q values, so two full sorts of all PSMs did not change anything. calcScores and merge now check in one pass whether the PSMs are already in strictly decreasing order of operator> (Scores::isSortedByScore), which stops at the first pair out of order, and skip the sort then. operator> orders PSMs without NaN scores totally, so the sort would have kept that order; a NaN score makes the check fail, and the sort runs as before. This holds whatever the path (also RESET and mix-max). The second scoring in validateDirection and the q values in merge are still computed. Post-iteration processing, -v 3, interleaved with the previous commit on the shared 4-vCPU machine at a load average of 10 to 15 (wall/CPU): - 1M_marked, two rounds: 1.4/1.2 and 1.7/1.3 s against 1.4/1.4 and 1.8/1.4 s. - 4M set, with the binary of the whole series (the later commits do not change the default path): 3.4/3.3 and 3.5/3.3 s against 4.4/4.1 s for the previous commit and 4.5/3.9 and 4.5/4.0 s for the base. Output files are byte-identical. Interface: new Scores::isSortedByScore. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
operator< repeated the six comparisons of operator> with the signs turned. It now returns "other > one". Each comparison a < b is b > a for every value, a NaN score or mass included (both are false), and compareIdAndLine changes its sign with its arguments, so the order is the same. Not done from the same item: lexicOrderProb::compStrIt compares the peptides char by char, which is signed on x86-64 and unsigned on arm64, while std::string_view::compare compares unsigned chars; replacing it would change the order of peptides with bytes above 127 on x86-64. The shared file-and-scan prefix of the three scan orders stays written out, since those are the comparators of the large sorts. The 167 unit tests pass. Output files are byte-identical. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
clang 18 with -Wall -Wextra gave three warnings where GCC's Release build gives none: - Set::operator[](size_t) overrides a virtual function of Array<int> without "override" (-Winconsistent-missing-override, since Set::add is now marked); - the assertion at the end of SetHandler::getFeatureNames compared an int with an unsigned int; Release builds do not compile it; - without OpenMP, the field numThreads_ of the helper OneThread in the unit tests of Scores is unused; it is now declared only with OpenMP. Checked with -fsyntax-only -Wall -Wextra over the sources and unit tests: clang 18 without OpenMP gives no warning, nor does GCC 13.3 with assertions enabled. clang's OpenMP header is not installed here, so clang was not run with -fopenmp. The 167 unit tests pass. Output files are byte-identical. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Entries for this series under "Dependencies and removed code", "Build, packaging and CI" and "Interface changes": the removal of Normalizer::updateSet and of small dead code, the enzyme table, the --no-terminate helper, std::isfinite without the MSVC macro, the blocking -Wall -Wextra job, the removed CMake options, and the picked-protein sources in perclibrary, with every removed name. The entry on finite normalisation factors no longer names updateSet. The code commits before this one remove 835 lines and add 380 in 54 files (src: -780, +265; the new unit test of the enzymes has 75 lines). Left as they are: MassHandler (Crux calls it), the retention arguments of Normalizer::setSet, the multi-fold RESET branch of the fold split, the public accessors without a caller, and the three scripts of tests/integration_tests/percolator (IntegrationTest_Percolator_Speed.py, _SpeedGraph.py and _SpeedGraphData.py, 698 lines), which CMake copies into the build tree and no test runs. Checked on the last code commit: 167 unit tests pass; a build of everything with -Wall -Wextra gives no warning; the regression gate gives the 317 checksums of the start commit except the random name in extra/x_multimiss/stderr.filtered, which is equal with the name masked, and the same output for 1 and 3 threads; the option matrix gives its 291 files as in the manifest, and the 41 exit-status cases pass. Not built on Windows or macOS. Text only. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
…tion The walk over a sorted list of targets and decoys that estimates the FDR at the end of each group of tied scores, with the mix-max correction for pi0 < 1, was written three times: in Scores::calcQvals, in PosteriorEstimator::getQValues, which read the mix-max counts from two arrays, and without the correction in countSortedTargetsBelowFdr of Scores.cpp. The three have to agree to the last bit, which only comments and a unit test held together. Whether getQValues returned the q values of the decoys, and whether the IRLS fit took a list as reversed, were two process-wide flags that five places set to true before each use. - New FdrWalk.h: walkFdrEstimates, a template over how an entry's label and ties are read and over what is done with the estimate of a group. It is the loop of calcQvals, with the mix-max counts taken from the totals and the counts above the group, and the floating-point expressions in their previous order. calcQvals writes the estimate to the PSMs of the group, getQValues appends it once per target or per entry, and the count keeps the targets up to the last group below the threshold. - getMixMaxCounts stays for binData of the IRLS fit, a different walk. - PosteriorEstimator: reversed and includeNegativesInResult are members of the qvality object instead of statics; the static functions take them as arguments. - The unit tests compare calcQvals, getQValues (with and without the q values of the decoys) and the counts with a copy of the previous getQValues instead of with getQValues itself. Interface: PosteriorEstimator::getQValues gains the argument includeNegatives (default false; Percolator's callers pass true) and estimatePEP the argument reversed (default false); setNegative, setReversed and getReversed are removed. With pi0 < 1 and skipDecoysPlusOne, a best group of decoys with a single decoy gives std::out_of_range from walkFdrEstimates in getQValues too, where it came from vector::at; no caller combines the two. Output files are byte-identical: the gate gives the 22 known differences from its reference and the checksums of the base; the option matrix has its 291 hashes; unit tests pass. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Scores::merge and countMergedTargets, the count that the pooled direction check and the second chance run before the merge, each had their own loop over the bins: which bins are checked for a too good separation, which anchors a bin is rescaled with, what makes the list unusable. The two had drifted apart once already, and the anchors of the training sets were computed a third time in CrossValidation::postIterationProcessing. - Scores::mergeBins (private) is the one loop. It returns a MergeStatus (OK, MISSING_SCALES, BIN_SEPARATES_TOO_WELL, CANNOT_RESCALE, LIST_SEPARATES_TOO_WELL). merge runs it on the bins with report = true: an error is raised where it is found, by the function that words its message, because under --no-terminate the same function prints the message and the merge goes on; only MISSING_SCALES is turned into its error by merge. countMergedTargets runs it with report = false on one copied and scored bin at a time, and any status but OK is its -1. - The two differences that remain are parameters of the one loop and described there: the dry run estimates a bin's pi0 only where the anchors of test need the bin's q values (the merge estimates it for every checked bin, and the later estimates of the run follow those random draws), and it does not rescale a single bin. - Scores::calcBinScales takes the anchors of train and train-decoys from the training sets, for CrossValidation (in place, with its message at -v 3) and for the dry run (each set on a copy). - Scores::noScoredPsms holds the "no scored PSMs" error of normalizeScores for both. Interface: Scores::calcScores, calcScoresAndQvals and calcScoreScale take the weights by const reference. New static Scores::calcBinScales. For a library caller, merge with skipNormalizeScores and a scheme other than test now checks the separation of each bin, as with test; Percolator always passes test there. Output files are byte-identical, error texts included: the gate gives the 22 known differences from its reference and the checksums of the base, the option matrix (with --direction-check pooled and second-chance and the merge schemes) its 291 hashes, and the exit-status cases pass. The unit tests of the merged counts (random state, unusable lists, counts against a direct merge) pass unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
How the cross-validation bins are merged was spread over Caller (the scheme, whether one was given, --static), CrossValidation (the scheme, --static again as a constructor argument, the selection FDR) and SanityCheck (the scheme, its FDR, --static, the scheme after a second chance, the lists made from the merged one), kept in step by setters that Caller and CrossValidation called at different times. Whether the second chance had kept the trained SVMs travelled from validateDirection, which returned a bool, to CrossValidation through SanityCheck::secondChanceKept(). - MergePlan (Scores.h) holds the scheme, the scheme after a second chance, the FDR of the anchors, skipNormalizeScores and the reported lists, and usedScheme(keptBySecondChance) gives the scheme of the merge. Caller::parseOptions fills what the options give, Caller::run completes it (the default scheme of the number of folds, the lists) and hands it to CrossValidation::setMergePlan, which sets the FDR and passes the plan to the SanityCheck before the initial direction. - SanityCheck::validateDirection returns DirectionOutcome: KEPT, KEPT_BY_SECOND_CHANCE or FAILED (the folds were reset, or keep their trained vectors under --override). CrossValidation keeps it (directionOutcome()) and takes the scheme of the merge from the plan. - The unit tests set the parts of the plan through a small subclass of SanityCheck and check the same outcomes as before. Interface: new MergePlan; SanityCheck::setMergePlan/mergePlan replace setMergeScheme, setSecondChanceMergeScheme, secondChanceMergeScheme, setReportedLists and secondChanceKept; validateDirection returns SanityCheck::DirectionOutcome instead of bool; CrossValidation::setMergePlan/mergePlan replace setMergeNormalization, its constructor loses the argument skipNormalizeScores, and it gains directionOutcome(). Output files are byte-identical: the gate gives the 22 known differences from its reference and the checksums of the base; the option matrix has its 291 hashes. The three direction checks with 3 and 10 folds and with -Y, two merge schemes, --override, -N, -W, -W --static, -W --override, --no-terminate, -v 3, -V and a strict --testFDR on four inputs of 2,000 to 5,000 PSMs (312 runs; the second chance runs in 87 and keeps the trained SVMs in 9, 205 reset) give the same result files, exit status and messages as before this series. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
…tyCheck readTab, readAndScoreTab and writeTab took a SanityCheck, of which reading used three setters (the default direction of the input, whether the search is concatenated, and the check of --default-direction against the feature names) and writing one getter. SetHandler.h therefore included SanityCheck.h, and the second pass of -N passed a SanityCheck that it never touched. - InputSummary (SetHandler.h) holds concatenatedSearch and the weights of the DefaultDirection line. readTab fills it; Caller:: loadAndNormalizeData passes it on to its SanityCheck after a successful read, in the previous order. - readAndScoreTab takes no check, and writeTab takes the default weights. - SetHandler.h no longer includes SanityCheck.h. Interface: SetHandler::readTab(std::istream&, InputSummary&), readAndScoreTab without the SanityCheck argument, writeTab(const std::string&, const std::vector<double>&). Output files are byte-identical: the gate gives the 22 known differences from its reference and the checksums of the base; the option matrix has its 291 hashes; the 41 exit-status cases pass. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
SetHandler read the PSM lines in three loops (all PSMs, the subset of -N, the second pass of -N), each with its own copy of the progress message, the trimming, the line counter and the handler that names the file of a multi-file input, and each with its own copy of "try the fast path, else getScanId and DataSet::readPsm". - SetHandler::forEachPsmLine is the loop; the three readers are its callbacks. - SetHandler::PsmLineReader reads one line: label and scan id first, then the PSM, by the fast path or, for a line that the fast path refuses, by getScanId and DataSet::readPsm, which stay the one place that words the errors of a malformed line. The second pass keeps reading only the label of a refused line, without the messages of getScanId. - The lines that the fast path refuses and that are read all the same are listed at PsmLineReader: a non-finite experimental mass under --no-terminate; a repeated CalcMass, retention time or file name column; a calculated mass or retention time that does not end at its tab but at other white space, or a blank or empty column that shifts the numbers without making them unreadable (strtod skips white space, tabs included). The unit test of the two parsers (30,000 mutated lines) now counts them, checks that each belongs to one of these kinds and that every kind occurs: the read PSMs are identical on both paths. It also resets the once-per-run warnings before each read, so that it passes when run alone. - DataSet::readPsm and readPsmBody lose the overloads that added the PSM to the set; the loop registers the PSM. Three error texts of getScanId are fixed on purpose. For a line that ends in its calculated mass, retention time or (not reachable) delta mass column, the message ended "Check if experimental mass is a floating point number.", copied from the experimental mass; it now ends "The line ends in this column.". Nothing else changes in what is accepted or printed. Interface: DataSet::readPsm(line, lineNr, optionalFields, featurePool, psmStore, decoyPrefix) and the five-argument DataSet::readPsmBody are removed; the static overloads remain. Output files are byte-identical: the gate gives the 22 known differences from its reference and the checksums of the base; the option matrix has its 291 hashes; the 41 exit-status cases pass. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
With more than one input file, Percolator first wrote a temporary file with the lines of all of them (the header of the widest file, zeros in the columns that a file lacks) and then read that file. The copy needs temporary space of the size of the input, which is memory where the temporary directory is a tmpfs, and its own pass over the data. - ConcatenatedPins (ValidateTabFile.h) makes the lines of that file one at a time. Its constructor reads the header and first rows of every file and prints what the copy printed, in the same order: the name of each file, the warning for a file without PSMs, the error for a column that the widest header lacks. ConcatenatedPinStream gives the lines as a std::istream; seekg(0) starts again, for the second pass of -N. - Caller::run reads that stream; no temporary directory is made. The line numbers are those of the concatenated file, so errors still name "line N of the concatenated input" and the file and line it comes from; the list of the files' first lines grows as the files are reached, and SetHandler reads it through a pointer (setInputSegments). - ValidateTabFile::concatenateMultiplePINs stays as a utility and writes the lines of ConcatenatedPins, so its tests cover the new reader. A new test reads four files (missing columns, a DefaultDirection line, a file without PSMs) through the stream, over the borders of its blocks, and again after seekg(0). - A further test pins that the reader of all PSMs and the subset reader of -N report malformed lines alike (messages, order, error). One message changes on purpose: at -v 2, "Reading tab-delimited input from datafile <temporary file>" becomes "Reading tab-delimited input from the N input files". The errors "Could not create/write the temporary file" can no longer occur. Measured on a 4M-PSM set split into four files (1.13 GB), 3 threads, three interleaved runs on a shared machine: the stage "concatenate input files" took 1.35, 1.38 and 1.20 s and 1,126 MB of temporary space; it is gone, and the temporary space is 0. Reading, which now also makes the lines, took 7.5, 7.1 and 8.5 s against 7.3, 7.3 and 6.1 s, so the two stages together took 7.5, 7.1 and 8.5 s against 8.7, 8.7 and 7.3 s. Interface: new ConcatenatedPins and ConcatenatedPinStream; SetHandler::setInputSegments(const std::vector<InputSegment>*); Caller no longer has a TmpDir. Output files are byte-identical. The gate gives the 22 known differences from its reference and the checksums of the base, except extra/x_multimiss/stderr.filtered, which now differs by the message above instead of by the random name of the temporary directory. 56 runs with several files (orders, missing columns, a missing file, a file without PSMs, DefaultDirection lines, -N, -Y, -J, -v 0 and 3, malformed lines in either file, --no-terminate) give the same result files, exit status and messages as before, the changed message aside. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
The entries of this series: the fixed error text of a line that ends in its calculated mass or retention time column, several input files read without a temporary copy, and the interface changes (FdrWalk.h and the arguments of PosteriorEstimator::getQValues and estimatePEP; the merge core, calcBinScales and MergePlan; SanityCheck::DirectionOutcome; InputSummary; ConcatenatedPins and ConcatenatedPinStream). Not in this series, after measurement: converting the numbers of the input on several threads after a serial pass over the lines. It was written with the messages and the error of the lowest failing line kept (1,480 runs on malformed inputs identical to reading line by line), and measured on the 4M-PSM set, read-input stage, against 5.1 to 7.2 s for reading line by line. With batches of 4,096 lines, 1 thread 6.8 and 7.3 s, 3 threads 6.4 and 9.4 s, 4 threads 9.4 and 11.1 s, at 17 to 26 s of CPU time instead of 5.4 to 7.1 s: the threads spin between the short parallel regions and take the cores from the serial pass on a busy machine. With batches of 65,536 lines, 1 thread 7.7 to 8.4 s, 3 threads 6.4 to 7.1 s, 4 threads 6.2 to 7.3 s: the kept lines no longer fit the cache. Both are slower than the code they replace, so it was dropped. No source file changes. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
RESET keeps the best PSM of each peptide and then draws the pseudo-targets by position in that list. CompositionSorter::psmsOnly read the list out of a std::unordered_map keyed by the peptide, and --composition-match processed the compositions in the iteration order of an unordered_map as well. That order depends on std::hash and on the bucket layout of the standard library, so the same input and seed give other peptides, other weights and other q values with libc++ or MSVC than with libstdc++. Shown by building the previous code with another hash (FNV-1a) and with another bucket layout (max_load_factor 0.3), --reset-algorithm, target peptides at q < 0.01, previous code -> this commit: - percolatorTab: 921 / 913 / 865 (libstdc++ / FNV-1a / load factor) -> 934 with all three; - percolatorTab --composition-match: 930 / 934 / 912 -> 918; - 100k synthetic concatenated PSMs (m100k_11): 4291 / 4333 / 4296 -> 4359; with --composition-match 4347 / 4306 / 4361 -> 4359. With this commit the five output files (-r -m -B -M -w) of the three builds are identical in all four runs. The winners are now listed in the order in which their peptides first appear among the PSMs, and the compositions are processed in the order in which they first appear; the hash maps are only used for lookups. The peptides of a composition were and are processed in the order of their strings. Which PSM wins a peptide is unchanged. Changes of results: every --reset-algorithm run changes once, as with another seed. The change is within the seed-to-seed spread and not a change in accuracy: percolatorTab, seeds 1 to 10, 804 to 924 target peptides at q < 0.01 before (mean 880) and 835 to 959 now (mean 899); three marked 100k-PSM sets with four seeds each, false discovery proportion at q < 0.01 0.0030 before and 0.0038 now on average, 0.0045 and 0.0068 at most, with 4030 and 4009 accepted peptides on average. Runs without --reset-algorithm do not reach this code. Tests: the references of the two order tests keep first-occurrence order instead of an unordered_map, and two fixed examples give the expected winners and their order (PsmsOnlyOrdersTheWinnersByFirst- Occurrence, CompositionMatchOrdersTheWinnersByFirstOccurrence). All 168 unit tests pass. The regression gate differs from the base in the 12 files of its two RESET runs (extra/x_reset, more/resetY) and nowhere else; the manifest tests/ci/option_matrix.sha256 is written again for the 15 files of ex_reset, ex_reset_tdc and ex_composition, the only ones that differ. Interface: DJB2Hash is removed from CompositionSorter.h; the map of compositions uses std::hash. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Mix-max takes every decoy PSM for one incorrect target PSM and does not scale by the numbers of targets and decoys. For numbers that differ by more than 10% Percolator printed "Warning: The mix-max procedure is not well behaved ... Consider using target-decoy competition (-Y flag)", not at all at -v 0, and went on. Measured with the previous binary on separate searches that follow the model of mix-max exactly: 100,000 spectra with 8 features, a decoy PSM and a target PSM each; for a native spectrum the target search reports the better of the correct and a random match, labelled by the winner. Decoy or target PSMs were removed at random. False discovery proportion of the target PSMs at q < 0.01, mean of 5 sets (accepted PSMs): kept pi0 = 0.5 pi0 = 0.9 all 0.0099 (32,560) 0.0105 (3,454) 95% of the decoys 0.0099 0.0103 90% of the decoys 0.0099 0.0116 80% of the decoys 0.0101 0.0131 50% of the decoys 0.0145 (35,996) 0.0190 (4,443) 95% of the targets 0.0098 0.0105 90% of the targets 0.0097 0.0102 80% of the targets 0.0101 0.0086 50% of the targets 0.0072 (15,077) 0.0056 (1,229) With fewer decoys the q values are too low: by a factor of up to targets/decoys where most targets are incorrect; with pi0 = 0.5 the correction term of mix-max, which is capped, hides a deficit of up to about 20%. With fewer targets they are too high and identifications are lost. Within the 10% that the warning allowed the error stays below about 1.1. The advice of the warning was wrong for missing decoys: with -Y the same inputs gave 0.0204 and 0.0196 with half of the decoys and 0.0124 and 0.0136 with 80% of them (0.0099 and 0.0101 with all). The warning is now an error that ends the run with exit status 1, also at -v 0: it gives both numbers and says what to do for a concatenated search (-Y or -I concatenated, not -y or -I separate) and for separate searches (a target and a decoy PSM for every spectrum; -Y does not make up for missing decoys). With --no-terminate the message is printed and the run goes on as before. The help of -y says so. The threshold of 10% is unchanged, and a scaled formula is left for a study of its own. Inputs that now stop, all of which got the warning before: mix-max (separate searches detected, -I separate or -y, without -Y) on PSMs whose numbers of targets and decoys differ by more than 10%. These are concatenated searches forced to mix-max with -y or -I separate, concatenated searches with several candidates per spectrum, which are detected as separate, and separate searches with filtered PSMs. Tests: CallerTest.MixMaxWithUnequalTargetsAndDecoysIsAnError runs 1,500 targets with 1,500 and with 750 decoys: the error and no results, also at -v 0; results with --no-terminate and with -Y. Three cases in tests/ci/exit_status.sh (44 cases pass). The run syn_search_input_separate of tests/ci/option_matrix.sh (-I separate on a concatenated search, 5,247 targets and 2,753 decoys) gets --no-terminate and writes the files of the manifest. All 169 unit tests and the system tests pass, which use -y on 9,852 targets and 9,822 decoys. No run of the regression gate has the warning: its files are those of the previous commit. Output files are byte-identical for inputs that still run. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Under --tdc-pep --pava-pep the decoy rate is fitted by PAVA as a function of the score. PAVARegressor::fit_xy sorted the observations by x and fed them to the pool-adjacent-violators pass one by one, equal x in input order. A run of equal scores was therefore split wherever its targets happened to come before its decoys, and PSMs with the same score got different PEPs, depending on the order of the input lines. fit_xy now starts with one block per distinct x, holding the sum and the number of its observations, so that tied observations are pooled before the pass and merged with their neighbours as a whole, weighted by their number. fit_y, which has no x (--rank-pep), and inputs without ties run the same arithmetic as before. Measured on three concatenated sets of 100,000 PSMs with exact target-decoy calibration and two features rounded to 0.5 (866 to 892 distinct scores), --tdc-pep --pava-pep, previous commit -> this one: - tie groups with more than one PEP: 53, 49 and 47 (14,915, 16,357 and 12,824 PSMs; PEPs up to 0.079, 0.095 and 0.117 apart) -> none; - sum of the PEPs of all targets: 33,482.0, 33,355.0 and 33,145.0 -> 33,485.0, 33,365.0 and 33,148.0, for 33,213, 33,322 and 33,212 incorrect targets; - targets at q < 0.01: sum of PEPs 171.9, 169.1 and 215.0 -> 173.8, 170.0 and 217.7, for 207, 204 and 198 incorrect targets. So the calibration is as it was; scores and q values are unchanged. qvality --tdc-pep --pava-pep on the scores of one feature (23 distinct values): 5 scores with more than one PEP -> none. --pava-pep without --tdc-pep goes through fit_xy too, but the raw PEPs of tied targets are already merged by the pass (the first of a tie group carries the step of the q value); its outputs on the three sets, and qvality --pava-pep, are byte-identical. Changes of results: PEPs of PSMs and peptides with tied scores under --tdc-pep --pava-pep, in Percolator and qvality. The regression gate (--tdc-pep --pava-pep on 200,000 PSMs with continuous features) and the 291 files of the manifest are unchanged. Tests: PavaTiesTest (four tests): a fixed example with its expected values, equal fits for equal x and for any input order with the sum of y kept, fit_xy equal to fit_y without ties, and equal PEPs for equal scores from InferPEP::tdc_to_pep; three of them fail with the previous code. All 173 unit tests pass. Interface: PAVARegressor::pava_impl (private) takes block sums and counts. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
-P auto takes the longest common prefix of the protein names of a tenth of the decoy PSMs, up to its first underscore. TabFileValidator::findDecoyPrefix drew that tenth with std::shuffle and a default-constructed std::default_random_engine. The engine behind that name and the algorithm of std::shuffle are implementation-defined, so libstdc++, libc++ and MSVC sample different decoys, and for an input whose decoys do not all share one prefix they can detect different prefixes. The sample is now every tenth decoy PSM, from the first one on (the 1st, 11th, 21st, ...): as many as before, (n + 9) / 10 of n, and the same on every platform. A prefix shared by all decoys is detected as before: "decoy_" for data/percolator/tab/percolatorTab and for 20,000 synthetic PSMs with the previous and the new binary. With decoys of two prefixes the result depends on the sample, before as now: of 10,092 decoys with 9 "rev_" names among "decoy_" the previous sample (libstdc++) held one and gave "", the new one holds none and gives "decoy_"; with 1%, 5% and 30% "rev_" names both give "". Tests: the reference of FindDecoyPrefixMatchesReference samples every tenth decoy (120 generated files); DecoyPrefixSamplesEveryTenthDecoy gives files whose detected prefix follows from the positions of the decoys alone, for 1 to 1,000 decoys and none. All 174 unit tests pass. The regression gate and the manifest of tests/ci (which give -P decoy_ or use percolatorTab) are unchanged. Output files are byte-identical for decoys with one prefix. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Entries under Unreleased for the four result-changing fixes of this series: the hash-independent order of the RESET peptides and the PAVA PEPs of tied scores under "Changes of results", the sample of -P auto under "Fixes", the error for mix-max on unequal numbers of target and decoy PSMs under "Input and output checks", and the removed DJB2Hash under the interface changes. The series against its base (96255c6): the regression gate differs in the 12 files of its two RESET runs (extra/x_reset and more/resetY: -r, -m, -B, -M, -w and stderr) and in no other file; the 1M-PSM output is the same with 1 and 3 threads. The manifest of tests/ci changes for the 15 files of ex_reset, ex_reset_tdc and ex_composition. 174 unit tests, the system tests and the 44 cases of tests/ci/exit_status.sh pass; the build has no warnings. Text only. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
The check of the numbers of target and decoy PSMs in Caller::loadAndNormalizeData ran whenever mix-max was selected, which the detection of separate searches does before --reset-algorithm is looked at. RESET does not use mix-max: it keeps the best PSM of each peptide in a Scores object without pi0, competes targets and decoys and takes its q values from the decoys it held out. Since the check became an error, a RESET run on separate searches whose numbers differ by more than 10% ended with status 1 and "Error: the mix-max method needs one target and one decoy PSM per spectrum". Shown on separate searches of 20,000 spectra with 80% of the decoy PSMs kept (20,000 targets, 15,957 decoys, 8 features, 30% of spectra with a correct match): --reset-algorithm ended with status 1; with --no-terminate it wrote the same -m, -r and -w files as --reset-algorithm -I concatenated, which never selects mix-max (3,243 target peptides at q < 0.01, false discovery proportion 0.0108). The check is skipped with --reset-algorithm. The same run now ends with status 0, without the message, and its three files are those of -I concatenated; the rest of its stderr is unchanged. The default run on the same input still stops. Tests: CallerTest.ResetIsNotStoppedByTheMixMaxCheck (1,500 targets and 750 decoys: status 0, results, and the peptides of -I concatenated) and the case reset_unequal of tests/ci/exit_status.sh (45 cases pass). All 178 unit tests pass. Output files are byte-identical for runs that ended with status 0 before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
Four commits ago the warning for numbers of target and decoy PSMs that
differ by more than 10% became an error with exit status 1. The numbers
do not tell whether the q values of mix-max are too low, and the text
of the error was wrong in one point.
Measured before that change (mix-max, warning only) on separate
searches that follow the model of mix-max: 100,000 spectra, 8 features,
10% or 50% of the spectra with a correct match; false discovery
proportion of the target PSMs at q < 0.01, mean of 5 sets, and the sets
the error stopped:
input targets/decoys FDP 10% FDP 50% stopped
all PSMs 1.00 0.0106 0.0100 0/5, 0/5
92% of the decoys 1.09 0.0108 0.0100 0/5, 0/5
80% of the decoys 1.25 0.0123 0.0100 5/5, 5/5
50% of the decoys 2.0 0.0215 0.0137 5/5, 5/5
80% of the targets 0.80 0.0090 0.0100 5/5, 5/5
50% of the targets 0.50 0.0065 0.0077 5/5, 5/5
threshold, 30% quantile 1.05 / 1.22 0.0107 0.0089 0/5, 5/5
threshold, 50% quantile 1.11 / 1.50 0.0098 0.0082 4/5, 5/5
"Threshold" drops, in both searches, the PSMs whose engine score is
below that quantile of the decoy scores, which is a usual reason for
unequal numbers: the surplus of targets is then the correct matches,
and mix-max stays at or below the nominal level. Of the 12 kinds of
input that were stopped, 3 were anti-conservative (decoys missing at
random), 9 were not. The error also said that -Y "does not make up for
missing decoy PSMs either": true for decoys missing at random (0.0223
and 0.0190 with half of them), not for a threshold (0.0097 to 0.0105).
The check is a warning again, printed at -v 1 and above like the other
warnings, and the run goes on. Its text gives both numbers and depends
on the direction: with more targets, the q values and PEPs are too low
by up to the ratio of the numbers if decoy PSMs are missing for some
spectra, and not if both searches left out the PSMs below a score
threshold; with fewer targets they are too high and identifications
are lost. In both cases it says what to do for a concatenated search
(-Y or -I concatenated, not -y or -I separate), which the previous
warning's "Consider using target-decoy competition (-Y flag)" only
half did. The help of -y says that a warning is printed. The threshold
of 10% is unchanged. --no-terminate has no effect on the check any
more.
Checked on one set of each of the 16 kinds above (first seed): 11
ended with status 1 before this commit; all end with status 0 now, with
the warning in the 11 ("too low" in 7, "too high" in 4) and none in the
5 within 10%, and with the -m, -r and -w files that --no-terminate gave
before.
Tests: CallerTest.MixMaxWithUnequalTargetsAndDecoysIsAWarning (1,500
targets with 1,500 and 750 decoys, and 750 targets with 1,500 decoys:
no warning, "too low", "too high"; the same PSM file with
--no-terminate and at -v 0, which prints nothing; no warning with -Y).
In tests/ci/exit_status.sh the cases mix_max_unequal and
mix_max_unequal_y expect status 0 and the warning, and reset_unequal
also checks that RESET prints none (44 cases pass). The run
syn_search_input_separate of tests/ci/option_matrix.sh loses its
--no-terminate; the 291 files are as in the manifest. All 178 unit
tests pass. Output files are byte-identical for runs that ended with
status 0 before; against the code before the error, only the text of
the warning differs.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
The entry of the mix-max error is written again for the two commits before this one: the check of the numbers of target and decoy PSMs is a warning with both numbers and the direction, it is not printed with --reset-algorithm, and the measurements are those of the larger table (random removal against a score threshold in both searches). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
With a p value file, run() adds as many decoys as there are p values
(the quantiles (2i+1)/(2m) of the uniform distribution), and with -d
("Include decoy probabilities in the output") the output has a line for
each of the 2m entries. The PEPs were made for all of them, but the q
values came from getQValuesFromP, one per p value, and finishStandalone
walked that vector over all 2m lines: the second half of the output
printed whatever followed the vector (6.9e-310, 4.9e-324, values of
other vectors), different from run to run, and ASan stopped the run.
This happened with every PEP method and is older than this branch.
For score input, -d gives a decoy the FDR estimate at its own score,
made monotone with the targets around it (getQValues with
includeNegatives). getAllQValuesFromP does the same for p values: a
p value keeps its q value, and a decoy d gets pi0 * m * d / #{p <= d},
the estimate getQValuesFromP makes for a p value at that place, limited
by the q value of the next p value. A decoy therefore lies between the
q values of the p values around it, and the values of the p values do
not change. estimateMonotonePEP interpolates the PEPs of the decoys
with these q values, as it does for score input; before, a decoy took
the PEP of the p value before it.
On 2,000 p values: the output of -d differed in five of five runs and
is now the same in five runs each with the default, --pava-pep,
--irls-pep and --tdc-pep; the lines of the p values have the score and
q value of the run without -d; the output without -d is unchanged; an
ASan and UBSan build gives the same files without a report.
tests/ci/exit_status.sh runs -d on 500 p values with three PEP methods
and checks the number of lines, that the q values lie in [0, 1] and do
not decrease, and that a second run gives the same file: all three
fail on the binary before this commit. A unit test checks the values on
a small example.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
percolator --no-terminate -f auto -P decoy_ -z trypsin on an input with decoy PSMs only ended with a segmentation fault (status 139), also before this branch. --no-terminate goes on after "no target PSMs were provided", so the protein inference gets decoy proteins only. ProteinProbEstimator::estimatePValues takes the p values of PosteriorEstimator::getPValues, one per target protein group, and started from the first element of that list, which is empty here: a null pointer was read (ProteinProbEstimator.cpp:113 under ASan). With no target protein, every protein gets the p value 1. The run then ends with status 0, which is what --no-terminate asks for, and writes the decoy proteins with q value 1 and PEP 1; no protein is reported at q < 0.01. Without --no-terminate the input is still the error "no target PSMs were provided" with status 1. Checked with an ASan and UBSan build, without a report: inputs with decoys only and with targets only, each with -f auto -P decoy_ and -z trypsin, without -z, with -Y and with --reset-algorithm. tests/ci/exit_status.sh has the case (status 139 before, and the decoy protein file is checked for q value 1) and the one with targets only, which worked before. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
With gtest_unit --gtest_shuffle, DataSetTest.* and SetHandlerTest.TestGoodReads and TestReadWithFeatures failed for some seeds (8 and 32 of the seeds 1 to 40) with "the peptide ... is not of the form X.PEPTIDE.Y ..., which protein inference needs". The cause is CallerTest.RunsGiveTheSameResultsAfterOtherRuns: its last run in the shuffled order can be one with -f, and a run leaves its process-wide settings behind, here ProteinProbEstimator::calcProteinLevelProb. The constructor of Caller resets them, so in the default order the next Caller cleaned up, and the tests of DataSet and SetHandler, which read peptides without flanks, ran before. The reset of the constructor is now the static Caller::resetProcessSettings, and the main file of the unit tests calls it before each test from a test event listener. A test therefore does not depend on what the tests before it set or failed to restore, whichever fixture it uses. ProcessSettingsTest has one test that leaves the settings of a run with -f, -v 0 and --no-terminate behind and one after it that expects the initial values; without the listener the second fails in the default order, and DataSetTest and SetHandlerTest fail in shuffled orders. gtest_unit --gtest_shuffle passes with the seeds 1 to 12, 32 and 12345 (182 tests each). Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
- Two entries contradicted each other: one said that several input files have the stage line "concatenate input files", the other that this stage is gone. Since the files are read in turn the stage of several input files is "validate input files" (their headers and first rows); both entries and tests/benchmark/README.md say so. - The interface lines named SanityCheck::setMergeScheme, setReportedLists, setSecondChanceMergeScheme and secondChanceKept and CrossValidation::setMergeNormalization as new, and a later line said that MergePlan replaced them. They never were in a release: the MergePlan line now describes what is set and how, and says that the earlier setters of this branch are gone. - tests/ci/exit_status.sh runs 49 cases (39 without /dev/full), not 39, and some of them expect status 0; tests/ci/README.md as well. - The wheel was compared with the CMake build on the 188 output files that the option matrix had then. The matrix has 51 runs and 286 output files now (291 manifest entries); the wheel was not run on the newer ones, and the entry no longer says "all files". - With --reset-algorithm on input detected as separate searches, "Separate target and decoy search inputs detected, using mix-max method." and the warning about several candidates per spectrum are still printed, although RESET does not use mix-max. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
The entry for the qvality -d fix said that only the second half of the lines had wrong q values and that the p-value lines are unchanged. In fact line i got the q value of the i-th p value whatever the line was, so nearly every p-value line had another line's q value; the fix changes them to the q values of the run without -d. The interface section also lacked the new PosteriorEstimator::getAllQValuesFromP. Text only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
The monotonicity check in the getAllQValuesFromP test was an unbraced if around EXPECT_LE, whose macro expands to an if-else. GCC warns with -Wdangling-else, and the warnings job (budget 0) fails on it. Built with -Wall -Wextra: no warning in 61 compiled files; 182 unit tests pass, also shuffled. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
RESET selects peptides after the initial direction, which sorts the PSM list by its score. The peptides and compositions are therefore in the order of first appearance in that sorted list, not in the input. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
|
Important Review skippedToo many files! This PR contains 176 files, which is 76 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.
|
With STATIC=ON, FindOpenMP takes libgomp.a. Its target and allocator
objects call dlopen, dlsym, dlerror and dlclose, which glibc moved from
libdl into libc only in 2.34. The manylinux_2_28 wheel builds (glibc
2.28, gcc-toolset-14) therefore failed to link percolator with
"undefined reference to `dlopen'" on x86_64 and aarch64, and the
AlmaLinux 8 portable build would fail in the same way whenever it finds
libgomp.a. ${CMAKE_DL_LIBS} now follows OpenMP when STATIC is on under
Linux; on glibc 2.34 and later, --as-needed drops it again.
Checked here (glibc 2.39, GCC 13): with -DSTATIC=ON the link line of
percolator and qvality ends in "libgomp.a libpthread.a -ldl", the
binary needs no libgomp.so or libdl.so, and its psm, peptide and
weight files on percolatorTab equal those of the default build. The
default build's link line is unchanged. The manylinux image could not
be pulled here, so the wheel build itself is not run.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
OneFeatureSets::trainBins passed "trainIsTest_ ? test_ : train_" to a function that takes a reference to an array of two vectors. GCC and Clang keep the array lvalue; MSVC lets both operands decay to pointers and stops with C2664 (build-windows on the pull request). The conditional now chooses between two calls. 182 unit tests pass, also shuffled; 0 warnings with -Wall -Wextra. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
readInt read with strtol into a long and refused values outside the range of int. Where long has 32 bits (Windows, LLP64), strtol saturates at LONG_MAX = INT_MAX and sets ERANGE, which the check ignored, so a label or scan number above 2147483647 was taken as 2147483647 instead of an error. Three unit tests failed on the build-windows job of the pull request for this reason (TabReaderTest.CheckReadInt, DataSetTest.CheckFeatureParsing, PsmHeaderTest.ScanNumberErrorNamesTheRange; the last one then divided by zero in an uninitialised FeatureMemoryPool of the test, which it only reached because no error was raised). The code dates from 2024; the Windows job did not run these tests before. readInt now reads with strtoll and also refuses ERANGE. Where long has 64 bits, strtol and strtoll are the same function, so nothing changes on Linux or macOS. A program that emulates a 32-bit strtol: the old check accepted 2147483648, -2147483649, 4294967296 and 1e20; the new check refuses them and accepts 2147483647 and 125. Checked: no warning with -Wall -Wextra; 182 unit tests pass, also shuffled; check_golden.sh --strict: 51 runs, 291 files as in the manifest; exit_status.sh: 49 cases. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017yywhfE3wwkLwPUfoERjp6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch: statisticalbiotechnology:claude/round-three (0313402), 67 commits on claude/round-two (e6c6ea0)
Compare: master...statisticalbiotechnology:percolator:claude/round-three
Open this after the round-two PR is merged; until then the compare view also lists round two's commits.
Title: Round three: faster serial stages, lower peak memory with many folds, CI safety net, defect fixes, pip wheel
Body:
Follows the round-two PR. With default options the result files are identical to round two, except for inputs with a constant feature column whose value is not a binary fraction (see Defects). RESET results change by design (see Statistics).
Speed and memory
Wall time in seconds (two runs; one at 10M) and peak RSS in GiB (the larger of the two runs), on a 4-core VM with load 1-3. The output files of the default mode are identical for all three versions.
--reset-algorithmThe default mode takes 16-24% less wall time than round two in these rows (11% at 1M on one thread) and about half the time of #404. On one thread the gain comes from the solver kernel, the prefetching and the weed-out keys; with more threads, also from the stages that now run in parallel. The ChangeLog's figures come from the runs of the single commits and differ from this table, which times the final branch.
Changes
Speed (identical output):
Memory (identical output):
--folds-in-memorysets the number of folds held at once. With 10 folds, peak RSS falls by 56% at 1M PSMs and 54% at 4M;main()(not the library) sets glibc's mmap threshold to 1 MiB, so freed training buffers leave the heap: peak -2 to -4%, +1.1 s system time at 4M;--in-place-traininghelp text gives measured costs.CI:
tests/ci/check_golden.sh --update;/dev/full): 39 bad inputs, invalid options and write errors that must fail, and 10 controls and edge cases that must succeed;-Wall -Wextrawarnings (budget 0, unit tests included);OMP_WAIT_POLICY=passivefor the tests;-v 3stage lines have six significant digits again (the normalization factors had left them at two). New stages time the weed-out, the writing of results and the validation of several input files; "PSM-level statistics" and "peptide-level statistics" now time the q values and PEPs alone.Defects:
-vand--no-terminateleaked from one run to the next in one process; constructing aCallernow resets them (new staticCaller::resetProcessSettings). Process-wide settings also leaked between unit tests, which failed under--gtest_shuffle;-nanI-spline PEPs with exit status 0; it is now an error. The I-spline solver warns if it does not converge;-don p values gave nearly every line another line's q value, and its second half read past the end of the q values. The p-value lines now have the q values of the run without-d, and the decoy lines their own;--no-terminate -fcrashed on input without target PSMs;-h,--helpand--htmlno longer callexit(0)inside the parser. The programs still end with status 0;Caller::parseOptionsreturns true andCaller::runreturns 1, as for--version;Statistics (results change, except the last point):
--tdc-pep --pava-pepwithout--rank-pep, PSMs with tied scores get one PEP (ties are pooled before PAVA), in percolator and qvality;-P autodetects the decoy prefix from every tenth decoy PSM instead of a sample drawn withstd::shuffle, which differed between libstdc++, libc++ and MSVC. The result changes only when the decoys carry more than one prefix;--reset-algorithmno longer prints it; RESET on input detected as separate searches still prints the mix-max detection line.Structure (identical result files; one
-v 2line and one error text change):Scores::mergeBins) and aMergePlaninstead of nine fields and four setters;calcQvals,getQValuesand the count-only grid evaluation;-v 2the input line reads "Reading tab-delimited input from the N input files";Normalizer::updateSetand smaller pieces, about 160 lines).MassHandlerstays, since Crux calls it;std::isfinitewithout the MSVC macro;-Wall -Wextra.Build and distribution:
percolatorandqvalityas entry points. The PyPI namepercolatoris taken, sopercolator-binis a placeholder to be decided;-DCMAKE_CXX_FLAGS=-pgor--coverage) and needs no C compiler;libpicked_protein.ais folded intolibperclibrary.a, so Crux's link line changes;Verification
tests/ci/check_golden.sh --strictpasses: 51 runs, 291 entries.exit_status.sh: 49 cases pass;check_determinism.sh: no difference;exit_status.shat the head, and nothing on the unit tests and the option matrix at the reviewed integration head.-Y; it is a warning again. A check of this text against the code found the warning and a wrong ChangeLog sentence, which the last two commits fix.Open points
Not run here:
A local Linux x86-64 wheel matched the CMake build on the 188 matrix outputs of its time.
Crux: not built against the changed interfaces, which the ChangeLog lists.
Mix-max threshold: the 10% threshold of the warning is not derived from data.
Timing noise: the timings were taken on a shared machine. The RESET gain over round two (3-7%) is within the noise.