import json
import unittest
import requests
import ndex.client as nc
from ndex.beta.path_scoring import PathScoring
from bioagents.qca import QCA


# BELOW ARE OLD QCA TESTS

def test_improved_path_ranking():
    qca = QCA()
    sources = ["E2F1"]
    targets = ["PTEN"]
    qca_results2 = qca.find_causal_path(targets, sources)
    print(qca_results2)
    assert len(qca_results2) > 0

def test_scratch():
    source_names = ["AKT1", "AKT2", "AKT3"]
    target_names = ["CCND1"]
    results_list = []
    host = "http://www.ndexbio.org"
    directed_path_query_url = 'http://general.bigmech.ndexbio.org/directedpath/query'

    ndex = nc.Ndex(host=host)

    #====================
    # Assemble REST url
    #====================
    uuid_prior = "84f321c6-dade-11e6-86b1-0ac135e8bacf"
    uuid_high_confidence = "b04e406b-dc88-11e6-86b1-0ac135e8bacf"
    target = ",".join(target_names)
    source = ",".join(source_names)
    max_number_of_paths = 200
    url = directed_path_query_url + '?source=' + source + '&target=' + target + '&uuid=' + uuid_prior + '&server=www.ndexbio.org' + '&pathnum=' + str(max_number_of_paths)

    r = requests.post(url)
    result_json = json.loads(r.content)

    edge_results = result_json.get("data").get("forward_english")
    path_scoring = PathScoring()

    A_all_scores = []

    for i, edge in enumerate(edge_results):
        print len(edge)
        top_edge = None
        if i == 24:
            mystr = ""
        if i == 14:
            mystr = ""
        for ranked_edges in path_scoring.cx_edges_to_tuples(edge, "A"):
            if top_edge is None:
                top_edge = ranked_edges
            else:
                if ranked_edges[1] < top_edge[1]:
                    top_edge = ranked_edges

        A_all_scores.append(("A" + str(i), top_edge[1]))

    print(A_all_scores)
    race_results = path_scoring.calculate_average_position(A_all_scores,[])

    print(race_results)
    print(results_list)

if __name__ == '__main__':
    unittest.main()

@@ -41,33 +41,8 @@
 sts%0A
-import ndex.client as nc%0A
 from
@@ -355,16 +355,17 @@
 2) %3E 0%0A%0A
+%0A
 def test
@@ -475,44 +475,8 @@
  %5B%5D%0A
-    host = %22http://www.ndexbio.org%22%0A
     
@@ -500,16 +500,26 @@
 ry_url =
+ %5C%0A       
  'http:/
@@ -576,480 +576,373 @@
     
-ndex = nc.Ndex(host=host)%0A%0A    #====================%0A    # Assemble REST url%0A    #====================%0A    uuid_prior = %2284f321c6-dade-11e6-86b1-0ac135e8bacf%22%0A    uuid_high_confidence = %22b04e406b-dc88-11e6-86b1-0ac135e8bacf%22%0A    target = %22,%22.join(target_names)%0A    source = %22,%22.join(source_names)%0A    max_number_of_paths = 200%0A    url = directed_path_query_url + '?source=' + source + '&target=' + target + '&uuid=' + uuid_prior + '&server=www.ndexbio.org' + '&pathnum=' +
+# Assemble REST url%0A    uuid_prior = %2284f321c6-dade-11e6-86b1-0ac135e8bacf%22%0A    target = %22,%22.join(target_names)%0A    source = %22,%22.join(source_names)%0A    max_number_of_paths = 200%0A    url = '%25s?source=%25s&target=%25s&uuid=%25s&server=%25s&pathnum=%25s' %25 (%0A        directed_path_query_url,%0A        source,%0A        target,%0A        uuid_prior,%0A        'www.ndexbio.org',%0A       
  str
@@ -962,16 +962,26 @@
 f_paths)
+%0A        )
 %0A%0A    r 
@@ -1261,94 +1261,8 @@
 one%0A
-        if i == 24:%0A            mystr = %22%22%0A        if i == 14:%0A            mystr = %22%22%0A
     
@@ -1669,16 +1669,17 @@
 _scores,
+ 
 %5B%5D)%0A%0A   
@@ -1724,16 +1724,17 @@
 _list)%0A%0A
+%0A
 if __nam

Remove unused variables and pep8-ify.