Skip to content

Commit

Permalink
Merge branch 'dev' into dev_latest_depthcharge
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilferrit committed Oct 15, 2024
2 parents e995d98 + 0f06ac9 commit 943dda4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- The `--output` option has been split into two options, `--output_dir` and `--output_root`.
- The `--validation_peak_path` is now optional when training; if `--validation_peak_path` is not set then the `train_peak_path` will also be used for validation.
- The `tb_summarywriter` config option is now a boolean config option, and if set to true the TensorBoard summary will be written to a sub-directory of the output directory named `tensorboard`.
- The Casanovo model peptide level score is now reported as the geometric mean of the raw amino acid scores, rather then the arithmetic mean.

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion casanovo/denovo/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def _aa_pep_score(
peptide_score : float
The peptide score.
"""
peptide_score = np.mean(aa_scores)
peptide_score = np.exp(np.mean(np.log(aa_scores)))
aa_scores = (aa_scores + peptide_score) / 2
if not fits_precursor_mz:
peptide_score -= 1
Expand Down
13 changes: 9 additions & 4 deletions tests/unit_tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,17 @@ def test_aa_pep_score():
aa_scores_raw = np.asarray([0.0, 0.5, 1.0])

aa_scores, peptide_score = _aa_pep_score(aa_scores_raw, True)
np.testing.assert_array_equal(aa_scores, np.asarray([0.25, 0.5, 0.75]))
assert peptide_score == pytest.approx(0.5)
np.testing.assert_array_equal(aa_scores, np.asarray([0.0, 0.25, 0.5]))
assert peptide_score == pytest.approx(0.0)

aa_scores, peptide_score = _aa_pep_score(aa_scores_raw, False)
np.testing.assert_array_equal(aa_scores, np.asarray([0.25, 0.5, 0.75]))
assert peptide_score == pytest.approx(-0.5)
np.testing.assert_array_equal(aa_scores, np.asarray([0.0, 0.25, 0.5]))
assert peptide_score == pytest.approx(-1.0)

aa_scores_raw = np.asarray([1.0, 0.25])
aa_scores, peptide_score = _aa_pep_score(aa_scores_raw, True)
np.testing.assert_array_equal(aa_scores, np.asarray([0.75, 0.375]))
assert peptide_score == pytest.approx(0.5)


def test_beam_search_decode(tiny_config):
Expand Down

0 comments on commit 943dda4

Please sign in to comment.