-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests, rename scipts to "_", add to ci
- Loading branch information
Terézia Slanináková
committed
Oct 1, 2024
1 parent
f061c9b
commit bf0ad0e
Showing
9 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,6 @@ kubectl | |
data/bucket-* | ||
data/embedding.pkl | ||
data/kmeans.idx | ||
models/ | ||
models/ | ||
.coverage | ||
coverage.xml |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[pytest] | ||
testpaths = . | ||
python_files = tests.py | ||
addopts = --cov=. --cov-report=term-missing --cov-report=xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ pre-commit | |
black==23.7.0 | ||
isort==5.12.0 | ||
flake8==6.1.0 | ||
pytest | ||
pytest-cov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
from create_embedding import run | ||
import pandas as pd | ||
import re | ||
|
||
|
||
def parse_protein_id(filename): | ||
# Use regex to extract the protein ID | ||
match = re.search(r'AF-([\w\d]+)-F1-model_v3\.cif', filename) | ||
if match: | ||
return match.group(1) | ||
return None | ||
|
||
|
||
def test_create_embedding(): | ||
cif_path = "./data/cifs" | ||
output_path = "./data/embedding.pkl" | ||
granularity = 10 | ||
|
||
# 45 features for each protein - (10x10 - 10) / 2 | ||
expected_dimensionality = 45 | ||
|
||
run(Path(cif_path), Path(output_path), granularity) | ||
|
||
assert os.path.exists(output_path) | ||
assert os.path.getsize(output_path) > 0 | ||
# load embedding.pkl and check if it has the correct shape | ||
df = pd.read_pickle(output_path) | ||
assert df.shape[0] == len(os.listdir(cif_path)) | ||
assert df.shape[1] == expected_dimensionality | ||
|
||
# check if the length of the index is equal to the number of proteins | ||
assert sorted(df.index.tolist()) == sorted( | ||
[parse_protein_id(file) for file in os.listdir(cif_path) if file.endswith('.cif')] | ||
) |