Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into features/ptm_p…
Browse files Browse the repository at this point in the history
…ipeline
  • Loading branch information
WassimG committed Nov 6, 2024
2 parents d5c067b + 728b111 commit 03b0249
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .cookietemple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ full_name: Victor Giurcoiu
email: victor.giurcoiu@tum.de
project_name: spectrum_fundamentals
project_short_description: Fundamentals public repo
version: 0.7.4
version: 0.7.8
license: MIT
4 changes: 2 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name-template: "0.7.4 " # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.7.4 # <<COOKIETEMPLE_FORCE_BUMP>>
name-template: "0.7.8 " # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.7.8 # <<COOKIETEMPLE_FORCE_BUMP>>
exclude-labels:
- "skip-changelog"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Check out source-code repository

- name: Setup Python
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: ${{ matrix.python }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main_master_branch_protection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: "3.9"
# PRs to the repository master branch are only ok if coming from any patch or release branch
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Check out source-code repository

- name: Setup Python
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: 3.9

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: "3.9"

Expand All @@ -29,7 +29,7 @@ jobs:
poetry build --ansi
- name: Publish package on PyPI
uses: pypa/gh-action-pypi-publish@v1.9.0
uses: pypa/gh-action-pypi-publish@v1.10.3
with:
# TODO COOKIETEMPLE: Configure your PyPI Token to enable automatic deployment to PyPi on releases
# https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_cookietemple_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Check out source-code repository

- name: Setup Python
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: 3.9

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
uses: actions/checkout@v4

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

Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Python 3.9
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: 3.9

Expand Down Expand Up @@ -166,4 +166,4 @@ jobs:
run: nox --force-color --session=coverage -- xml -i

- name: Upload coverage report
uses: codecov/codecov-action@v4.5.0
uses: codecov/codecov-action@v4.6.0
2 changes: 1 addition & 1 deletion .github/workflows/sync_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: 3.9

Expand Down
2 changes: 1 addition & 1 deletion cookietemple.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.4
current_version = 0.7.8

[bumpversion_files_whitelisted]
init_file = spectrum_fundamentals/__init__.py
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
# the built documents.
#
# The short X.Y version.
version = "0.7.4"
version = "0.7.8"
# The full version, including alpha/beta/rc tags.
release = "0.7.4"
release = "0.7.8"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "spectrum_fundamentals"
version = "0.7.4" # <<COOKIETEMPLE_FORCE_BUMP>>
version = "0.7.8" # <<COOKIETEMPLE_FORCE_BUMP>>
description = "Fundamental functions, annotation pipeline and constants for oktoberfest"
authors = ["Wilhelmlab at Technical University of Munich"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion spectrum_fundamentals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__author__ = """The Oktoberfest development team (Wilhelmlab at Technical University of Munich)"""
__copyright__ = f"Copyright {datetime.now():%Y}, Wilhelmlab at Technical University of Munich"
__license__ = "MIT"
__version__ = "0.7.4"
__version__ = "0.7.8"

import logging
import logging.handlers
Expand Down
2 changes: 1 addition & 1 deletion spectrum_fundamentals/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@click.command()
@click.version_option(version="0.7.4", message=click.style("spectrum_fundamentals Version: 0.7.4"))
@click.version_option(version="0.7.8", message=click.style("spectrum_fundamentals Version: 0.7.8"))
def main() -> None:
"""spectrum_fundamentals."""

Expand Down
2 changes: 1 addition & 1 deletion spectrum_fundamentals/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ class RescoreType(Enum):

CHARGES = [1, 2, 3] # limited to uint8 (0-255) when array is created
POSITIONS = [x for x in range(1, 30)] # fragment numbers 1-29 -- limited to uint8 (0-255) when array is created

POSITIONS_XL = [x for x in range(1, 59)]
ANNOTATION_FRAGMENT_TYPE = []
ANNOTATION_FRAGMENT_CHARGE = []
ANNOTATION_FRAGMENT_NUMBER = []
Expand Down
26 changes: 15 additions & 11 deletions spectrum_fundamentals/metrics/percolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def __init__(
drop_miss_cleavage_flag: Optional[bool] = False,
):
"""Initialize a Percolator obj."""
super().__init__(pred_intensities, true_intensities, mz, "CROSSLINKER_TYPE" in metadata.columns)

self.metadata = metadata
self.input_type = input_type
self.all_features_flag = all_features_flag
Expand All @@ -70,7 +72,7 @@ def __init__(
self.fdr_cutoff = fdr_cutoff
self.neutral_loss_flag = neutral_loss_flag
self.drop_miss_cleavage_flag = drop_miss_cleavage_flag
self.xl = "CROSSLINKER_TYPE" in self.metadata.columns

self.base_columns = [
"raw_file",
"scan_number",
Expand All @@ -94,10 +96,9 @@ def __init__(
"mass_analyzer",
"mz_range",
"collision_energy",
"proteins",
]

super().__init__(pred_intensities, true_intensities, mz)

@staticmethod
def sample_balanced_over_bins(retention_time_df: pd.DataFrame, sample_size: int = 5000) -> pd.Index:
"""
Expand Down Expand Up @@ -328,19 +329,17 @@ def add_percolator_metadata_columns(self):
"""Add metadata columns needed by percolator, e.g. to identify a PSM."""
if self.xl:
spec_id_cols = ["RAW_FILE", "SCAN_NUMBER", "MODIFIED_SEQUENCE_A", "MODIFIED_SEQUENCE_B", "PRECURSOR_CHARGE"]
self.metrics_val["Peptide"] = (
self.metadata["MODIFIED_SEQUENCE_A"] + "_" + self.metadata["MODIFIED_SEQUENCE_B"]
).apply(lambda x: "_." + x + "._")
self.metrics_val["Proteins"] = (
self.metadata["MODIFIED_SEQUENCE_A"] + "_" + self.metadata["MODIFIED_SEQUENCE_B"]
modified_sequence_a = self.metadata["MODIFIED_SEQUENCE_A"].astype(str)
modified_sequence_b = self.metadata["MODIFIED_SEQUENCE_B"].astype(str)
self.metrics_val["Peptide"] = (modified_sequence_a + "_" + modified_sequence_b).apply(
lambda x: "_." + x + "._"
)
self.metrics_val["Proteins"] = modified_sequence_a + "_" + modified_sequence_b
self.metrics_val["Label"] = self.target_decoy_labels
else:
spec_id_cols = ["RAW_FILE", "SCAN_NUMBER", "MODIFIED_SEQUENCE", "PRECURSOR_CHARGE"]
self.metrics_val["Peptide"] = self.metadata["MODIFIED_SEQUENCE"].apply(lambda x: "_." + x + "._")
self.metrics_val["Proteins"] = self.metadata[
"MODIFIED_SEQUENCE"
] # we don't need the protein ID to get PSM / peptide results, fill with peptide sequence
self.metrics_val["Proteins"] = self.metadata["PROTEINS"]

if "SCAN_EVENT_NUMBER" in self.metadata.columns:
spec_id_cols.append("SCAN_EVENT_NUMBER")
Expand Down Expand Up @@ -469,6 +468,11 @@ def calc(self): # noqa: C901
if self.neutral_loss_flag:
self.metrics_val["ANNOTATED_NL_COUNT"] = self.metadata["ANNOTATED_NL_COUNT"]
self.metrics_val["EXPECTED_NL_COUNT"] = self.metadata["EXPECTED_NL_COUNT"]
columns_to_remove = []
for col in self.metrics_val.columns:
if "vs_predicted" in col:
columns_to_remove.append(col)
self.metrics_val.drop(columns=columns_to_remove, inplace=True)
if self.drop_miss_cleavage_flag:
self.metrics_val.drop(columns=["missedCleavages", "KR"], inplace=True)
if self.xl:
Expand Down
7 changes: 4 additions & 3 deletions spectrum_fundamentals/metrics/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,6 @@ def _calc_additional_metrics(
true_intensities, pred_intensities, "max"
)
self.metrics_val[f"mse{key_suffix}"] = SimilarityMetrics.abs_diff(true_intensities, pred_intensities, "mse")
self.metrics_val[f"modified_cosine{key_suffix}"] = SimilarityMetrics.modified_cosine(
true_intensities, pred_intensities, self.mz, self.mz
)

col_names_spectral_angle = [
f"spectral_angle_{amount}_charge{key_suffix}" for amount in ["single", "double", "triple"]
Expand Down Expand Up @@ -539,3 +536,7 @@ def _calc_additional_metrics(
self.metrics_val[col_name_spearman_corr] = SimilarityMetrics.correlation(
true_intensities, pred_intensities, i + 1, "spearman"
)

self.metrics_val[f"modified_cosine{key_suffix}"] = SimilarityMetrics.modified_cosine(
true_intensities, pred_intensities, self.mz, self.mz
)
18 changes: 9 additions & 9 deletions tests/unit_tests/data/perc_input.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
,RAW_FILE,SCAN_NUMBER,MODIFIED_SEQUENCE,SEQUENCE,PRECURSOR_CHARGE,MASS,CALCULATED_MASS,SCORE,REVERSE,FRAGMENTATION,MASS_ANALYZER,SCAN_EVENT_NUMBER,RETENTION_TIME,PREDICTED_IRT,COLLISION_ENERGY
0,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,7978,AAIGEATRL,AAIGEATRL,2,900.50345678,900.50288029264,60.43600000000001,False,HCD,FTMS,1,0.5000000183883155,0.5000000323590892,30.0
1,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,12304,AAVPRAAFL,AAVPRAAFL,2,914.53379,914.53379,34.006,True,HCD,FTMS,2,1.000000038995633,1.5000000246189773,30.0
2,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,12398,AAYFGVYDTAK,AAYFGVYDTAK,2,1204.5764,1204.5764,39.97399999999999,True,HCD,FTMS,3,1.5000000993570157,2.500000056694346,30.0
3,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,11716,AAYYHPSYL,AAYYHPSYL,2,1083.5025,1083.5025,99.919,False,HCD,FTMS,4,2.0000000098074193,3.5000000203256407,30.0
4,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,5174,AEDLNTRVA,AEDLNTRVA,2,987.49852,987.49852,87.802,False,HCD,FTMS,5,2.500000083793533,4.5000000747038005,30.0
5,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,5174,AEDLNTRVA,AEDLNTRVA,2,987.49852,987.49852,62.802,False,HCD,FTMS,6,3.0000000338727677,5.5000000960095505,30.0
6,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,5174,AEDLNTRVA,AEDLNTRVA,2,987.49852,987.49852,79.802,False,HCD,FTMS,7,3.500000001673834,6.5000000134594345,30.0
7,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,5174,AEDLNTRVA,AEDLNTRVA,2,987.49852,987.49852,79.802,False,HCD,FTMS,8,4.000000066050141,7.500000085284446,30.0
,RAW_FILE,SCAN_NUMBER,MODIFIED_SEQUENCE,SEQUENCE,PRECURSOR_CHARGE,MASS,CALCULATED_MASS,SCORE,REVERSE,FRAGMENTATION,MASS_ANALYZER,SCAN_EVENT_NUMBER,RETENTION_TIME,PREDICTED_IRT,COLLISION_ENERGY,PROTEINS
0,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,7978,AAIGEATRL,AAIGEATRL,2,900.5034568,900.5028803,60.436,FALSE,HCD,FTMS,1,0.500000018,0.500000032,30,sp|O23523|RGGA_ARATH
1,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,12304,AAVPRAAFL,AAVPRAAFL,2,914.53379,914.53379,34.006,TRUE,HCD,FTMS,2,1.000000039,1.500000025,30,sp|O23523|RGGA_ARATH
2,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,12398,AAYFGVYDTAK,AAYFGVYDTAK,2,1204.5764,1204.5764,39.974,TRUE,HCD,FTMS,3,1.500000099,2.500000057,30,sp|O23523|RGGA_ARATH
3,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,11716,AAYYHPSYL,AAYYHPSYL,2,1083.5025,1083.5025,99.919,FALSE,HCD,FTMS,4,2.00000001,3.50000002,30,sp|O23523|RGGA_ARATH
4,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,5174,AEDLNTRVA,AEDLNTRVA,2,987.49852,987.49852,87.802,FALSE,HCD,FTMS,5,2.500000084,4.500000075,30,sp|O23523|RGGA_ARATH
5,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,5174,AEDLNTRVA,AEDLNTRVA,2,987.49852,987.49852,62.802,FALSE,HCD,FTMS,6,3.000000034,5.500000096,30,sp|O23523|RGGA_ARATH
6,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,5174,AEDLNTRVA,AEDLNTRVA,2,987.49852,987.49852,79.802,FALSE,HCD,FTMS,7,3.500000002,6.500000013,30,sp|O23523|RGGA_ARATH
7,20210122_0263_TMUCLHan_Peiru_DDA_IP_C797S_02,5174,AEDLNTRVA,AEDLNTRVA,2,987.49852,987.49852,79.802,FALSE,HCD,FTMS,8,4.000000066,7.500000085,30,sp|O23523|RGGA_ARATH
2 changes: 1 addition & 1 deletion tests/unit_tests/test_percolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def test_calc(self):
# np.testing.assert_almost_equal(percolator.metrics_val['ExpMass'][0], 900.50345678)
np.testing.assert_string_equal(percolator.metrics_val["Peptide"][0], "_.AAIGEATRL._")
np.testing.assert_string_equal(
percolator.metrics_val["Proteins"][0], "AAIGEATRL"
percolator.metrics_val["Proteins"][0], "sp|O23523|RGGA_ARATH"
) # we don't need the protein ID to get PSM / peptide results

# features
Expand Down

0 comments on commit 03b0249

Please sign in to comment.