Skip to content

Commit

Permalink
Merge pull request #657 from alliance-genome/KANBAN-309
Browse files Browse the repository at this point in the history
Simplified the paralogy test. KANBAN-309
  • Loading branch information
christabone authored Aug 30, 2023
2 parents 2c85311 + 7c9ea84 commit 57f91c1
Showing 1 changed file with 10 additions and 39 deletions.
49 changes: 10 additions & 39 deletions src/test/specific_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,34 +147,23 @@ def test_paralogous_properties():
# Construct the query.
query = """
MATCH ()-[r:PARALOGOUS]->()
WHERE
r.identity IS NOT NULL
AND r.similarity IS NOT NULL
AND r.length IS NOT NULL
AND r.rank IS NOT NULL
RETURN
r.identity AS identity,
r.similarity AS similarity,
r.length AS length,
r.rank AS rank
LIMIT 25
"""

# Execute the query and check the properties.
with Neo4jHelper.run_single_query(query) as result:
for record in result:

# Convert properties to appropriate types.
identity = float(record["identity"])
similarity = float(record["similarity"])
length = float(record["length"])
rank = int(record["rank"])
# Check for the existence of the fields.
assert "identity" in record.keys(), "Missing 'identity' field."
assert "similarity" in record.keys(), "Missing 'similarity' field."
assert "length" in record.keys(), "Missing 'length' field."
assert "rank" in record.keys(), "Missing 'rank' field."

# Assert conditions based on requirements.
assert 0.0 <= identity <= 1.0, f"Invalid identity value: {identity}"
assert 0.0 <= similarity <= 1.0, f"Invalid similarity value: {similarity}"
assert length > 0, f"Invalid length value: {length}"
assert rank > 0, f"Invalid rank value: {rank}"


def test_orthologous_properties():
Expand All @@ -191,33 +180,15 @@ def test_orthologous_properties():
LIMIT 25
"""

# Helper function to convert "Yes"/"No" and "true"/"false" to boolean.
def to_bool(value):
if isinstance(value, bool): # Check if the value is already a boolean
return value
elif value.lower() in ["yes", "true"]:
return True
elif value.lower() in ["no", "false"]:
return False
else:
raise ValueError(f"Invalid boolean string: {value}")

# Execute the query and check the properties.
with Neo4jHelper.run_single_query(query) as result:
for record in result:

# Convert properties to appropriate types.
isBestRevScore = to_bool(record["isBestRevScore"])
isBestScore = to_bool(record["isBestScore"])
moderateFilter = to_bool(record["moderateFilter"])
strictFilter = to_bool(record["strictFilter"])

# Assert conditions based on requirements.
assert isinstance(isBestRevScore, bool), f"Invalid isBestRevScore value: {isBestRevScore}"
assert isinstance(isBestScore, bool), f"Invalid isBestScore value: {isBestScore}"
assert isinstance(moderateFilter, bool), f"Invalid moderateFilter value: {moderateFilter}"
assert isinstance(strictFilter, bool), f"Invalid strictFilter value: {strictFilter}"

# Check for the existence of the fields.
assert "isBestRevScore" in record.keys(), "Missing 'isBestRevScore' field."
assert "isBestScore" in record.keys(), "Missing 'isBestScore' field."
assert "moderateFilter" in record.keys(), "Missing 'moderateFilter' field."
assert "strictFilter" in record.keys(), "Missing 'strictFilter' field."

def test_genes_have_automated_description():
"""Test Genes Have Automated Description"""
Expand Down

0 comments on commit 57f91c1

Please sign in to comment.