changeset 1:b65ee881ca64 draft

planemo upload for repository http://unipept.ugent.be/apidocs commit e91b0fe16bf468b34884508652359b91847d1f95
author galaxyp
date Tue, 22 Jan 2019 20:58:28 -0500
parents b33376bf2290
children dca8a1fe0bf3
files unipept.py unipept.xml
diffstat 2 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/unipept.py	Wed Oct 24 14:45:18 2018 -0400
+++ b/unipept.py	Tue Jan 22 20:58:28 2019 -0500
@@ -183,7 +183,7 @@
       return None
     elif len(matches) == 1:
       return matches[0].copy()
-    else:
+    elif 'taxon_rank' in matches[0]:
       # find the most specific match (peptide is always the first column order field)
       for col in reversed(pept2lca_extra_column_order[1:]):
         col_id = col+"_id" if options.extra else col
@@ -192,6 +192,8 @@
             return match.copy()
           if col_id in match and match[col_id]:
             return match.copy()
+    else:
+      return sorted(matches, key=lambda x: len(x['peptide']))[-1].copy()
     return None
 
   def get_taxon_json(resp):
@@ -280,7 +282,10 @@
           protein_count = ec['protein_count']
           ec_number = ec['ec_number']
           for ec_id in get_ids(ec_number):
-            child = get_node(ec_id,ec_id,child,seq)
+            ec_name = str(ec_id)
+            ## if len(ec_id) == 3:
+            ##   ec_name = '%s\n%s\n%s' %(str(ec_id), ec_name_dict[str(ec_id[0])],  ec_name_dict[str(ec_id)])
+            child = get_node(ec_id,ec_name,child,seq)
             seq = None
           if child:
             get_node(0,'-.-.-.-',child,None)
@@ -499,11 +504,11 @@
       post_data.append(("domains","true"))
     post_data += [('input[]', x) for x in trypticPeptides[idx[i]:idx[i+1]]]
     if options.debug: print >> sys.stdout, "post_data: %s\n" % (str(post_data))
-    params = '&'.join(['%s=%s' % (i[0],i[1]) for i in post_data])
-    #headers = {'Content-Type': 'application/x-www-form-urlencoded',  'Accept': 'application/json'}
-    headers = {'Accept': 'application/json'}
+    headers = {'Content-Type': 'application/x-www-form-urlencoded',  'Accept': 'application/json'}
+    ## headers = {'Accept': 'application/json'}
     url = '%s/%s' % (options.url.rstrip('/'),options.unipept)
     if options.get:
+      params = '&'.join(['%s=%s' % (i[0],i[1]) for i in post_data])
       url = '%s.json?%s' % (url,params)
       req = urllib2.Request( url )
     else:
@@ -546,7 +551,7 @@
           match['tryptic_peptide'] = match['peptide']
           match['peptide'] = peptide
           peptideMatches.append(match)
-  elif options.unipept in ['pept2lca']:
+  elif options.unipept in ['pept2lca', 'peptinfo']:
     ## should be one response per trypticPeptide for pep2lca
     respMap = {v['peptide']:v for v in unipept_resp}
     ## map resp back to peptides
--- a/unipept.xml	Wed Oct 24 14:45:18 2018 -0400
+++ b/unipept.xml	Tue Jan 22 20:58:28 2019 -0500
@@ -228,7 +228,6 @@
             </conditional>
             -->
         </actions>
-peptide,total_protein_count,ec_numbers,ec_protein_counts,ec_names,go_terms,go_protein_counts,go_names
       </data> 
       <data name="output_csv" format="csv" label="${tool.name} ${unipept.api} on ${on_string} csv"> 
         <filter>'csv' in selected_outputs</filter>
@@ -288,7 +287,7 @@
         <output name="output_tsv">
             <assert_contents>
               <has_text text="9606" />
-              <has_text text="9598" />
+              <has_text text="9596" />
             </assert_contents>
         </output>
       </test>
@@ -303,33 +302,33 @@
         <output name="output_tsv">
             <assert_contents>
               <has_text text="sapiens" />
-              <has_text text="troglodytes" />
+              <has_text text="paniscus" />
               <has_text text="Gorilla" />
-              <has_text text="Macaca" />
             </assert_contents>
         </output>
       </test>
       <test>
-        <param name="api" value="pept2lca"/>
+        <param name="api" value="pept2funct"/>
         <param name="fmt" value="tabular"/>
-        <param name="input_tsv" value="tryptic.tsv"/>
+        <param name="input_tsv" value="input.tsv"/>
         <param name="column" value="2"/>
         <param name="extra" value="True"/>
         <param name="names" value="True"/>
         <param name="selected_outputs" value="tsv,ec_tsv,go_tsv,unmatched"/>
         <output name="output_tsv">
             <assert_contents>
-              <has_text text="3.2.1.17" />
+              <has_text text="GO:0004802" />
+              <has_text text="2.2.1.1" />
             </assert_contents>
         </output>
         <output name="output_ec_tsv">
             <assert_contents>
-              <has_text text="3.2.1.17" />
+              <has_text text="2.2.1.1" />
             </assert_contents>
         </output>
         <output name="output_go_tsv">
             <assert_contents>
-              <has_text text="GO:0006412" />
+              <has_text text="GO:0004802" />
             </assert_contents>
         </output>
       </test>