def metabolic_pathways_HTML_alg1(pathway0, pathway1):
	redirectOut()
	# graph creation
	graph0 = to_graph_from_dict(pathway0)
	graph1 = to_graph_from_dict(pathway1)

	bft0 = graph0.breadth_first_traversal()
	dft0 = graph0.depth_first_traversal() 
	add_to_dictionary(bft0)
	add_to_dictionary(dft0)
	bft1 = graph1.breadth_first_traversal()
	dft1 = graph1.depth_first_traversal()
	add_to_dictionary(bft1)
	add_to_dictionary(dft1)



	# Full Detail Output
	print "<h4>Full Detail Output</h4>"
	print "<p>Breadth First Traversal (BFT)</p>"
	print "<p class='pathway'>Pathway 1: ", ' '.join(bft0), "</p>"
	print "<p class='pathway'>Pathway 2: ", ' '.join(bft1), "</p>"
	print '<br>'
	print "<p>Depth First Traversal (DFT)</p>"
	print "<p class='pathway'>Pathway 1: ", ' '.join(dft0), "</p>"
	print "<p class='pathway'>Pathway 2: ", ' '.join(dft1), "</p>"
	print "<br>"
	show_dictionary()
	# Low Detail Output
	print "<h4>Low Detail Output</h4>"
	print "<p>Breadth First Search (BFT)</p>"
	print "<p class='pathway'>Pathway 1: ", ' '.join(renamed_path(bft0)), "</p>"
	print "<p class='pathway'>Pathway 2: ", ' '.join(renamed_path(bft1)), "</p>"
	print "<br>"
	print "<p>Depth First Search (DFT)</p>"
	print "<p class='pathway'>Pathway 1: ", ' '.join(renamed_path(dft0)), "</p>"
	print "<p class='pathway'>Pathway 2: ", ' '.join(renamed_path(dft1)), "</p>"
	print "<h4>Alignment Algorithms</h4>"
	print "<p>Global Alignment (BFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in needleman_wunsch(renamed_path(bft0), renamed_path(bft1))])
	print "<p>Global Alignment (DFT):</p>", '\n '.join(["<p class='alignment'>" + str(i) + "</p>" for i in needleman_wunsch(renamed_path(dft0), renamed_path(dft1))])
	print "<br>"
	print "<p>Local Alignment (BFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in local_alignment(renamed_path(bft0), renamed_path(bft1))])
	print "<p>Local Alignment (DFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in local_alignment(renamed_path(dft0), renamed_path(dft1))])
	print "<br>"
	print "<p>Semiglobal Alignment (BFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in semiglobal_alignment(renamed_path(bft0), renamed_path(bft1))])
	print "<p>Semiglobal Alignment (DFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in semiglobal_alignment(renamed_path(dft0), renamed_path(dft1))])
	print "<br>"
	print "<h4>Equality Identified</h4>"
	identify_equality(graph0, graph1, LOW)
	print "<br>"
	print "<h4>Differences Identified (from Pathway 1 to Pathway 2)</h4>"
	identify_differences(graph0, graph1, FULL)
	print "<br>"
	print "<h4>Differences Identified (from Pathway 2 to Pathway 1)</h4>"
	identify_differences(graph1, graph0, FULL)
def metabolic_pathways_HTML_alg3(pathway0, pathway1):
	# graph creation
	graph0 = to_graph_from_dict(pathway0)
	graph1 = to_graph_from_dict(pathway1)

	
	print "Graph 1"
	for n,i in zip(range(len(graph0.get_nodes())),graph0.get_nodes()):
		print n," - ",i.get_value()
	start0 = input("Start Node Graph 1: ")
	end0 = input("End Node Graph 1: ")
	print ""

	print "Graph 2"
	for n,i in zip(range(len(graph1.get_nodes())),graph1.get_nodes()):
		print n," - ",i.get_value()

	start1 = (input("Start Node Graph 2: "))
	end1 = (input("End Node Graph 2: "))


	bft0 = graph0.breadth_first_traversal(start0,end0)
	dft0 = graph0.depth_first_traversal(start0,end0) 
	add_to_dictionary(bft0)
	add_to_dictionary(dft0)
	bft1 = graph1.breadth_first_traversal(start1,end1)
	dft1 = graph1.depth_first_traversal(start1,end1)
	add_to_dictionary(bft1)
	add_to_dictionary(dft1)



	# Full Detail Output
	redirectOut()
	print "<h4>Full Detail Output</h4>"
	print "<p>Breadth First Traversal (BFT)</p>"
	print "<p class='pathway'>Pathway 1: ", ' '.join(bft0), "</p>"
	print "<p class='pathway'>Pathway 2: ", ' '.join(bft1), "</p>"
	print '<br>'
	print "<p>Depth First Traversal (DFT)</p>"
	print "<p class='pathway'>Pathway 1: ", ' '.join(dft0), "</p>"
	print "<p class='pathway'>Pathway 2: ", ' '.join(dft1), "</p>"
	print "<br>"
	show_dictionary()
	# Low Detail Output
	print "<h4>Low Detail Output</h4>"
	print "<p>Breadth First Search (BFT)</p>"
	print "<p class='pathway'>Pathway 1: ", ' '.join(renamed_path(bft0)), "</p>"
	print "<p class='pathway'>Pathway 2: ", ' '.join(renamed_path(bft1)), "</p>"
	print "<br>"
	print "<p>Depth First Search (DFT)</p>"
	print "<p class='pathway'>Pathway 1: ", ' '.join(renamed_path(dft0)), "</p>"
	print "<p class='pathway'>Pathway 2: ", ' '.join(renamed_path(dft1)), "</p>"
	print "<h4>Alignment Algorithms</h4>"
	print "<p>Global Alignment (BFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in needleman_wunsch(renamed_path(bft0), renamed_path(bft1))])
	print "<p>Global Alignment (DFT):</p>", '\n '.join(["<p class='alignment'>" + str(i) + "</p>" for i in needleman_wunsch(renamed_path(dft0), renamed_path(dft1))])
	print "<br>"
	print "<p>Local Alignment (BFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in local_alignment(renamed_path(bft0), renamed_path(bft1))])
	print "<p>Local Alignment (DFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in local_alignment(renamed_path(dft0), renamed_path(dft1))])
	print "<br>"
	print "<p>Semiglobal Alignment (BFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in semiglobal_alignment(renamed_path(bft0), renamed_path(bft1))])
	print "<p>Semiglobal Alignment (DFT):</p>", '\n'.join(["<p class='alignment'>" + str(i) + "</p>" for i in semiglobal_alignment(renamed_path(dft0), renamed_path(dft1))])
	print "<br>"
	print "<h4>Equality Identified</h4>"
	identify_equality(graph0, graph1, LOW)
	print "<br>"
	print "<h4>Differences Identified (from Pathway 1 to Pathway 2)</h4>"
	identify_differences(graph0, graph1, FULL)
	print "<br>"
	print "<h4>Differences Identified (from Pathway 2 to Pathway 1)</h4>"
	identify_differences(graph1, graph0, FULL)
コード例 #3
0
s_list = []
s_count = get_input_int('How many sequences will you align?')
for idx in range(s_count):
    next_seq = input(f'Input sequence #{idx+1}')
    s_list.append(next_seq)

select_center = get_input_boolean('Do you want to input the center star sequence? [Y/N]')
if select_center:
    center_star_seq = input('Input the center star sequence')
    center_star_st1s = []
    center_star_st2s = []
    for seq in s_list:
        if seq == center_star_seq:
            continue

        V, paths = needleman_wunsch(center_star_seq, seq, ins_cost, del_cost, match_cost, mismatch_cost)
        st1, st2, score = reconstruct(center_star_seq, seq, V, paths)
        center_star_st1s.append(st1)
        center_star_st2s.append(st2)
else:
    print("Finding center star...")
    start_time_total = timer()
    best_d = np.inf
    center_star_seq = ''
    center_star_st1s = []
    center_star_st2s = []
    for idx1, seq1 in enumerate(s_list):
        d_sum = 0
        st1_list = []
        st2_list = []
        for idx2, seq2 in enumerate(s_list):
コード例 #4
0
ファイル: main.py プロジェクト: anthonylle/metabolic-pathways
def metabolic_pathways_HTML_alg15(pathway0, pathway1):
    global end0, end1, n
    # graph creation
    g1 = generate_graph(pathway0)
    g2 = generate_graph(pathway1)
    graph0 = to_graph_from_dict(pathway0)
    graph1 = to_graph_from_dict(pathway1)

    if (not params):
        print("Graph 1")
        for n, i in zip(range(len(graph0.get_nodes())), graph0.get_nodes()):
            print(n, " - ", i.get_value(), "->",
                  [node.get_value() for node in i.get_edges()])
        end0 = input("End Node Graph 1: ")
        print("")

        print("Graph 2")
        for n, i in zip(range(len(graph1.get_nodes())), graph1.get_nodes()):
            print(n, " - ", i.get_value(), "->",
                  [node.get_value() for node in i.get_edges()])

        end1 = (input("End Node Graph 2: "))
        n = (input("Maximum cycles: "))
        paths0 = []
        for node in graph0:
            if (node.get_value() != graph0[end0].get_value()):
                paths0 += graph0.get_cyclic_paths(node, graph0[end0], [], n)

        paths1 = []
        for node1 in graph1:
            if (node1.get_value() != graph1[end1].get_value()):
                paths1 += graph1.get_cyclic_paths(node1, graph1[end1], [], n)

        if (len(paths0) == 0):
            print("Not avaliable paths for graph 0")
            return
        if (len(paths1) == 0):
            print("Not avaliable paths for graph 1")
            return
        """
		print("Paths Graph 0:")
		for n,i in zip(range(len(paths0)),paths0):
			out = ""
			for node in i:
				out+=str(node.get_value())+"->"
			out = out[0:-2]
			print(n," - ",out)

		selected_Path0 = input("Select Path of graph 0: ")
		print("")
		print("Paths Graph 1:")
		for n,i in zip(range(len(paths1)),paths1):
			out = ""
			for node in i:
				out+=str(node.get_value())+"->"
			out = out[0:-2]
			print(n," - ",out)

		selected_Path1 = input("Select Path of graph 1: ")
		paths0 = [paths0[selected_Path0]]
		paths1 = [paths1[selected_Path1]]"""
    else:
        paths0 = graph0.get_cyclic_paths(graph0[start0], graph0[end0], [], n)
        paths1 = graph1.get_cyclic_paths(graph1[start1], graph1[end1], [], n)

    redirectOut(5)
    print("<h3>Algorithm 1.5</h3>")
    print("Paths Graph 1:<br>")
    for n, i in zip(range(len(paths0)), paths0):
        out = ""
        for node in i:
            out += str(node.get_value()) + "->"
        out = out[0:-2]
        print("".join([str(1), ".", str(n), " - ", out]))
        print("<br>")

    print("<br>")
    print("Paths Graph 2:<br>")
    for n, i in zip(range(len(paths1)), paths1):
        out = ""
        for node in i:
            out += str(node.get_value()) + "->"
        out = out[0:-2]
        print("".join([str(2), ".", str(n), " - ", out]))
        print("<br>")
    print("<h3>G1 ------------------------------------------G2</h3>")
    print('<img src="data:image/png;base64,', g1, '" alt="Red dot" />')
    print('<img src="data:image/png;base64,', g2, '" alt="Red dot" />')
    maxglobNeed = [[-100]]
    maxlocalAlg = [[-100]]
    maxSemiglobal = [[-100]]
    for p1 in range(len(paths0)):
        path0 = to_graph_from_dict(path2Dic(paths0[p1]))
        for p2 in range(len(paths1)):
            path1 = to_graph_from_dict(path2Dic(paths1[p2]))
            reset_dictionary()
            bft0 = path0.breadth_first_traversal()
            bft1 = path1.breadth_first_traversal()
            add_to_dictionary(bft0)
            add_to_dictionary(bft1)
            # Full Detail Output
            pathStr1 = "<p class='pathway'>Pathway 1." + str(
                p1) + ": " + ' '.join(bft0) + "</p>"
            pathStr2 = "<p class='pathway'>Pathway 2" + "." + str(
                p2) + ": " + ' '.join(bft1) + "</p>"
            print("<h4>Full Detail Output - Algorithm 1.4</h4>")
            print(pathStr1)
            print(pathStr2)
            print("<br>")
            show_dictionary()
            # Low Detail Output
            print("<h4>Alignment Algorithms</h4>")
            globNeed = needleman_wunsch(renamed_path(bft0), renamed_path(bft1))
            localAlg = local_alignment(renamed_path(bft0), renamed_path(bft1))
            SemilocalAlg = semiglobal_alignment(renamed_path(bft0),
                                                renamed_path(bft1))
            if (globNeed[0] > maxglobNeed[0][0]):
                maxglobNeed = [globNeed, pathStr1, pathStr2]
            if (localAlg[0] > maxlocalAlg[0][0]):
                maxlocalAlg = [localAlg, pathStr1, pathStr2]
            if (SemilocalAlg[0] > maxSemiglobal[0][0]):
                maxSemiglobal = [SemilocalAlg, pathStr1, pathStr2]
            print(
                "<p>Global Alignment (BFT): ",
                globNeed[0] if globNeed[0] <= 0 else "+" + str(globNeed[0]),
                "<br>", '\n'.join([
                    "<p class='alignment' style='font-family:Courier'>" +
                    str(i) + "</p>" for i in globNeed[1:]
                ]))
            print("<br>")
            print(
                "<p>Local Alignment (BFT): ",
                localAlg[0] if localAlg[0] <= 0 else "+" + str(localAlg[0]),
                "<br>", '\n'.join([
                    "<p class='alignment' style='font-family:Courier'>" +
                    str(i) + "</p>" for i in localAlg[1:]
                ]))
            print("<br>")
            print(
                "<p>Semiglobal Alignment (BFT): ",
                SemilocalAlg[0] if SemilocalAlg[0] <= 0 else "+" +
                str(SemilocalAlg[0]), "<br>", '\n'.join([
                    "<p class='alignment' style='font-family:Courier'>" +
                    str(i) + "</p>" for i in SemilocalAlg[1:]
                ]))
            print("<br>")

    print("<h4>MAX Global Alignment</h4>")
    print(maxglobNeed[1])
    print(maxglobNeed[2])
    print(
        "<p>Global Alignment (BFT): ",
        maxglobNeed[0][0] if maxglobNeed[0][0] <= 0 else "+" +
        str(maxglobNeed[0][0]), "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in maxglobNeed[0][1:]
        ]))
    print("<br>")
    print("<h4>MAX Local Alignment</h4>")
    print(maxlocalAlg[1])
    print(maxlocalAlg[2])
    print(
        "<p>Local Alignment (BFT): ",
        maxlocalAlg[0][0] if maxlocalAlg[0][0] <= 0 else "+" +
        str(maxlocalAlg[0][0]), "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in maxlocalAlg[0][1:]
        ]))
    print("<br>")
    print("<h4>MAX Semiglobal Alignment</h4>")
    print(maxSemiglobal[1])
    print(maxSemiglobal[2])
    print(
        "<p>Semiglobal Alignment (BFT): ",
        maxSemiglobal[0][0] if maxSemiglobal[0][0] <= 0 else "+" +
        str(maxSemiglobal[0][0]), "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in maxSemiglobal[0][1:]
        ]))
    print("<br>")
コード例 #5
0
ファイル: main.py プロジェクト: anthonylle/metabolic-pathways
def metabolic_pathways_HTML_alg13(pathway0, pathway1):
    # graph creation
    g1 = generate_graph(pathway0)
    g2 = generate_graph(pathway1)
    graph0 = to_graph_from_dict(pathway0)
    graph1 = to_graph_from_dict(pathway1)

    print("Graph 1")
    for n, i in zip(range(len(graph0.get_nodes())), graph0.get_nodes()):
        print(n, " - ", i.get_value(), " -> ",
              [node.get_value() for node in i.get_edges()])
    start0 = input("Start Node Graph 1: ")
    end0 = input("End Node Graph 1: ")
    print("")

    print("Graph 2")
    for n, i in zip(range(len(graph1.get_nodes())), graph1.get_nodes()):
        print(n, " - ", i.get_value(), " -> ",
              [node.get_value() for node in i.get_edges()])

    start1 = (input("Start Node Graph 2: "))
    end1 = (input("End Node Graph 2: "))

    bft0 = graph0.breadth_first_traversal(start0, end0)
    dft0 = graph0.depth_first_traversal(start0, end0)
    add_to_dictionary(bft0)
    add_to_dictionary(dft0)
    bft1 = graph1.breadth_first_traversal(start1, end1)
    dft1 = graph1.depth_first_traversal(start1, end1)
    add_to_dictionary(bft1)
    add_to_dictionary(dft1)

    # Low Detail Output
    globNeed = [
        needleman_wunsch(renamed_path(bft0), renamed_path(bft1)),
        needleman_wunsch(renamed_path(dft0), renamed_path(dft1))
    ]
    localAlg = [
        local_alignment(renamed_path(bft0), renamed_path(bft1)),
        local_alignment(renamed_path(dft0), renamed_path(dft1))
    ]
    SemilocalAlg = [
        semiglobal_alignment(renamed_path(bft0), renamed_path(bft1)),
        semiglobal_alignment(renamed_path(dft0), renamed_path(dft1))
    ]

    # Full Detail Output
    redirectOut(3)
    print("<h4>Alignment Algorithms 1.3</h4>")
    print("<h4>Full Detail Output</h4>")
    print("<p>Breadth First Traversal (BFT)</p>")
    print("<p class='pathway'>Pathway 1: ", ' '.join(bft0), "</p>")
    print("<p class='pathway'>Pathway 2: ", ' '.join(bft1), "</p>")
    print('<br>')
    print("<p>Depth First Traversal (DFT)</p>")
    print("<p class='pathway'>Pathway 1: ", ' '.join(dft0), "</p>")
    print("<p class='pathway'>Pathway 2: ", ' '.join(dft1), "</p>")
    print("<br>")
    print("<h3>G1 ------------------------------------------G2</h3>")
    print('<img src="data:image/png;base64,', g1, '" alt="Red dot" />')
    print('<img src="data:image/png;base64,', g2, '" alt="Red dot" />')
    show_dictionary()
    # Low Detail Output
    print("<h4>Low Detail Output</h4>")
    print("<p>Breadth First Search (BFT)</p>")
    print("<p class='pathway'>Pathway 1: ", ' '.join(renamed_path(bft0)),
          "</p>")
    print("<p class='pathway'>Pathway 2: ", ' '.join(renamed_path(bft1)),
          "</p>")
    print("<br>")
    print("<p>Depth First Search (DFT)</p>")
    print("<p class='pathway'>Pathway 1: ", ' '.join(renamed_path(dft0)),
          "</p>")
    print("<p class='pathway'>Pathway 2: ", ' '.join(renamed_path(dft1)),
          "</p>")
    print("<h4>Alignment Algorithms</h4>")
    print(
        "<p>Global Alignment (BFT): ",
        globNeed[0][0] if globNeed[0][0] <= 0 else "+" + str(globNeed[0][0]),
        "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in globNeed[0][1:]
        ]))
    print(
        "<p>Global Alignment (DFT): ",
        globNeed[1][0] if globNeed[1][0] <= 0 else "+" + str(globNeed[1][0]),
        "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in globNeed[0][1:]
        ]))
    print("<br>")
    print(
        "<p>Local Alignment (BFT): ",
        localAlg[0][0] if localAlg[0][0] <= 0 else "+" + str(localAlg[0][0]),
        "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in localAlg[0][1:]
        ]))
    print(
        "<p>Local Alignment (DFT): ",
        localAlg[0][0] if localAlg[0][0] <= 0 else "+" + str(localAlg[0][0]),
        "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in localAlg[0][1:]
        ]))
    print("<br>")
    print(
        "<p>Semiglobal Alignment (DFT): ",
        SemilocalAlg[0][0] if SemilocalAlg[0][0] <= 0 else "+" +
        str(SemilocalAlg[0][0]), "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in SemilocalAlg[0][1:]
        ]))
    print(
        "<p>Semiglobal Alignment (DFT): ",
        SemilocalAlg[0][0] if SemilocalAlg[0][0] <= 0 else "+" +
        str(SemilocalAlg[0][0]), "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in SemilocalAlg[0][1:]
        ]))
    print("<br>")
    print("<h4>Equality Identified</h4>")
    identify_equality(graph0, graph1, LOW)
    print("<br>")
    print("<h4>Differences Identified (from Pathway 1 to Pathway 2)</h4>")
    identify_differences(graph0, graph1, FULL)
    print("<br>")
    print("<h4>Differences Identified (from Pathway 2 to Pathway 1)</h4>")
    identify_differences(graph1, graph0, FULL)
コード例 #6
0
ファイル: main.py プロジェクト: anthonylle/metabolic-pathways
def metabolic_pathways_HTML_alg1(pathway0, pathway1):
    redirectOut(1)
    # graph creation
    g1 = generate_graph(pathway0)
    g2 = generate_graph(pathway1)
    graph0 = to_graph_from_dict(pathway0)
    graph1 = to_graph_from_dict(pathway1)

    bft0 = graph0.breadth_first_traversal()
    dft0 = graph0.depth_first_traversal()
    add_to_dictionary(bft0)
    add_to_dictionary(dft0)
    bft1 = graph1.breadth_first_traversal()
    dft1 = graph1.depth_first_traversal()
    add_to_dictionary(bft1)
    add_to_dictionary(dft1)

    # Low Detail Output
    globNeed = [
        needleman_wunsch(renamed_path(bft0), renamed_path(bft1)),
        needleman_wunsch(renamed_path(dft0), renamed_path(dft1))
    ]
    localAlg = [
        local_alignment(renamed_path(bft0), renamed_path(bft1)),
        local_alignment(renamed_path(dft0), renamed_path(dft1))
    ]
    SemilocalAlg = [
        semiglobal_alignment(renamed_path(bft0), renamed_path(bft1)),
        semiglobal_alignment(renamed_path(dft0), renamed_path(dft1))
    ]

    redirectOut(1)
    print("<h4>Alignment Algorithms 1</h4>")
    print("<h4>Full Detail Output</h4>")
    print("<p>Breadth First Traversal (BFT)</p>")
    print("<p class='pathway'>Pathway 1: ", ' '.join(bft0), "</p>")
    print("<p class='pathway'>Pathway 2: ", ' '.join(bft1), "</p>")
    print('<br>')
    print("<p>Depth First Traversal (DFT)</p>")
    print("<p class='pathway'>Pathway 1: ", ' '.join(dft0), "</p>")
    print("<p class='pathway'>Pathway 2: ", ' '.join(dft1), "</p>")
    print("<br>")
    print("<h3>G1 ------------------------------------------G2</h3>")
    print('<img src="data:image/png;base64,', g1, '" alt="Red dot" />')
    print('<img src="data:image/png;base64,', g2, '" alt="Red dot" />')
    show_dictionary()
    # Low Detail Output
    print("<h4>Low Detail Output</h4>")
    print("<p>Breadth First Search (BFT)</p>")
    print("<p class='pathway'>Pathway 1: ", ' '.join(renamed_path(bft0)),
          "</p>")
    print("<p class='pathway'>Pathway 2: ", ' '.join(renamed_path(bft1)),
          "</p>")
    print("<br>")
    print("<p>Depth First Search (DFT)</p>")
    print("<p class='pathway'>Pathway 1: ", ' '.join(renamed_path(dft0)),
          "</p>")
    print("<p class='pathway'>Pathway 2: ", ' '.join(renamed_path(dft1)),
          "</p>")
    print("<h4>Alignment Algorithms</h4>")
    print(
        "<p>Global Alignment (BFT): ",
        globNeed[0][0] if globNeed[0][0] <= 0 else "+" + str(globNeed[0][0]),
        "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in globNeed[0][1:]
        ]))
    print(
        "<p>Global Alignment (DFT): ",
        globNeed[1][0] if globNeed[1][0] <= 0 else "+" + str(globNeed[1][0]),
        "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in globNeed[0][1:]
        ]))
    print("<br>")
    print(
        "<p>Local Alignment (BFT): ",
        localAlg[0][0] if localAlg[0][0] <= 0 else "+" + str(localAlg[0][0]),
        "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in localAlg[0][1:]
        ]))
    print(
        "<p>Local Alignment (DFT): ",
        localAlg[0][0] if localAlg[0][0] <= 0 else "+" + str(localAlg[0][0]),
        "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in localAlg[0][1:]
        ]))
    print("<br>")
    print(
        "<p>Semiglobal Alignment (DFT): ",
        SemilocalAlg[0][0] if SemilocalAlg[0][0] <= 0 else "+" +
        str(SemilocalAlg[0][0]), "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in SemilocalAlg[0][1:]
        ]))
    print(
        "<p>Semiglobal Alignment (DFT): ",
        SemilocalAlg[0][0] if SemilocalAlg[0][0] <= 0 else "+" +
        str(SemilocalAlg[0][0]), "<br>", '\n'.join([
            "<p class='alignment' style='font-family:Courier'>" + str(i) +
            "</p>" for i in SemilocalAlg[0][1:]
        ]))
    print("<br>")
    print("<h4>Equality Identified</h4>")
    identify_equality(graph0, graph1, LOW)
    print("<br>")
    print("<h4>Differences Identified (from Pathway 1 to Pathway 2)</h4>")
    identify_differences(graph0, graph1, FULL)
    print("<br>")
    print("<h4>Differences Identified (from Pathway 2 to Pathway 1)</h4>")
    identify_differences(graph1, graph0, FULL)
コード例 #7
0
ファイル: main.py プロジェクト: anthonylle/metabolic-pathways
def metabolic_pathways_HTML_alg4(pathway0, pathway1):
    # graph creation
    graph0 = to_graph_from_dict(pathway0)
    graph1 = to_graph_from_dict(pathway1)

    print "Graph 1"
    for n, i in zip(range(len(graph0.get_nodes())), graph0.get_nodes()):
        print n, " - ", i.get_value()
    start0 = input("Start Node Graph 1: ")
    end0 = input("End Node Graph 1: ")
    print ""

    print "Graph 2"
    for n, i in zip(range(len(graph1.get_nodes())), graph1.get_nodes()):
        print n, " - ", i.get_value()

    start1 = (input("Start Node Graph 2: "))
    end1 = (input("End Node Graph 2: "))
    n = int(input("Maximum cycles: "))
    paths0 = graph0.get_cyclic_paths(graph0[start0], graph0[end0], [], n)
    paths1 = graph1.get_cyclic_paths(graph1[start1], graph1[end1], [], n)

    if (len(paths0) == 0):
        print "Not avaliable paths for graph 0"
        return
    if (len(paths1) == 0):
        print "Not avaliable paths for graph 1"
        return

    print "Paths Graph 0:"
    for n, i in zip(range(len(paths0)), paths0):
        out = ""
        for node in i:
            out += str(node.get_value()) + "->"
        out = out[0:-2]
        print n, " - ", out

    selected_Path0 = input("Select Path of graph 0: ")
    print ""
    print "Paths Graph 1:"
    for n, i in zip(range(len(paths1)), paths1):
        out = ""
        for node in i:
            out += str(node.get_value()) + "->"
        out = out[0:-2]
        print n, " - ", out

    selected_Path1 = input("Select Path of graph 1: ")

    bft0 = graph0.breadth_first_traversal(selected_Path0)
    dft0 = graph0.depth_first_traversal(selected_Path0)
    add_to_dictionary(bft0)
    add_to_dictionary(dft0)
    bft1 = graph1.breadth_first_traversal(selected_Path1)
    dft1 = graph1.depth_first_traversal(selected_Path1)
    add_to_dictionary(bft1)
    add_to_dictionary(dft1)

    # Full Detail Output
    redirectOut()
    print "<h4>Full Detail Output</h4>"
    print "<p>Breadth First Traversal (BFT)</p>"
    print "<p class='pathway'>Pathway 1: ", ' '.join(bft0), "</p>"
    print "<p class='pathway'>Pathway 2: ", ' '.join(bft1), "</p>"
    print '<br>'
    print "<p>Depth First Traversal (DFT)</p>"
    print "<p class='pathway'>Pathway 1: ", ' '.join(dft0), "</p>"
    print "<p class='pathway'>Pathway 2: ", ' '.join(dft1), "</p>"
    print "<br>"
    show_dictionary()
    # Low Detail Output
    print "<h4>Low Detail Output</h4>"
    print "<p>Breadth First Search (BFT)</p>"
    print "<p class='pathway'>Pathway 1: ", ' '.join(
        renamed_path(bft0)), "</p>"
    print "<p class='pathway'>Pathway 2: ", ' '.join(
        renamed_path(bft1)), "</p>"
    print "<br>"
    print "<p>Depth First Search (DFT)</p>"
    print "<p class='pathway'>Pathway 1: ", ' '.join(
        renamed_path(dft0)), "</p>"
    print "<p class='pathway'>Pathway 2: ", ' '.join(
        renamed_path(dft1)), "</p>"
    print "<h4>Alignment Algorithms</h4>"
    print "<p>Global Alignment (BFT):</p>", '\n'.join([
        "<p class='alignment'>" + str(i) + "</p>"
        for i in needleman_wunsch(renamed_path(bft0), renamed_path(bft1))
    ])
    print "<p>Global Alignment (DFT):</p>", '\n '.join([
        "<p class='alignment'>" + str(i) + "</p>"
        for i in needleman_wunsch(renamed_path(dft0), renamed_path(dft1))
    ])
    print "<br>"
    print "<p>Local Alignment (BFT):</p>", '\n'.join([
        "<p class='alignment'>" + str(i) + "</p>"
        for i in local_alignment(renamed_path(bft0), renamed_path(bft1))
    ])
    print "<p>Local Alignment (DFT):</p>", '\n'.join([
        "<p class='alignment'>" + str(i) + "</p>"
        for i in local_alignment(renamed_path(dft0), renamed_path(dft1))
    ])
    print "<br>"
    print "<p>Semiglobal Alignment (BFT):</p>", '\n'.join([
        "<p class='alignment'>" + str(i) + "</p>"
        for i in semiglobal_alignment(renamed_path(bft0), renamed_path(bft1))
    ])
    print "<p>Semiglobal Alignment (DFT):</p>", '\n'.join([
        "<p class='alignment'>" + str(i) + "</p>"
        for i in semiglobal_alignment(renamed_path(dft0), renamed_path(dft1))
    ])
    print "<br>"
    print "<h4>Equality Identified</h4>"
    identify_equality(graph0, graph1, LOW)
    print "<br>"
    print "<h4>Differences Identified (from Pathway 1 to Pathway 2)</h4>"
    identify_differences(graph0, graph1, FULL)
    print "<br>"
    print "<h4>Differences Identified (from Pathway 2 to Pathway 1)</h4>"
    identify_differences(graph1, graph0, FULL)