Skip to content

Commit

Permalink
[0.7.2rc1] Updated tests, pandas code, and resolve oustanding issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wfondrie authored Jul 16, 2021
2 parents 0878cba + 764a060 commit 0c09986
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 10 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# Changelog for mokapot

## [Unreleased]
## [0.7.2] - 2021-07-16
### Added
- `--keep_decoys` option to the command line interface. Thanks @jspaezp!
- Notes about setting a random seed to the Python API documentation. (Issue #30)
- Added more information about peptides that couldn't be mapped to proteins. (Issue #29)

### Fixed
- Loading a saved model with `mokapot.load_model()` would fail because of an
update to Pandas that introduced a new exception. We've updated mokapot
accordingly.

### Changed
- Updates to unit tests.
- Updates to unit tests. Warnings are now treated as errors for system tests.

## [0.7.1] - 2021-03-22
### Changed
Expand Down
15 changes: 15 additions & 0 deletions docs/source/api/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Python API
==========

Expand All @@ -22,6 +23,20 @@ Alternatively, PSMs that are already represented in a
Finally, custom machine learning models can be created using the
:py:class:`mokapot.model.Model` class.

.. note::

Set your NumPy random seed to ensure reproducibility:

.. code-block::
import numpy as np
np.random.seed(42)
In a future release, we will update mokapot to use the `new NumPy random
sampling API
<https://numpy.org/doc/stable/reference/random/index.html?highlight=random%20sampling%20numpy%20random#module-numpy.random>`_.


.. toctree::
:maxdepth: 1
:hidden:
Expand Down
2 changes: 1 addition & 1 deletion mokapot/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def load_model(model_file):
model.is_trained = True

# Then try loading it with pickle:
except KeyError:
except (KeyError, UnicodeDecodeError):
logging.info("Loading mokapot model.")
with open(model_file, "rb") as mod_in:
model = pickle.load(mod_in)
Expand Down
14 changes: 7 additions & 7 deletions mokapot/picked_protein.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ def picked_protein(

if shared_unmatched:
LOGGER.debug("%s", unmatched_prots.loc[~shared, "stripped sequence"])
if shared_unmatched / len(prots) > 0.10:
raise ValueError(
"Fewer than 90% of all peptides could be matched to proteins. "
"Verify that your digest settings are correct."
)

LOGGER.warning(
"%i out of %i peptides could not be mapped. "
"Check your digest settings.",
"Please check your digest settings.",
shared_unmatched,
len(prots),
)

if shared_unmatched / len(prots) > 0.10:
raise ValueError(
"Fewer than 90% of all peptides could be matched to proteins. "
"Please verify that your digest settings are correct."
)

# Verify that reasonable number of decoys were matched.
if proteins.has_decoys:
num_unmatched_decoys = unmatched_prots[target_column][~shared].sum()
Expand Down
17 changes: 17 additions & 0 deletions tests/system_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import pytest
import pandas as pd

# Warnings are errors for these tests
pytestmark = pytest.mark.filterwarnings("error")


@pytest.fixture
def scope_files():
Expand Down Expand Up @@ -78,6 +81,20 @@ def test_cli_options(tmp_path, scope_files):
tmp_path, f"blah.{file_bases[1]}.mokapot.peptides.txt"
).exists()

# Test keep_decoys:
assert Path(
tmp_path, f"blah.{file_bases[0]}.mokapot.decoy.psms.txt"
).exists()
assert Path(
tmp_path, f"blah.{file_bases[0]}.mokapot.decoy.peptides.txt"
).exists()
assert Path(
tmp_path, f"blah.{file_bases[1]}.mokapot.decoy.psms.txt"
).exists()
assert Path(
tmp_path, f"blah.{file_bases[1]}.mokapot.decoy.peptides.txt"
).exists()


def test_cli_aggregate(tmp_path, scope_files):
"""Test that aggregate results in one result file."""
Expand Down
4 changes: 4 additions & 0 deletions tests/system_tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
import os
import logging

import pytest
import pandas as pd
import mokapot

logging.basicConfig(level=logging.INFO)

# Warnings are errors for these tests
pytestmark = pytest.mark.filterwarnings("error")


def test_compare_to_percolator():
"""Test that mokapot get almost the same answer as Percolator"""
Expand Down

0 comments on commit 0c09986

Please sign in to comment.