X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=gene_search;h=9d1a3e2fab087226623323cf75e561c06ce87122;hb=56c8d8b286ae38e170ce915472f9aa86fabf9fee;hp=7f1ed28a2e8902284c67abdd558c706e6785a118;hpb=c9645f6b18d502c7a599e60b772faf2914ccab98;p=bin.git diff --git a/gene_search b/gene_search index 7f1ed28..9d1a3e2 100755 --- a/gene_search +++ b/gene_search @@ -63,11 +63,15 @@ my %options = (debug => 0, man => 0, color => 1, org_mode => 0, + symbol => 0, + organism => 'Homo sapiens', ); GetOptions(\%options, 'color|c!', - 'org_mode|org-mode', + 'org_mode|org-mode!', + 'symbol|s!', + 'organism|o=s', 'debug|d+','help|h|?','man|m'); pod2usage() if $options{help}; @@ -82,10 +86,15 @@ if (not @ARGV) { pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS; +my $term = join(' ',@ARGV); +if ($options{symbol}) { + $term = join(' OR ',map {'('.$_.'[Preferred Symbol] AND '.$options{organism}.'[Orgn])'} @ARGV); +} + my $search = Bio::DB::EUtilities->new(-eutil => 'esearch', -email => 'don@donarmstrong.com', -db => 'gene', - -term => join(' ',@ARGV), + -term => $term, -retmax => 1000, ); my @ids = $search->get_ids(); @@ -97,14 +106,18 @@ my $esummary = Bio::DB::EUtilities->new(-eutil => 'efetch', -id => \@ids, -retmode => 'xml', ); -#print $esummary->get_Response()->content(); +#print $esummary->get_Response()->content() if $DEBUG; use XML::LibXML; my $xml = XML::LibXML->load_xml(string => $esummary->get_Response()->content()); for my $gene ($xml->findnodes('Entrezgene-Set/Entrezgene')) { - # print $article->toString; + print $gene->toString if $DEBUG; my ($locus) = $gene->findnodes('.//Gene-ref_locus'); my ($desc) = $gene->findnodes('.//Gene-ref_desc'); my ($summary) = $gene->findnodes('.//Entrezgene_summary'); + my ($idiogram) = $gene->findnodes('.//Gene-ref_maploc'); + next unless defined $idiogram; + my ($start) = $gene->findnodes('.//Gene-commentary_seqs/Seq-loc/Seq-loc_int/Seq-interval/Seq-interval_from'); + my ($stop) = $gene->findnodes('.//Gene-commentary_seqs/Seq-loc/Seq-loc_int/Seq-interval/Seq-interval_to'); if ($options{org_mode}) { print "* "; } @@ -112,6 +125,9 @@ for my $gene ($xml->findnodes('Entrezgene-Set/Entrezgene')) { print $locus->textContent(); print ": "; print RESET if $options{color}; + print "(".$idiogram->textContent(); + print " ".$start->textContent().":"; + print $stop->textContent().") "; print BOLD CYAN if $options{color}; print encode_utf8($desc->textContent())."\n"; print RESET if $options{color};