Exemplo n.º 1
0
def test_additional_edges():
    import convert_networks_to_graphml
    import networkx as nx
    import constants_network as CONST

    logger.debug(
        "Exporting ion identity molecular network with ALL nodes (NO collapsing)"
    )
    convert_networks_to_graphml.create_graphml(
        "reference_data/IIN/edges.tsv",
        "reference_data/IIN/cluster_summary.tsv",
        "reference_data/IIN/library_matches.tsv",
        "reference_data/IIN/library_matches.tsv",
        "reference_data/IIN/additional_edges", "iin.graphml")

    logger.info("Reading graph")
    G = nx.read_graphml("iin.graphml")
    logger.info("Number of nodes in IIMN graph: " + str(len(G.nodes())))
    logger.info("Number of edges in IIMN graph: " + str(len(G.edges())))

    listy = G.get_edge_data('7347', '9043')
    logger.info("edge info:" + str(listy))
    mass_difference = float(listy[CONST.EDGE.ION_TYPE]["mass_difference"])
    #mass_difference = round(mass_difference, 4)
    # safely compare floating point numbers
    assert (numpy.isclose(mass_difference, 3.0051))
Exemplo n.º 2
0
def test_additional_edges():
    import convert_networks_to_graphml

    convert_networks_to_graphml.create_graphml(
        "reference_data/IIN/edges.tsv",
        "reference_data/IIN/cluster_summary.tsv",
        "reference_data/IIN/library_matches.tsv",
        "reference_data/IIN/library_matches.tsv",
        "reference_data/IIN/additional_edges", "iin.graphml")
def test_additional_edges():
    import convert_networks_to_graphml
    import networkx as nx
    import unittest

    convert_networks_to_graphml.create_graphml("reference_data/IIN/edges.tsv", 
    "reference_data/IIN/cluster_summary.tsv", 
    "reference_data/IIN/library_matches.tsv", 
    "reference_data/IIN/library_matches.tsv", 
    "reference_data/IIN/additional_edges", 
    "iin.graphml")
    
    G = nx.read_graphml("iin.graphml")   
    listy = G.get_edge_data('7347','9043')
    mass_difference = float(listy[0]["mass_difference"])
    mass_difference = round(mass_difference, 4)
    assert(mass_difference == 3.0051)
Exemplo n.º 4
0
def test_collapse_ion_identity_networks():
    import convert_networks_to_graphml
    import networkx as nx

    logger.info("Exporting ion identity molecular network with collapsed nodes")
    convert_networks_to_graphml.create_graphml("reference_data/IIN/edges.tsv",
                                               "reference_data/IIN/cluster_summary.tsv",
                                               "reference_data/IIN/library_matches.tsv",
                                               "reference_data/IIN/library_matches.tsv",
                                               "reference_data/IIN/additional_edges",
                                               "iin.graphml", collapse_ion_edges=True)

    logger.info("Reading graph")
    G = nx.read_graphml("iin.graphml")
    logger.info("Number of nodes in collapsed IIMN graph: " + str(len(G.nodes())))
    logger.info("Number of edges in collapsed IIMN graph: " + str(len(G.edges())))
    # TODO: add test values
    assert (len(G.nodes()) < 1140)