Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Zulkower committed Dec 16, 2024
1 parent fc6b476 commit 44f8616
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
11 changes: 11 additions & 0 deletions test/data/boltz_input_ligand.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 1 # Optional, defaults to 1
sequences:
- protein:
id: [A, B]
sequence: MVTPEGNVSLVDESLLVGVTDEDRAVRSAHQ
- ligand:
id: [C, D]
ccd: SAH
- ligand:
id: [E, F]
smiles: N[C@@H](Cc1ccc(O)cc1)C(=O)O
8 changes: 8 additions & 0 deletions test/data/boltz_input_multimer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 1 # Optional, defaults to 1
sequences:
- protein:
id: A
sequence: MAHHHHHHVAVDAVSFTLLQDQLQSVLDTL
- protein:
id: B
sequence: MRYAFAAEATTCNAFWRNVDMTVTALYEVPLGVCTQDPDRW
5 changes: 5 additions & 0 deletions test/data/boltz_input_single_protein.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 1 # Optional, defaults to 1
sequences:
- protein:
id: A
sequence: MAHHHHHHVAVDAVSFTLLQDQLQSVLDTL
16 changes: 15 additions & 1 deletion test/test_models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import tempfile
from pathlib import Path
import pytest

from ginkgo_ai_client import (
Expand All @@ -6,6 +8,7 @@
MeanEmbeddingQuery,
PromoterActivityQuery,
DiffusionMaskedQuery,
BoltzStructurePredictionQuery,
)


Expand Down Expand Up @@ -63,6 +66,7 @@ def test_promoter_activity():
assert "heart" in response.activity_by_tissue
assert "liver" in response.activity_by_tissue


@pytest.mark.parametrize(
"model, sequence",
[
Expand All @@ -73,7 +77,7 @@ def test_promoter_activity():
def test_diffusion_masked_inference(model, sequence):
client = GinkgoAIClient()
query = DiffusionMaskedQuery(
sequence=sequence, #upper and lower cases
sequence=sequence, # upper and lower cases
model=model,
temperature=0.5,
decoding_order_strategy="entropy",
Expand All @@ -82,3 +86,13 @@ def test_diffusion_masked_inference(model, sequence):
response = client.send_request(query)
assert isinstance(response.sequence, str)
assert "<mask>" not in response.sequence


def test_boltz_structure_prediction():
client = GinkgoAIClient()
data_file = Path(__file__).parent / "data" / "boltz_input_single_chain.yaml"
query = BoltzStructurePredictionQuery.from_yaml_file(data_file)
response = client.send_request(query)
with tempfile.TemporaryDirectory() as temp_dir:
response.download_structure(Path(temp_dir) / "structure.cif")
response.download_structure(Path(temp_dir) / "structure.pdb")
26 changes: 25 additions & 1 deletion test/test_query_creation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import pytest
import re
from pathlib import Path
from ginkgo_ai_client.queries import MeanEmbeddingQuery, PromoterActivityQuery
from ginkgo_ai_client.queries import (
MeanEmbeddingQuery,
PromoterActivityQuery,
BoltzStructurePredictionQuery,
)


def test_that_forgetting_to_name_arguments_raises_the_better_error_message():
Expand Down Expand Up @@ -37,3 +41,23 @@ def test_promoter_activity_iteration():
},
)
assert len(queries) == 50


@pytest.mark.parametrize(
"filename, expected_sequences",
[
("boltz_input_ligand.yaml", 3),
("boltz_input_multimer.yaml", 2),
],
)
def test_boltz_structure_prediction_query_from_yaml_file(filename, expected_sequences):
query = BoltzStructurePredictionQuery.from_yaml_file(
Path(__file__).parent / "data" / filename
)
assert len(query.sequences) == expected_sequences


def test_boltz_structure_prediction_query_from_protein_sequence():
query = BoltzStructurePredictionQuery.from_protein_sequence(sequence="MLLKP")
sequences = query.model_dump(exclude_none=True)["sequences"]
assert sequences == [{"protein": {"id": "A", "sequence": "MLLKP"}}]

0 comments on commit 44f8616

Please sign in to comment.