2 # gene_to_aliases takes a list of genes and returns their aliases,
3 # and is released under the terms of the GPL version 2, or any later
4 # version, at your option. See the file README and COPYING for more
6 # Copyright 2009 by Don Armstrong <don@donarmstrong.com>.
7 # $Id: perl_script 1432 2009-04-21 02:42:41Z don $
18 gene_to_aliases - take a list of genes and return aliases
25 --debug, -d debugging level (Default 0)
26 --help, -h display this help
27 --man, -m display manual
35 Debug verbosity. (Default 0)
39 Display brief usage information.
58 my %options = (debug => 0,
64 'debug|d+','help|h|?','man|m');
66 pod2usage() if $options{help};
67 pod2usage({verbose=>2}) if $options{man};
69 $DEBUG = $options{debug};
73 # push @USAGE_ERRORS,"You must pass something";
76 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
81 next unless length $_;
85 my $m = WWW::Mechanize->new(autocheck => 0);
87 for my $gene (@genes) {
88 my $url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=gene&retmax=1&term='.
89 uri_escape($gene.'[Symbol] AND Homo[Orgn]');
90 my $content = get_loop($url);
97 $content = get_loop('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=gene&retmax=1&retmode=xml&id='.$id[0]);
99 m{<(?:Gene|Prot)-ref_(?:syn|name)_E>([^<]+)</(?:Gene|Prot)-ref_(?:syn|name)_E>}g;
100 print join("\t",$gene,@syn),qq(\n);
101 print $content if $DEBUG;
110 $content = $m->content;
115 } while ($counter < 100);