diff --git a/.cookietemple.yml b/.cookietemple.yml index 7459a05..a386290 100644 --- a/.cookietemple.yml +++ b/.cookietemple.yml @@ -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.7 +version: 0.7.8 license: MIT diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 806aea3..902c9de 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,5 +1,5 @@ -name-template: "0.7.7 " # <> -tag-template: 0.7.7 # <> +name-template: "0.7.8 " # <> +tag-template: 0.7.8 # <> exclude-labels: - "skip-changelog" diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index 8c35afe..0dd9cb6 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml @@ -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 }} diff --git a/.github/workflows/main_master_branch_protection.yml b/.github/workflows/main_master_branch_protection.yml index b8eb3d9..8619c3a 100644 --- a/.github/workflows/main_master_branch_protection.yml +++ b/.github/workflows/main_master_branch_protection.yml @@ -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 diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml index 8d5ac9c..bf649a2 100644 --- a/.github/workflows/publish_docs.yml +++ b/.github/workflows/publish_docs.yml @@ -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 diff --git a/.github/workflows/publish_package.yml b/.github/workflows/publish_package.yml index ff86ea9..60093c0 100644 --- a/.github/workflows/publish_package.yml +++ b/.github/workflows/publish_package.yml @@ -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" @@ -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 diff --git a/.github/workflows/run_cookietemple_lint.yml b/.github/workflows/run_cookietemple_lint.yml index 3b3ef4f..1af37d3 100644 --- a/.github/workflows/run_cookietemple_lint.yml +++ b/.github/workflows/run_cookietemple_lint.yml @@ -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 diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 1a2ce98..080d0c4 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -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 }} @@ -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 @@ -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 diff --git a/.github/workflows/sync_project.yml b/.github/workflows/sync_project.yml index ab6b647..111650e 100644 --- a/.github/workflows/sync_project.yml +++ b/.github/workflows/sync_project.yml @@ -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 diff --git a/cookietemple.cfg b/cookietemple.cfg index 4fdf161..e174cfc 100644 --- a/cookietemple.cfg +++ b/cookietemple.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.7.7 +current_version = 0.7.8 [bumpversion_files_whitelisted] init_file = spectrum_fundamentals/__init__.py diff --git a/docs/conf.py b/docs/conf.py index 2b90c61..0d12982 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -52,9 +52,9 @@ # the built documents. # # The short X.Y version. -version = "0.7.7" +version = "0.7.8" # The full version, including alpha/beta/rc tags. -release = "0.7.7" +release = "0.7.8" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/pyproject.toml b/pyproject.toml index 6c8ef0a..9bebb9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "spectrum_fundamentals" -version = "0.7.7" # <> +version = "0.7.8" # <> description = "Fundamental functions, annotation pipeline and constants for oktoberfest" authors = ["Wilhelmlab at Technical University of Munich"] license = "MIT" diff --git a/spectrum_fundamentals/__init__.py b/spectrum_fundamentals/__init__.py index 1b67d97..741dd90 100644 --- a/spectrum_fundamentals/__init__.py +++ b/spectrum_fundamentals/__init__.py @@ -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.7" +__version__ = "0.7.8" import logging import logging.handlers diff --git a/spectrum_fundamentals/__main__.py b/spectrum_fundamentals/__main__.py index 31fea9c..e59a495 100644 --- a/spectrum_fundamentals/__main__.py +++ b/spectrum_fundamentals/__main__.py @@ -5,7 +5,7 @@ @click.command() -@click.version_option(version="0.7.7", message=click.style("spectrum_fundamentals Version: 0.7.7")) +@click.version_option(version="0.7.8", message=click.style("spectrum_fundamentals Version: 0.7.8")) def main() -> None: """spectrum_fundamentals.""" diff --git a/spectrum_fundamentals/constants.py b/spectrum_fundamentals/constants.py index 68f1942..f3781cb 100644 --- a/spectrum_fundamentals/constants.py +++ b/spectrum_fundamentals/constants.py @@ -510,7 +510,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 = [] diff --git a/spectrum_fundamentals/metrics/percolator.py b/spectrum_fundamentals/metrics/percolator.py index 17434d9..e10909d 100644 --- a/spectrum_fundamentals/metrics/percolator.py +++ b/spectrum_fundamentals/metrics/percolator.py @@ -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 @@ -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", @@ -97,8 +99,6 @@ def __init__( "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: """ @@ -327,12 +327,12 @@ 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"] diff --git a/spectrum_fundamentals/metrics/similarity.py b/spectrum_fundamentals/metrics/similarity.py index 24f81c5..e637ccc 100644 --- a/spectrum_fundamentals/metrics/similarity.py +++ b/spectrum_fundamentals/metrics/similarity.py @@ -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"] @@ -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 + )