Skip to content

Commit

Permalink
Merge pull request #111 from ExposuresProvider/add-testing
Browse files Browse the repository at this point in the history
This PR adds a test suite in Python for CAM-KP-API to cam-pipeline. Some of this code has been moved over from https://github.com/ExposuresProvider/cam-kp-api and the rest has been newly written for this.

There are three tests here:
- test_api.py: test the Automat-CAM-KP API endpoints.
- test_examples.py: tests the example files in `examples/`.
- test_curies.py: test a set of CURIEs to see if Automat-CAM-KP has information or not about them. This currently includes failing tests from #101

I tried to move over the integration tests from CAM-KP-API, but I couldn't work out the easiest way to figure out how to move them over as a Scala project. I think these Python tests are easier to read and maintain, but I'm happy to be proved wrong.

Closes #94
  • Loading branch information
gaurav authored Feb 13, 2024
2 parents b158f1e + c539c74 commit 0cb6dab
Show file tree
Hide file tree
Showing 13 changed files with 3,135 additions and 0 deletions.
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used only by the Python testing code in `tests/`.
pytest
requests
black
42 changes: 42 additions & 0 deletions tests/examples/chemicals-affected-by-prcd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"meta": {
"description": "Chemicals affected by gene Photoreceptor Disc Component (PRCD, NCBIGene:768206)"
},
"query": {
"message": {
"query_graph": {
"nodes": {
"gene": {
"categories": [
"biolink:Gene"
],
"ids": [
"NCBIGene:768206"
]
},
"chemical": {
"categories": [
"biolink:ChemicalEntity"
]
}
},
"edges": {
"t_edge": {
"object": "gene",
"subject": "chemical",
"predicates": [
"biolink:affects"
],
"knowledge_type": "inferred"
}
}
}
}
},
"assertions": [
{
"type": "ExpectedResultCounts",
"min": 17
}
]
}
43 changes: 43 additions & 0 deletions tests/examples/chemicals-decreasing-ncbigene-1956.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"meta": {
"description": "Chemicals decreasing the activity of epidermal growth factor receptor (NCBIGene:1956)"
},
"query": {
"message": {
"query_graph": {
"nodes": {
"n0": {
"name": "Chemical Entity",
"categories": [
"biolink:ChemicalEntity"
]
},
"n1": {
"name": "EGFR",
"ids": [
"NCBIGene:1956"
],
"categories": [
"biolink:Gene"
]
}
},
"edges": {
"e0": {
"subject": "n1",
"object": "n0",
"predicates": [
"biolink:affects"
]
}
}
}
}
},
"assertions": [
{
"type": "ExpectedResultCounts",
"min": 35
}
]
}
53 changes: 53 additions & 0 deletions tests/examples/genes-affecting-genes-found-in-leukocytes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"meta": {
"description": "Find genes that affect the activity of ‘GPR35’, specifically occurring within leukocytes (CL:0000738)"
},
"query": {
"message": {
"query_graph": {
"nodes": {
"n0": {
"categories": [
"biolink:GeneOrGeneProduct"
]
},
"n1": {
"categories": [
"biolink:GeneOrGeneProduct"
]
},
"n2": {
"categories": [
"biolink:AnatomicalEntity"
],
"ids": [
"CL:0000738"
]
}
},
"edges": {
"e0": {
"subject": "n0",
"object": "n1",
"predicates": [
"biolink:affects"
]
},
"e1": {
"subject": "n1",
"object": "n2",
"predicates": [
"biolink:overlaps"
]
}
}
}
}
},
"assertions": [
{
"type": "ExpectedResultCounts",
"min": 5
}
]
}
35 changes: 35 additions & 0 deletions tests/examples/genetic-pathway-positive-control.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"meta": {
"description": "Half the genetic pathway 'positive control' from the June 2022 Relay at https://docs.google.com/presentation/d/1V_K_bgyLWEP2neTdM0TD7Bs-GtJUmqCt8p6BzWTv96s/edit?pli=1#slide=id.p"
},
"query": {
"message": {
"query_graph": {
"nodes": {
"n0": {
"ids": [
"NCBIGene:5468"
]
},
"n1": {
"categories": [
"biolink:BiologicalProcess"
]
}
},
"edges": {
"e01": {
"object": "n0",
"subject": "n1"
}
}
}
}
},
"assertions": [
{
"type": "ExpectedResultCounts",
"min": 8
}
]
}
44 changes: 44 additions & 0 deletions tests/examples/molecular-activity-with-valproic-acid-as-input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"meta": {
"description": "Molecular activity that has valproic acid (PUBCHEM.COMPOUND:3121) as an input"
},
"query": {
"message": {
"query_graph": {
"nodes": {
"n0": {
"categories": [
"biolink:MolecularActivity"
]
},
"n1": {
"ids": [
"PUBCHEM.COMPOUND:3121"
]
}
},
"edges": {
"e0": {
"subject": "n0",
"object": "n1",
"predicates": [
"biolink:has_input"
]
}
}
}
}
},
"assertions": [
{
"type": "ExpectedResultCounts",
"min": 1
},
{
"type": "ExpectedNodeResults",
"node": "n0",
"resultEquals": ["GO:0005488"],
"description": "Expected binding (GO:0005488) to have valproic acid (PUBCHEM.COMPOUND:3121) as an input."
}
]
}
44 changes: 44 additions & 0 deletions tests/examples/proteins-that-interact-with-pyruvate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"meta": {
"description": "Named things related to pyruvate (PUBCHEM.COMPOUND:107735)"
},
"query": {
"message": {
"query_graph": {
"nodes": {
"n0": {
"categories": [
"biolink:Protein"
]
},
"n1": {
"ids": [
"PUBCHEM.COMPOUND:107735"
]
}
},
"edges": {
"e0": {
"subject": "n0",
"object": "n1",
"predicates": [
"biolink:interacts_with"
]
}
}
}
}
},
"assertions": [
{
"type": "ExpectedResultCounts",
"min": 6
},
{
"type": "ExpectedNodeResults",
"node": "n0",
"resultEquals": ["UniProtKB:P21796", "UniProtKB:P26297", "UniProtKB:Q9BYZ2", "UniProtKB:Q1EHB4",
"UniProtKB:P11498", "UniProtKB:Q8N695"]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"meta": {
"description": "What gene or gene product is part of the plasma membrane?"
},
"query": {
"message": {
"query_graph": {
"nodes": {
"n0": {
"categories": [
"biolink:GeneOrGeneProduct"
]
},
"n1": {
"categories": [
"biolink:AnatomicalEntity"
],
"ids": [
"GO:0005886"
]
}
},
"edges": {
"e0": {
"subject": "n0",
"object": "n1",
"predicates": [
"biolink:part_of"
]
}
}
}
}
},
"assertions": [
{
"type": "ExpectedResultCounts",
"min": 10
}
]
}
44 changes: 44 additions & 0 deletions tests/examples/what-regulates-mapk-activity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"meta": {
"description": "What regulates MAP kinase activity (GO:0004707)?"
},
"query": {
"message": {
"query_graph": {
"nodes": {
"n0": {
"categories": [
"biolink:NamedThing"
]
},
"n1": {
"ids": [
"GO:0004707"
]
}
},
"edges": {
"e0": {
"predicates": [
"biolink:regulates"
],
"subject": "n0",
"object": "n1"
}
}
}
}
},
"assertions": [
{
"type": "ExpectedResultCounts",
"min": 85
},
{
"type": "ExpectedNodeResults",
"node": "n0",
"resultIncludes": ["GO:0004708", "GO:0004709"],
"description": "MAP kinase activity (GO:0004707) is regulated by MAP kinase kinase activity (GO:0004708) and MAP kinase kinase kinase activity (GO:0004709)"
}
]
}
Loading

0 comments on commit 0cb6dab

Please sign in to comment.