Skip to content

Commit

Permalink
Merge branch 'main' into ionbot_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfG authored Sep 15, 2023
2 parents c6b0679 + e2cb5d4 commit 0b96576
Show file tree
Hide file tree
Showing 28 changed files with 1,356 additions and 473 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"

- name: Install dependencies
run: |
python -m pip install --upgrade pip flit
pip install --editable .[dev]
- name: Install dependencies
run: |
python -m pip install --upgrade pip flit
pip install --editable .[dev]
- name: Test package
run: |
pytest
- name: Test package
run: |
pytest
- name: Build and publish to PyPI
env:
FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }}
FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: flit publish
- name: Build and publish to PyPI
env:
FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }}
FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: flit publish
87 changes: 43 additions & 44 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,63 @@ jobs:
test-with-codecov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flit flake8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flit flake8
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install with Flit
run: flit install --deps all
- name: Install with Flit
run: flit install --deps all

- name: Test with pytest and codecov
run: |
pytest --cov=psm_utils tests
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: Test with pytest and codecov
run: |
pytest --cov=psm_utils tests
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3

test-platforms:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install package and its dependencies
run: |
python -m pip install --upgrade pip
pip install flit flake8
- name: Install package and its dependencies
run: |
python -m pip install --upgrade pip
pip install flit flake8
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install with Flit
run: flit install --deps all
- name: Install with Flit
run: flit install --deps all

- name: Test with pytest
run: |
pytest
- name: Test with pytest
run: |
pytest
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Ruff
.ruff_cache/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -103,7 +106,8 @@ celerybeat.pid

# Environments
.env
.venv
.venv/
.venv*/
env/
venv/
ENV/
Expand All @@ -127,3 +131,4 @@ dmypy.json

# Pyre type checker
.pyre/
.vscode/settings.json
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

python:
version: '3.8'
install:
- method: pip
path: .
Expand Down
27 changes: 14 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,20 @@ Goals and non-goals
Supported file formats
**********************

===================================================================================================================== =============== =============== ===============
File format psm_utils tag Read support Write support
===================================================================================================================== =============== =============== ===============
`OpenMS idXML <https://www.openms.de/>`_ ``idxml`` ✅ ❌
`MaxQuant msms.txt <https://www.maxquant.org/>`_ ``msms`` ✅ ❌
`MS Amanda CSV <https://ms.imp.ac.at/?goto=msamanda>`_ ``msamanda`` ✅ ❌
`mzIdentML <https://psidev.info/mzidentml>`_ ``mzid`` ✅ ✅
`Peptide Record <https://psm-utils.readthedocs.io/en/stable/api/psm_utils.io/#module-psm_utils.io.peptide_record>`_ ``peprec`` ✅ ✅
`Percolator tab <https://github.com/percolator/percolator/wiki/Interface>`_ ``percolator`` ✅ ✅
`Sage <https://github.com/lazear/sage/blob/v0.12.0/DOCS.md#interpreting-sage-output>`_ ``sage`` ✅ ❌
`TSV <https://psm-utils.readthedocs.io/en/stable/api/psm_utils.io/#module-psm_utils.io.tsv>`_ ``tsv`` ✅ ✅
`X!Tandem XML <https://www.thegpm.org/tandem/>`_ ``xtandem`` ✅ ❌
===================================================================================================================== =============== =============== ===============
===================================================================================================================== ======================== =============== ===============
File format psm_utils tag Read support Write support
===================================================================================================================== ======================== =============== ===============
`OpenMS idXML <https://www.openms.de/>`_ ``idxml`` ✅ ❌
`MaxQuant msms.txt <https://www.maxquant.org/>`_ ``msms`` ✅ ❌
`MS Amanda CSV <https://ms.imp.ac.at/?goto=msamanda>`_ ``msamanda`` ✅ ❌
`mzIdentML <https://psidev.info/mzidentml>`_ ``mzid`` ✅ ✅
`Peptide Record <https://psm-utils.readthedocs.io/en/stable/api/psm_utils.io/#module-psm_utils.io.peptide_record>`_ ``peprec`` ✅ ✅
`Percolator tab <https://github.com/percolator/percolator/wiki/Interface>`_ ``percolator`` ✅ ✅
Proteome Discoverer MSF ``proteome_discoverer`` ✅ ❌
`Sage <https://github.com/lazear/sage/blob/v0.12.0/DOCS.md#interpreting-sage-output>`_ ``sage`` ✅ ❌
`TSV <https://psm-utils.readthedocs.io/en/stable/api/psm_utils.io/#module-psm_utils.io.tsv>`_ ``tsv`` ✅ ✅
`X!Tandem XML <https://www.thegpm.org/tandem/>`_ ``xtandem`` ✅ ❌
===================================================================================================================== ======================== =============== ===============

Legend: ✅ Supported, ❌ Unsupported

Expand Down
22 changes: 15 additions & 7 deletions docs/source/api/psm_utils.io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ psm_utils.io


psm_utils.io.idxml
#####################
##################

.. automodule:: psm_utils.io.idxml
:members:
Expand All @@ -25,7 +25,7 @@ psm_utils.io.maxquant


psm_utils.io.msamanda
##########################
#####################

.. automodule:: psm_utils.io.msamanda
:members:
Expand All @@ -34,7 +34,7 @@ psm_utils.io.msamanda


psm_utils.io.mzid
#####################
#################

.. automodule:: psm_utils.io.mzid
:members:
Expand All @@ -52,16 +52,24 @@ psm_utils.io.peptide_record


psm_utils.io.percolator
###########################
#######################

.. automodule:: psm_utils.io.percolator
:members:
:inherited-members:



psm_utils.io.proteome_discoverer
################################
.. automodule:: psm_utils.io.proteome_discoverer
:members:
:inherited-members:



psm_utils.io.sage
###########################
#################

.. automodule:: psm_utils.io.sage
:members:
Expand All @@ -70,7 +78,7 @@ psm_utils.io.sage


psm_utils.io.tsv
##########################
################

.. automodule:: psm_utils.io.tsv
:members:
Expand All @@ -79,7 +87,7 @@ psm_utils.io.tsv


psm_utils.io.xtandem
##########################
####################

.. automodule:: psm_utils.io.xtandem
:members:
Expand Down
31 changes: 9 additions & 22 deletions online/pages/1_PSM_file_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ def _input_form(self):
"Score type: order",
options=[True, False],
format_func=lambda x: "Higher score is better"
if x == True
if x
else "Lower score is better",
)
self.state["log_scale"] = row[1].radio(
"Score type: scale",
options=[False, True],
format_func=lambda x: "Logarithmic scale (e.g., e-value)"
if x == True
if x
else "Linear scale (e.g., Andromeda score)",
help=(
"""
Expand Down Expand Up @@ -142,9 +142,7 @@ def _read_file(self):
# Write file to disk for psm_utils; then read
with NamedTemporaryFile(mode="wb", delete=False) as tmp_file:
if self.state["input_file"].name.lower().endswith(".gz"):
tmp_file.write(
gzip.decompress(self.state["input_file"].getvalue())
)
tmp_file.write(gzip.decompress(self.state["input_file"].getvalue()))
else:
tmp_file.write(self.state["input_file"].getvalue())
tmp_file.flush()
Expand Down Expand Up @@ -179,7 +177,7 @@ def _prepare_psms(self):
)

# If no q-values, try to calculate
if (psm_list["qvalue"] == None).any():
if (psm_list["qvalue"] == None).any(): # noqa: E711
# If no decoys, display error
if percent_decoys == 0.0:
st.error(
Expand Down Expand Up @@ -231,13 +229,9 @@ def _show_results(self):

n_collections = psm_df["collection"].unique().shape[0]
n_runs = psm_df[["run", "collection"]].drop_duplicates().shape[0]
n_spectra = (
psm_df[["spectrum_id", "run", "collection"]].drop_duplicates().shape[0]
)
n_spectra = psm_df[["spectrum_id", "run", "collection"]].drop_duplicates().shape[0]
n_psms = psm_df.shape[0]
n_peptidoforms = (
psm_df["peptidoform"].apply(lambda x: x.proforma).unique().shape[0]
)
n_peptidoforms = psm_df["peptidoform"].apply(lambda x: x.proforma).unique().shape[0]
percent_decoys = np.count_nonzero(psm_list["is_decoy"]) / len(psm_list)

row_1 = st.columns(3)
Expand All @@ -262,19 +256,12 @@ def _show_results(self):
else:
psm_df_filtered = psm_df[psm_df["qvalue"] <= self.state["fdr_threshold"]]
n_spectra = (
psm_df_filtered[["spectrum_id", "run", "collection"]]
.drop_duplicates()
.shape[0]
psm_df_filtered[["spectrum_id", "run", "collection"]].drop_duplicates().shape[0]
)
n_psms = psm_df_filtered.shape[0]
n_peptides = (
psm_df["peptidoform"].apply(lambda x: x.sequence).unique().shape[0]
)
n_peptides = psm_df["peptidoform"].apply(lambda x: x.sequence).unique().shape[0]
n_peptidoforms = (
psm_df_filtered["peptidoform"]
.apply(lambda x: x.proforma)
.unique()
.shape[0]
psm_df_filtered["peptidoform"].apply(lambda x: x.proforma).unique().shape[0]
)

row_3 = st.columns(4)
Expand Down
7 changes: 7 additions & 0 deletions psm_utils/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import psm_utils.io.mzid as mzid
import psm_utils.io.peptide_record as peptide_record
import psm_utils.io.percolator as percolator
import psm_utils.io.proteome_discoverer as proteome_discoverer
import psm_utils.io.sage as sage
import psm_utils.io.tsv as tsv
import psm_utils.io.xtandem as xtandem
Expand Down Expand Up @@ -54,6 +55,12 @@
"extension": ".percolator.txt",
"filename_pattern": r"^.*\.(?:(?:pin)|(?:pout))$",
},
"proteome_discoverer": {
"reader": proteome_discoverer.MSFReader,
"writer": None,
"extension": ".msf",
"filename_pattern": r"^.*\.msf$",
},
"tsv": {
"reader": tsv.TSVReader,
"writer": tsv.TSVWriter,
Expand Down
Loading

0 comments on commit 0b96576

Please sign in to comment.