Skip to content

Commit

Permalink
Fixed pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlaltaf committed Jun 17, 2024
1 parent 6f59c78 commit f160609
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def main():
go_protein_pairs,
sample_size,
protein_list,
graph_file_path,
dataset_directory_path,
testing_graph_file_path,
testing_input_directory_path,
output_data_path,
output_image_path,
repeats,
Expand Down
35 changes: 16 additions & 19 deletions tests/test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
from classes.protein_degree_v3_class import ProteinDegreeV3
from classes.sample_algorithm import SampleAlgorithm
from classes.base_algorithm_class import BaseAlgorithm
from classes.hypergeometric_distribution_class import HypergeometricDistribution
from classes.hypergeometric_distribution_class_V2 import HypergeometricDistributionV2

from pathlib import Path
from tools.helper import (
read_specific_columns,
import_graph_from_pickle,
)
from tools.workflow import run_workflow
from tools.workflow import run_experiement
import os



def test_algorithm_attributes():
algorithm_classes = {
"OverlappingNeighbors": OverlappingNeighbors,
Expand All @@ -26,7 +24,8 @@ def test_algorithm_attributes():
"ProteinDegree": ProteinDegree,
"ProteinDegreeV2": ProteinDegreeV2,
"ProteinDegreeV3": ProteinDegreeV3,
"SampleAlgorithm": SampleAlgorithm,
"HypergeometricDistribution": HypergeometricDistribution,
"HypergeometricDistributionV2": HypergeometricDistributionV2,
}
for algorithm in algorithm_classes:
assert hasattr(algorithm_classes[algorithm](), "y_score")
Expand All @@ -41,14 +40,15 @@ def test_algorithm_inherits_class():
"ProteinDegree": ProteinDegree,
"ProteinDegreeV2": ProteinDegreeV2,
"ProteinDegreeV3": ProteinDegreeV3,
"SampleAlgorithm": SampleAlgorithm,
"HypergeometricDistribution": HypergeometricDistribution,
"HypergeometricDistributionV2": HypergeometricDistributionV2,
}

for algorithm in algorithm_classes:
assert issubclass(algorithm_classes[algorithm], BaseAlgorithm)


def test_algorithm_workflow():
def test_algorithm_experiment():
if not os.path.exists("output"):
os.makedirs("output")
if not os.path.exists("output/dataset"):
Expand All @@ -70,9 +70,11 @@ def test_algorithm_workflow():
"ProteinDegree": ProteinDegree,
"ProteinDegreeV2": ProteinDegreeV2,
"ProteinDegreeV3": ProteinDegreeV3,
"HypergeometricDistribution": HypergeometricDistribution,
"HypergeometricDistributionV2": HypergeometricDistributionV2,
}

results = run_workflow(
results = run_experiement(
algorithm_classes,
input_directory_path,
graph_file_path,
Expand All @@ -88,10 +90,8 @@ def test_algorithm_workflow():
"ProteinDegree": 0.825,
"ProteinDegreeV2": 0.675,
"ProteinDegreeV3": 0.89,
"HypergeometricDistribution": 0.78,
"HypergeometricDistributionV2": 0.89,
"HypergeometricDistributionV3": 0.675,
"HypergeometricDistributionV4": 0.6
"HypergeometricDistribution": 0.76,
"HypergeometricDistributionV2": 0.86,
}

pr_results = {
Expand All @@ -101,11 +101,8 @@ def test_algorithm_workflow():
"OverlappingNeighborsV2": 0.7467907092907092,
"ProteinDegreeV2": 0.6367757242757243,
"OverlappingNeighbors": 0.5329058916229968,
"SampleAlgorithm": 0.4093791854859966,
"HypergeometricDistribution": 0.7899246806,
"HypergeometricDistributionV2": 0.8519169719,
"HypergeometricDistributionV3": 0.7142573629,
"HypergeometricDistributionV4": 0.6967847007,
"HypergeometricDistribution": 0.7899246805825753,
"HypergeometricDistributionV2": 0.8519169719169718,
}

for algorithm, metrics in results.items():
Expand Down
6 changes: 3 additions & 3 deletions tools/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def run_workflow(
): # Creates a pos/neg list each replicate then runs workflow like normal
print("\n\nReplicate: " + str(i) + "\n")

positive_dataset, negative_dataset = sample_data(
go_protein_pairs, sample_size, protein_list, G, dataset_directory_path
)
# positive_dataset, negative_dataset = sample_data(
# go_protein_pairs, sample_size, protein_list, G, dataset_directory_path
# )

results = run_experiement(
algorithm_classes,
Expand Down

0 comments on commit f160609

Please sign in to comment.