Repository 'dgidb_annotator'
hg clone https://toolshed.g2.bx.psu.edu/repos/devteam/dgidb_annotator

Changeset 1:8cc7cf4bd833 (2014-02-25)
Previous changeset 0:8c6dc9da6c89 (2013-11-27) Next changeset 2:792f3cb0eff4 (2014-02-25)
Commit message:
Uploaded
modified:
dgidb_annotator.py
b
diff -r 8c6dc9da6c89 -r 8cc7cf4bd833 dgidb_annotator.py
--- a/dgidb_annotator.py Wed Nov 27 23:51:48 2013 -0500
+++ b/dgidb_annotator.py Tue Feb 25 14:16:43 2014 -0500
[
@@ -2,7 +2,7 @@
 Annotates a tabular file with information from the Drug-Gene Interaction (DGI) database.
 '''
 
-import optparse, json, urllib2, sys
+import optparse, json, urllib2, sys, re
 
 def __main__():
     # -- Parse command line. --
@@ -25,13 +25,17 @@
     gene_list = []
     lines = []
     for line in input_file:
-        gene_list.append( line.split('\t')[gene_name_col].strip() )
+        entry = line.split('\t')[gene_name_col].strip()
+        # Some annotations may be of the form 
+        #    <gene_name>(<splicing_info>) or <gene_name>;<gene_name>(splicing_info)
+        gene_list.append(entry.split(';')[0].split('(')[0])
         lines.append(line.strip())
     
     # Query for results.
     query_str = 'http://dgidb.genome.wustl.edu/api/v1/interactions.json?genes=%s' % ','.join(set(gene_list))
     if options.expert_curated:
         query_str += '&source_trust_levels=Expert%20curated'
+    print query_str
     results = urllib2.urlopen(query_str).read()
     results_dict = json.loads(results)
     
@@ -61,4 +65,4 @@
         elif options.print_all:
             print line
 
-if __name__=="__main__": __main__()
\ No newline at end of file
+if __name__=="__main__": __main__()