summaryrefslogtreecommitdiff
path: root/Code
diff options
context:
space:
mode:
Diffstat (limited to 'Code')
-rw-r--r--Code/update_network_by_force.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Code/update_network_by_force.py b/Code/update_network_by_force.py
index aafa2f0..56f46dc 100644
--- a/Code/update_network_by_force.py
+++ b/Code/update_network_by_force.py
@@ -11,6 +11,7 @@ from datetime import datetime
from configure import HISTORY_DIR, HISTORY_DIR2, UPDATE_NETWORK_LOG_FILE, MERGED_EDGE_FILE, EDGE_POOL_DIR
from configure import PARAMETER_FOR_BUILDCMATRIX, PARAMETER_FOR_BUILDRMATRIX, PARAMETER_FOR_NET
from backup_files import copy_and_backup_file
+from overlap import Overlap
########## Helper functions #######################
def write_log_file(s, fname):
@@ -148,3 +149,31 @@ if os.path.getmtime(MERGED_EDGE_FILE) < os.path.getmtime(EDGE_POOL_DIR): # edge
write_log_file('[update_network_by_force.py] Update done at %s.\n\n' % (datetime.now().strftime('%Y-%m-%d %H:%M:%S')), UPDATE_NETWORK_LOG_FILE)
+
+
+# Compute overlap
+
+f = open('../Data/temp/AtRegNet.20210208.csv')
+AtRegNet_dict = {}
+for line in f:
+ line = line.strip()
+ lst = line.split(',')
+ if lst[0] != 'TFName' and len(lst) > 4:
+ tf = lst[1].upper().strip()
+ target = lst[4].upper().strip()
+ AtRegNet_dict[tf+target] = 100
+f.close()
+
+f = open(MERGED_EDGE_FILE)
+BrainEdges_dict = {}
+for line in f:
+ line = line.strip()
+ lst = line.split('\t')
+ tf = lst[1].split()[0]
+ target = lst[0].split()[0]
+ score = float(lst[8])
+ BrainEdges_dict[tf+target] = score
+f.close()
+
+overlap = Overlap(BrainEdges_dict, 3, AtRegNet_dict, 0)
+write_log_file('[update_network_by_force.py] Performance stats - TP:%d, PP:%d, Hit rate: %4.7f while comparing with AtRegNet.20210208.csv.' % (overlap.getTP(), overlap.getNumberOfPositivesInPred(), overlap.getTP()/overlap.getNumberOfPositivesInPred()), UPDATE_NETWORK_LOG_FILE)