88from classes .protein_degree_v3_class import ProteinDegreeV3
99from classes .sample_algorithm import SampleAlgorithm
1010from classes .base_algorithm_class import BaseAlgorithm
11+ from classes .hypergeometric_distribution_class import HypergeometricDistribution
12+ from classes .hypergeometric_distribution_class_V2 import HypergeometricDistributionV2
13+
1114from pathlib import Path
1215from tools .helper import (
1316 read_specific_columns ,
@@ -70,6 +73,8 @@ def test_algorithm_workflow():
7073 "ProteinDegree" : ProteinDegree ,
7174 "ProteinDegreeV2" : ProteinDegreeV2 ,
7275 "ProteinDegreeV3" : ProteinDegreeV3 ,
76+ "HypergeometricDistribution" : HypergeometricDistribution ,
77+ "HypergeometricDistributionV2" : HypergeometricDistributionV2
7378 }
7479
7580 results = run_workflow (
@@ -88,10 +93,8 @@ def test_algorithm_workflow():
8893 "ProteinDegree" : 0.825 ,
8994 "ProteinDegreeV2" : 0.675 ,
9095 "ProteinDegreeV3" : 0.89 ,
91- "HypergeometricDistribution" : 0.78 ,
92- "HypergeometricDistributionV2" : 0.89 ,
93- "HypergeometricDistributionV3" : 0.675 ,
94- "HypergeometricDistributionV4" : 0.6
96+ "HypergeometricDistribution" : 0.76 ,
97+ "HypergeometricDistributionV2" : 0.86 ,
9598 }
9699
97100 pr_results = {
@@ -102,14 +105,122 @@ def test_algorithm_workflow():
102105 "ProteinDegreeV2" : 0.6367757242757243 ,
103106 "OverlappingNeighbors" : 0.5329058916229968 ,
104107 "SampleAlgorithm" : 0.4093791854859966 ,
105- "HypergeometricDistribution" : 0.7899246806 ,
106- "HypergeometricDistributionV2" : 0.8519169719 ,
107- "HypergeometricDistributionV3" : 0.7142573629 ,
108- "HypergeometricDistributionV4" : 0.6967847007 ,
108+ "HypergeometricDistribution" : 0.7899246805825753 ,
109+ "HypergeometricDistributionV2" : 0.8519169719169718 ,
110+ }
111+
112+ for algorithm , metrics in results .items ():
113+ assert metrics ["roc_auc" ] == roc_results [algorithm ]
114+
115+ for algorithm , metrics in results .items ():
116+ assert metrics ["pr_auc" ] == pr_results [algorithm ]
117+
118+
119+ def test_self_edge_case (): #Redundant but mostly for the sake of seperation, I can add it to the above section
120+ if not os .path .exists ("output" ):
121+ os .makedirs ("output" )
122+ if not os .path .exists ("output/dataset" ):
123+ os .makedirs ("output/dataset" )
124+ if not os .path .exists ("output/data" ):
125+ os .makedirs ("output/data" )
126+ if not os .path .exists ("output/images" ):
127+ os .makedirs ("output/images" )
128+
129+ output_data_path = Path ("./output/data/" )
130+ output_image_path = Path ("./output/images/" )
131+ input_directory_path = Path ("./tests/testing-dataset/zfish" )
132+ graph_file_path = Path (input_directory_path , "graph.pickle" )
133+
134+ algorithm_classes = {
135+ "OverlappingNeighbors" : OverlappingNeighbors ,
136+ "OverlappingNeighborsV2" : OverlappingNeighborsV2 ,
137+ "OverlappingNeighborsV3" : OverlappingNeighborsV3 ,
138+ "ProteinDegree" : ProteinDegree ,
139+ "ProteinDegreeV2" : ProteinDegreeV2 ,
140+ "ProteinDegreeV3" : ProteinDegreeV3 ,
141+ "HypergeometricDistribution" : HypergeometricDistribution ,
142+ "HypergeometricDistributionV2" : HypergeometricDistributionV2
143+ }
144+
145+ #For zfish
146+ results = run_workflow (
147+ algorithm_classes ,
148+ input_directory_path ,
149+ graph_file_path ,
150+ output_data_path ,
151+ output_image_path ,
152+ False ,
153+ False ,
154+ )
155+ roc_results = {
156+ "OverlappingNeighbors" : 0.715 ,
157+ "OverlappingNeighborsV2" : 0.8 ,
158+ "OverlappingNeighborsV3" : 0.7899999999999999 ,
159+ "ProteinDegree" : 0.9650000000000001 ,
160+ "ProteinDegreeV2" : 0.775 ,
161+ "ProteinDegreeV3" : 0.9750000000000001 ,
162+ "HypergeometricDistribution" : 0.5449999999999999 ,
163+ "HypergeometricDistributionV2" : 0.8300000000000001 ,
164+ }
165+
166+ pr_results = {
167+ "ProteinDegreeV3" : 0.9754545454545455 ,
168+ "ProteinDegree" : 0.9675757575757575 ,
169+ "OverlappingNeighborsV3" : 0.8179265873015872 ,
170+ "OverlappingNeighborsV2" : 0.8292361111111111 ,
171+ "ProteinDegreeV2" : 0.7573318322544329 ,
172+ "OverlappingNeighbors" : 0.5794961247902424 ,
173+ "SampleAlgorithm" : 0.43900023737872035 ,
174+ "HypergeometricDistribution" : 0.5095882374849092 ,
175+ "HypergeometricDistributionV2" : 0.674983904983905 ,
176+ }
177+
178+ for algorithm , metrics in results .items ():
179+ assert metrics ["roc_auc" ] == roc_results [algorithm ]
180+
181+ for algorithm , metrics in results .items ():
182+ assert metrics ["pr_auc" ] == pr_results [algorithm ]
183+
184+
185+ #For Bsub
186+ input_directory_path = Path ("./tests/testing-dataset/bsub" )
187+ graph_file_path = Path (input_directory_path , "graph.pickle" )
188+
189+ results = run_workflow (
190+ algorithm_classes ,
191+ input_directory_path ,
192+ graph_file_path ,
193+ output_data_path ,
194+ output_image_path ,
195+ False ,
196+ False ,
197+ )
198+ roc_results = {
199+ "OverlappingNeighbors" : 0.575 ,
200+ "OverlappingNeighborsV2" : 0.6399999999999999 ,
201+ "OverlappingNeighborsV3" : 0.6399999999999999 ,
202+ "ProteinDegree" : 0.7050000000000001 ,
203+ "ProteinDegreeV2" : 0.54 ,
204+ "ProteinDegreeV3" : 0.71 ,
205+ "HypergeometricDistribution" : 0.51 ,
206+ "HypergeometricDistributionV2" : 0.8499999999999999 ,
207+ }
208+
209+ pr_results = {
210+ "ProteinDegreeV3" : 0.6918311998459057 ,
211+ "ProteinDegree" : 0.6560890253537313 ,
212+ "OverlappingNeighborsV3" : 0.5933333333333334 ,
213+ "OverlappingNeighborsV2" : 0.5933333333333334 ,
214+ "ProteinDegreeV2" : 0.588080808080808 ,
215+ "OverlappingNeighbors" : 0.5224841799067805 ,
216+ "SampleAlgorithm" : 0.5922520550055379 ,
217+ "HypergeometricDistribution" : 0.5001244588744589 ,
218+ "HypergeometricDistributionV2" : 0.7131783494283495 ,
109219 }
110220
111221 for algorithm , metrics in results .items ():
112222 assert metrics ["roc_auc" ] == roc_results [algorithm ]
113223
114224 for algorithm , metrics in results .items ():
115225 assert metrics ["pr_auc" ] == pr_results [algorithm ]
226+
0 commit comments