<commit_before>import networkx as nx
import pdb
import os
import argparse
import sys


import parse_modules
import graph_io

""" Compare two networks (without modules)
    
    - Look @ the differences/similarities
    Measures:

    Compare two networks (with modules)

"""
def get_top_n_modules(m_to_gene, n):
    "return top n largest modules"
    d_sorted = sorted(m_to_gene.keys(), key=lambda x: len(m_to_gene[x]))
    d_sorted.reverse()
    return d_sorted[:n]

def compare_modules(m_g0, g_m0, m_g1, g_m1, g0, g1):
    """
        currently saves two images of the biggest module for graph0 and graph1.
    """
    print 'calling compare_modules'
    top10_0 = get_top_n_modules(m_g0, 10)
    top10_1 = get_top_n_modules(m_g1, 10)

    top_module_genes0 = list(m_g0[top10_0[0]])
    top_module_genes1 = list(m_g1[top10_1[0]])

    H0 = g0.subgraph(top_module_genes0)
    H1 = g1.subgraph(top_module_genes1)

    print top_module_genes0
    print top_module_genes1
    print top_module_genes0 == top_module_genes1

    print 'saving the two biggest modoles'
    graph_io.save_graph(H0, '../results/Merlin/h0.png')
    graph_io.save_graph(H1, '../results/Merlin/h1.png')


    return None


def compare_two_networks(g0, g1): # Without module information


    return None


def main():
    parser = argparse.ArgumentParser()

    parser.add_argument('-i', dest='input_files', nargs=2, help="enter atleast 2 input files.",<commit_msg>added one line documentation<commit_after>import networkx as nx
import pdb
import os
import argparse
import sys


import parse_modules
import graph_io

""" Compare two networks (without modules)
    
    - Look @ the differences/similarities
    Measures:

    Compare two networks (with modules)

"""
def get_top_n_modules(m_to_gene, n):
    "return top n largest modules"
    d_sorted = sorted(m_to_gene.keys(), key=lambda x: len(m_to_gene[x]))
    d_sorted.reverse()
    return d_sorted[:n]

def compare_modules(m_g0, g_m0, m_g1, g_m1, g0, g1):
    """
        currently saves two images of the biggest module for graph0 and graph1.
    """
    print 'calling compare_modules'
    top10_0 = get_top_n_modules(m_g0, 10)
    top10_1 = get_top_n_modules(m_g1, 10)

    top_module_genes0 = list(m_g0[top10_0[0]])
    top_module_genes1 = list(m_g1[top10_1[0]])

    H0 = g0.subgraph(top_module_genes0)
    H1 = g1.subgraph(top_module_genes1)

    print top_module_genes0
    print top_module_genes1
    print top_module_genes0 == top_module_genes1

    print 'saving the two biggest modoles'

    #todo get this to display the same graph, since edgelist is the same?
    graph_io.save_graph(H0, '../results/Merlin/h0.png')
    graph_io.save_graph(H1, '../results/Merlin/h1.png')


    return None


def compare_two_networks(g0, g1): # Without module information


    return None


def main():
    parser = argparse.ArgumentParser()

    parser.add_argument('-i', dest='input_files', nargs=2, help="enter atleast 2 input files.",
{'fraction_non_alphanumeric': 0.099527665317139, 'fraction_numerical': 0.033738191632928474, 'mean_word_length': 3.813311688311688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4003231', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1058, 'n_words': 257}