3 # under the terms of the GPL version 2, or any later version, at your
4 # option. See the file README and COPYING for more information.
5 # Copyright 2011 by Don Armstrong <don@donarmstrong.com>.
6 # $Id: perl_script 1825 2011-01-02 01:53:43Z don $
15 use Bio::DB::EUtilities;
17 use Encode qw(encode_utf8);
18 use Term::ANSIColor qw(:constants);
28 pubmed_search [options] [searchterms]
31 --debug, -d debugging level (Default 0)
32 --help, -h display this help
33 --man, -m display manual
41 Debug verbosity. (Default 0)
45 Display brief usage information.
61 my %options = (debug => 0,
71 'debug|d+','help|h|?','man|m');
73 pod2usage() if $options{help};
74 pod2usage({verbose=>2}) if $options{man};
76 $DEBUG = $options{debug};
80 push @USAGE_ERRORS,"You must pass something";
83 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
85 my $search = Bio::DB::EUtilities->new(-eutil => 'esearch',
86 -email => 'don@donarmstrong.com',
88 -term => join(' ',@ARGV),
91 my @ids = $search->get_ids();
92 # print scalar(@ids)." results:\n";
94 my $esummary = Bio::DB::EUtilities->new(-eutil => 'efetch',
95 -email => 'don@donarmstrong.com',
100 #print $esummary->get_Response()->content();
102 my $xml = XML::LibXML->load_xml(string => $esummary->get_Response()->content());
103 for my $gene ($xml->findnodes('Entrezgene-Set/Entrezgene')) {
104 # print $article->toString;
105 my ($locus) = $gene->findnodes('.//Gene-ref_locus');
106 my ($desc) = $gene->findnodes('.//Gene-ref_desc');
107 my ($summary) = $gene->findnodes('.//Entrezgene_summary');
108 if ($options{org_mode}) {
111 print BOLD GREEN if $options{color};
112 print $locus->textContent();
114 print RESET if $options{color};
115 print BOLD CYAN if $options{color};
116 print encode_utf8($desc->textContent())."\n";
117 print RESET if $options{color};
118 print BOLD MAGENTA if $options{color};
119 if (defined $summary) {
120 if ($options{org_mode}) {
121 print "** Summary\n";
123 $summary = $summary->textContent();
124 $summary =~ s/^\s*//mg;
125 $summary = encode_utf8($summary);
126 print wrap('','',$summary);
128 print RESET if $options{color};