def letsStartKMeans(ways_type,dataset_type, family_type): #hungarian.Hungarian_algo() #Form networkx representation of both graphs subprocess.call("rm -rf ../../Data/KMeans", shell=True) INPUT_FILE_1 = os.path.join(Constants.NAPA_PATH, ways_type, dataset_type,family_type, Constants.INPUT_FILE_1_NAME ) INPUT_FILE_2 = os.path.join(Constants.NAPA_PATH, ways_type, dataset_type,family_type, Constants.INPUT_FILE_2_NAME ) G1 = Utils.convertNetToGefx(INPUT_FILE_1 + Constants.NET_FORMAT) G2 = Utils.convertNetToGefx(INPUT_FILE_2 + Constants.NET_FORMAT) #print("**************Run kmeans*****************") #Run kmeans for num_clusters in [8,20]: kmeans_cluster.kmeans_cluster(G1, Constants.INPUT_FILE_1_NAME, num_clusters) kmeans_cluster.kmeans_cluster(G2, Constants.INPUT_FILE_2_NAME, num_clusters) SDF_PATH = Utils.ComputeSpectralDistance(Constants.INPUT_FILE_1_NAME, Constants.INPUT_FILE_2_NAME, "Kmeans") #Find best Matching for our bipartite graph #Compute cluster parameters cluster_edge_weight_matrix = compute_cluster_param.find_cluster_edges_SDF(SDF_PATH, num_clusters, num_clusters) best_cluster_pairs = hungarian.Hungarian_algo(cluster_edge_weight_matrix) #Generate alignment score of our graphs generate_alignment.generate_alignment_score(best_cluster_pairs, "Kmeans", "SDF", INPUT_FILE_1,INPUT_FILE_2, Constants.INPUT_FILE_1_NAME, Constants.INPUT_FILE_2_NAME, ways_type,dataset_type, family_type, num_clusters)
def letsStartMcl(ways_type,dataset_type, family_type): subprocess.call("rm -rf ../../Data/MCL", shell=True) INPUT_FILE_1 = os.path.join(Constants.NAPA_PATH, ways_type, dataset_type,family_type, Constants.INPUT_FILE_1_NAME ) INPUT_FILE_2 = os.path.join(Constants.NAPA_PATH, ways_type, dataset_type,family_type, Constants.INPUT_FILE_2_NAME ) for mcl_param in [1.35,1.40,1.45,1.50]: A_sg_dir = mcl_cluster.getMCLFromFile(INPUT_FILE_1+Constants.NET_FORMAT, '../../Data', mcl_param) B_sg_dir = mcl_cluster.getMCLFromFile(INPUT_FILE_2+Constants.NET_FORMAT, '../../Data', mcl_param) print Utils.ComputeSpectralDistance(A_sg_dir.split('/')[-1], B_sg_dir.split('/')[-1], "MCL") clustersdf = createClusterSDF('../../Data/MCL/SDF/A_B', '../../Data/MCL/SDF/A_B_cluster.sdf') d, best_cluster_pairs = getDistanceAndPairsFromSDF(clustersdf) best_cluster_pairs = [(pair[0][1:], pair[1][1:]) for pair in best_cluster_pairs] print best_cluster_pairs final_out = generate_alignment.generate_alignment_score(best_cluster_pairs, "MCL", "SDF", INPUT_FILE_1,INPUT_FILE_2, Constants.INPUT_FILE_1_NAME, Constants.INPUT_FILE_2_NAME, ways_type,dataset_type, family_type, mcl_param)