# HG changeset patch # User proteore # Date 1561623679 14400 # Node ID 34097acf457cdcb70db370651ab1846f6adee973 # Parent 113cce3fc379ca2429430b32878435aed459d4b2 planemo upload commit fb27a6b5de5cd7b269a41be3c85c593b77aa1b18-dirty diff -r 113cce3fc379 -r 34097acf457c reactome_analysis.py --- a/reactome_analysis.py Thu Dec 13 04:17:25 2018 -0500 +++ b/reactome_analysis.py Thu Jun 27 04:21:19 2019 -0400 @@ -1,7 +1,4 @@ -import os -import re -import json -import argparse +import os, re, json, argparse, csv CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -42,22 +39,29 @@ """ trash = [] if identifiers[1] == "list": - ids = "\n".join(id_valid(identifiers[0].split())[0]) + ids = identifiers[0].split() + ids = [x.split(";") for x in ids] + ids = [item.strip() for sublist in ids for item in sublist if item != ''] 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] elif identifiers[1] == "file": header = identifiers[2] - mq = open(identifiers[0]).readlines() - if isnumber("int", identifiers[3].replace("c", "")): - if header == "true": - idens = [x.split("\t")[int(identifiers[3].replace("c", ""))-1] for x in mq[1:]] - else: - idens = [x.split("\t")[int(identifiers[3].replace("c", ""))-1] for x in mq] - ids = "\n".join(id_valid(idens)[0]) - 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> stderr" % ids).read() - if len(id_valid(idens)[1]) > 0: - trash = id_valid(idens)[1] + with open(identifiers[0],"r") as mq : + file_content = csv.reader(mq,delimiter="\t") + file_content = list(file_content) #csv object to list + ncol = identifiers[3] + if isnumber("int", ncol.replace("c", "")): + if header == "true": + idens = [x for x in [line[int(ncol.replace("c", ""))-1].split(";") for line in file_content[1:]]] + else: + idens = [x for x in [line[int(ncol.replace("c", ""))-1].split(";") for line in file_content]] + + idens = [item.strip() for sublist in idens for item in sublist if item != ''] #flat list of list of lists, remove empty items + ids = "\n".join(id_valid(idens)[0]) + 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> stderr" % ids).read() + if len(id_valid(idens)[1]) > 0: + trash = id_valid(idens)[1] #print(json_string) j = json.loads(json_string) print ("Identifiers not found: " + str(j["identifiersNotFound"])) diff -r 113cce3fc379 -r 34097acf457c reactome_analysis.xml --- a/reactome_analysis.xml Thu Dec 13 04:17:25 2018 -0500 +++ b/reactome_analysis.xml Thu Jun 27 04:21:19 2019 -0400 @@ -1,5 +1,5 @@ - - + + [Reactome] @@ -20,12 +20,12 @@ ]]> - + - + - + @@ -37,15 +37,17 @@ - - - + + + + [c]{0,1}[0-9]+ + - - - - + + + + @@ -67,13 +69,34 @@