Skip to content

Commit

Permalink
Merge pull request #6 from pluskal-lab/issue05
Browse files Browse the repository at this point in the history
Create basic_ci.yml
  • Loading branch information
roman-bushuiev authored May 25, 2024
2 parents e9b44ff + 85ddb44 commit 010f567
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 38 deletions.
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

0 comments on commit 010f567

Please sign in to comment.