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

Create basic_ci.yml #6

Merged
merged 4 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/basic_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Basic CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
basic_tests:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Python info
run: |
which python
python --version
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Show pip list
run: |
pip list
- name: Run tests
run: |
pytest
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@
"seaborn",
"standardizeUtils @ git+https://github.com/boecker-lab/standardizeUtils/#egg=standardizeUtils"
],
extras_require={"dev": ["black",
"pytest",
"pytest-cov",
],
}
)
41 changes: 41 additions & 0 deletions tests/test_tokenizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import numpy as np
import matchms
from massspecgym.transforms import SpecTokenizer


def test_spec_tokenizer():
spec = matchms.Spectrum(
mz=np.array(
[
45.134823,
45.13699,
110.096245,
130.064972,
136.111862,
277.16571,
289.165924,
307.177856,
406.223083,
]
),
intensities=np.array(
[
0.01082,
0.01064,
0.17184,
0.1397,
0.00874,
1.0,
0.52842,
0.00793,
0.43696
]
),
metadata={"precursor_mz": 406.22},
)

tokenizer = SpecTokenizer(n_peaks=60)
spec_np = tokenizer(spec)
assert spec_np.shape == (60, 2)
assert (spec_np[:spec.peaks.mz.shape[0], 0] == spec.peaks.mz).all()
assert (spec_np[:spec.peaks.intensities.shape[0], 1] == spec.peaks.intensities).all()
38 changes: 0 additions & 38 deletions tests/test.py → tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,44 +51,6 @@ def test_pad_spectrum():
assert False


def test_spec_tokenizer():
spec = matchms.Spectrum(
mz=np.array(
[
45.134823,
45.13699,
110.096245,
130.064972,
136.111862,
277.16571,
289.165924,
307.177856,
406.223083,
]
),
intensities=np.array(
[
0.01082,
0.01064,
0.17184,
0.1397,
0.00874,
1.0,
0.52842,
0.00793,
0.43696
]
),
metadata={"precursor_mz": 406.22},
)

tokenizer = SpecTokenizer(n_peaks=60)
spec_np = tokenizer(spec)
assert spec_np.shape == (60, 2)
assert (spec_np[:spec.peaks.mz.shape[0], 0] == spec.peaks.mz).all()
assert (spec_np[:spec.peaks.intensities.shape[0], 1] == spec.peaks.intensities).all()


def test_morgan_fp():
mol = Chem.MolFromSmiles("Cn1cnc2c1c(=O)n(C)c(=O)n2C")
for i in [2048, 4096]:
Expand Down
Loading