# HG changeset patch # User devteam # Date 1393355803 18000 # Node ID 8cc7cf4bd833e7baa8116e32af57c35cf5a45dc4 # Parent 8c6dc9da6c89a0be7320a3b9752f74eb0ece5d67 Uploaded 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 + # () or ;(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__()