diff reactome_analysis.py @ 2:db63d069b5e6 draft

planemo upload commit a0b73386d86dc3d60ad33b944dad88fd5ff4d9ab-dirty
author proteore
date Tue, 11 Dec 2018 07:46:12 -0500
parents 8200968789c1
children 988a6f43acdb
line wrap: on
line diff
--- a/reactome_analysis.py	Fri Dec 07 10:43:57 2018 -0500
+++ b/reactome_analysis.py	Tue Dec 11 07:46:12 2018 -0500
@@ -43,8 +43,6 @@
     trash = []
     if identifiers[1] == "list":
         ids = "\n".join(id_valid(identifiers[0].split())[0])
-        #print(ids)
-        #print("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/projection/\?pageSize\=1\&page\=1" % ids)
         json_string = os.popen("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/\?pageSize\=1\&page\=1" % ids).read()
         if len(id_valid(identifiers[0].split())[1]) > 0:
             trash = id_valid(identifiers[0].split())[1]
@@ -57,12 +55,13 @@
             else:
                 idens = [x.split("\t")[int(identifiers[3].replace("c", ""))-1] for x in mq]
             ids = "\n".join(id_valid(idens)[0])
-            #print(ids)
-            #print("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/projection/\?pageSize\=1\&page\=1" % ids)
-            json_string = os.popen("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/\?pageSize\=1\&page\=1" % ids).read()
+            json_string = os.popen("curl -H \"Content-Type: text/plain\" -d \"$(printf '%s')\" -X POST --url www.reactome.org/AnalysisService/identifiers/\?pageSize\=1\&page\=1 2> /dev/null" % ids).read()
             if len(id_valid(idens)[1]) > 0:
                 trash = id_valid(idens)[1]
-    print(json_string)
+    #print(json_string)
+    j = json.loads(json_string)
+    print ("Identifiers not found: " + str(j["identifiersNotFound"]))
+    print ("Pathways found: " + str(j["pathwaysFound"]))
     return json_string, trash
 
 def write_output(filename, json_string, species, trash_file, trash):
@@ -83,7 +82,7 @@
     output.close()
     
     if trash:
-        print(trash)
+        #print(trash)
         trash_out = open(trash_file, "w")
         trash_out.write("\n".join(trash))
         trash_out.close()