Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #44

Merged
merged 13 commits into from
May 17, 2024
Merged
8 changes: 8 additions & 0 deletions .github/workflows/_run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ jobs:
miniconda-version: "latest"
auto-update-conda: true
python-version: ${{ inputs.python-version }}
- name: Install mono
shell: bash -l {0}
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
conda install -y mono
fi
- name: Conda info
shell: bash -l {0}
run: conda info
Expand All @@ -35,12 +41,14 @@ jobs:
shell: bash -l {0}
run: |
conda activate alpharaw
pip install matplotlib
pip install pytest nbmake==1.5.3
conda deactivate
- name: Run tests
shell: bash -l {0}
run: |
conda activate alpharaw
cd tests
python download_test_data.py
. ./run_tests.sh
conda deactivate
6 changes: 4 additions & 2 deletions .github/workflows/pip_installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
name: Test stable pip installation on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest, macos-latest-xlarge]
# macos-latest is now arm64, which cannot install mono
os: [ubuntu-latest, macos-13, windows-latest]
uses: ./.github/workflows/_run_tests.yml
with:
os: ${{ matrix.os }}
Expand All @@ -31,7 +32,8 @@ jobs:
# runs-on: ${{ matrix.os }} # `runs-on` conflicts with `uses`, see https://github.com/orgs/community/discussions/62320
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest, macos-latest-xlarge]
# macos-latest is now arm64, which cannot install mono
os: [ubuntu-latest, macos-13, windows-latest]
uses: ./.github/workflows/_run_tests.yml
with:
os: ${{ matrix.os }}
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
*.raw
jalew188 marked this conversation as resolved.
Show resolved Hide resolved
*.wiff
*.wiff2
*.d
*.scan

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
3 changes: 2 additions & 1 deletion alpharaw/match/psm_match_alphatims.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def match_ms2_one_raw(self,

"""
self._preprocess_psms(psm_df_one_raw)
self.psm_df = psm_df_one_raw

psm_df_one_raw = self._add_missing_columns_to_psm_df(
psm_df_one_raw
Expand All @@ -248,7 +249,7 @@ def match_ms2_one_raw(self,
fragment_mz_df,
matched_intensity_df,
matched_mz_err_df,
) = self._prepare_matching_dfs(psm_df_one_raw)
) = self._prepare_matching_dfs()

if (
'mobility' in psm_df_one_raw.columns and
Expand Down
4 changes: 2 additions & 2 deletions alpharaw/sciex.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, centroided:bool=True,
if self.centroided:
self.centroided = False
warnings.warn('Centroiding for Sciex data is not well implemented yet')
self.centroid_mz_tol = 0.06
self.centroid_ppm = 20.0
self.ignore_empty_scans = True
self.keep_k_peaks_per_spec = 2000
self.sample_id = 0
Expand All @@ -46,7 +46,7 @@ def _import(self,
)
data_dict = wiff_reader.load_sample(self.sample_id,
centroid = self.centroided,
centroid_mz_tol = self.centroid_mz_tol,
centroid_ppm = self.centroid_ppm,
jalew188 marked this conversation as resolved.
Show resolved Hide resolved
ignore_empty_scans=self.ignore_empty_scans,
keep_k_peaks=self.keep_k_peaks_per_spec,
)
Expand Down
612 changes: 0 additions & 612 deletions nbs/feature_finding.ipynb

This file was deleted.

213 changes: 14 additions & 199 deletions nbs/psm_match_alphatims.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,9 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:root:WARNING: Temp mmap arrays are written to /var/folders/fh/hf8t3l1x02d42ggk3b304_rh0000gn/T/temp_mmap_iam1yqfl. Cleanup of this folder is OS dependant, and might need to be triggered manually! Current space: 699,914,002,432\n",
"WARNING:root:WARNING: No Bruker libraries are available for this operating system. Mobility and m/z values need to be estimated. While this estimation often returns acceptable results with errors < 0.02 Th, huge errors (e.g. offsets of 6 Th) have already been observed for some samples!\n"
]
}
],
"outputs": [],
"source": [
"from alpharaw.match.psm_match_alphatims import *"
"from alpharaw.match.psm_match_alphatims import PepSpecMatch_AlphaTims"
]
},
{
Expand All @@ -36,6 +27,8 @@
"#| hide\n",
"import io\n",
"import copy\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"import peptdeep.psm_frag_reader.psmlabel_reader #to register psmlabel_reader\n",
"from peptdeep.psm_frag_reader.psm_frag_reader import psm_w_frag_reader_provider\n",
Expand All @@ -47,19 +40,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "AssertionError",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[5], line 185\u001b[0m\n\u001b[1;32m 183\u001b[0m psm_df, mz_df, inten_df, merr_df \u001b[39m=\u001b[39m matching\u001b[39m.\u001b[39mmatch_ms2_one_raw(psm_df)\n\u001b[1;32m 184\u001b[0m \u001b[39m#np.sum(matching.matched_intensity_df.values!=0,axis=1)\u001b[39;00m\n\u001b[0;32m--> 185\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mlen\u001b[39m(merr_df\u001b[39m.\u001b[39mvalues[\u001b[39m~\u001b[39mnp\u001b[39m.\u001b[39misinf(merr_df\u001b[39m.\u001b[39mvalues)])\u001b[39m==\u001b[39m\u001b[39m3\u001b[39m\n\u001b[1;32m 186\u001b[0m \u001b[39massert\u001b[39;00m np\u001b[39m.\u001b[39mcount_nonzero(inten_df\u001b[39m.\u001b[39mvalues)\u001b[39m==\u001b[39m\u001b[39m3\u001b[39m\n",
"\u001b[0;31mAssertionError\u001b[0m: "
]
}
],
"outputs": [],
"source": [
"#| hide\n",
"#unittest\n",
Expand Down Expand Up @@ -302,181 +283,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>spec_idx</th>\n",
" <th>charge</th>\n",
" <th>precursor_mz</th>\n",
" <th>peak_start_idx</th>\n",
" <th>peak_stop_idx</th>\n",
" <th>rt</th>\n",
" <th>ms_level</th>\n",
" <th>isolation_lower_mz</th>\n",
" <th>isolation_upper_mz</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>100.0</td>\n",
" <td>0</td>\n",
" <td>62</td>\n",
" <td>0.016667</td>\n",
" <td>2</td>\n",
" <td>-1.0</td>\n",
" <td>-1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>-1</td>\n",
" <td>-1</td>\n",
" <td>0.000000</td>\n",
" <td>2</td>\n",
" <td>-1.0</td>\n",
" <td>-1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>-1</td>\n",
" <td>-1</td>\n",
" <td>0.000000</td>\n",
" <td>2</td>\n",
" <td>-1.0</td>\n",
" <td>-1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>100.0</td>\n",
" <td>62</td>\n",
" <td>119</td>\n",
" <td>0.033333</td>\n",
" <td>2</td>\n",
" <td>-1.0</td>\n",
" <td>-1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4</td>\n",
" <td>2</td>\n",
" <td>100.0</td>\n",
" <td>119</td>\n",
" <td>121</td>\n",
" <td>0.050000</td>\n",
" <td>2</td>\n",
" <td>-1.0</td>\n",
" <td>-1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>-1</td>\n",
" <td>-1</td>\n",
" <td>0.000000</td>\n",
" <td>2</td>\n",
" <td>-1.0</td>\n",
" <td>-1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>6</td>\n",
" <td>2</td>\n",
" <td>100.0</td>\n",
" <td>121</td>\n",
" <td>124</td>\n",
" <td>0.066667</td>\n",
" <td>2</td>\n",
" <td>-1.0</td>\n",
" <td>-1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>7</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>-1</td>\n",
" <td>-1</td>\n",
" <td>0.000000</td>\n",
" <td>2</td>\n",
" <td>-1.0</td>\n",
" <td>-1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>8</td>\n",
" <td>2</td>\n",
" <td>100.0</td>\n",
" <td>124</td>\n",
" <td>125</td>\n",
" <td>0.083333</td>\n",
" <td>2</td>\n",
" <td>-1.0</td>\n",
" <td>-1.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" spec_idx charge precursor_mz peak_start_idx peak_stop_idx rt \\\n",
"0 0 3 100.0 0 62 0.016667 \n",
"1 1 0 0.0 -1 -1 0.000000 \n",
"2 2 0 0.0 -1 -1 0.000000 \n",
"3 3 2 100.0 62 119 0.033333 \n",
"4 4 2 100.0 119 121 0.050000 \n",
"5 5 0 0.0 -1 -1 0.000000 \n",
"6 6 2 100.0 121 124 0.066667 \n",
"7 7 0 0.0 -1 -1 0.000000 \n",
"8 8 2 100.0 124 125 0.083333 \n",
"\n",
" ms_level isolation_lower_mz isolation_upper_mz \n",
"0 2 -1.0 -1.0 \n",
"1 2 -1.0 -1.0 \n",
"2 2 -1.0 -1.0 \n",
"3 2 -1.0 -1.0 \n",
"4 2 -1.0 -1.0 \n",
"5 2 -1.0 -1.0 \n",
"6 2 -1.0 -1.0 \n",
"7 2 -1.0 -1.0 \n",
"8 2 -1.0 -1.0 "
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"matching.get_peaks(100,)"
]
Expand All @@ -496,7 +303,15 @@
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
Expand Down
Loading
Loading