Mercurial > repos > devteam > dgidb_annotator
diff dgidb_annotator.py @ 1:8cc7cf4bd833 draft
Uploaded
author | devteam |
---|---|
date | Tue, 25 Feb 2014 14:16:43 -0500 |
parents | 8c6dc9da6c89 |
children | 792f3cb0eff4 |
line wrap: on
line diff
--- 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__()