#!/usr/bin/env perl # PURPOSE: wrapper to eutils that allows sequential search and fetch # EXAMPLES: # ncbi_eutil -search db=nucleotide term=AC207960 -fetch rettype=qual > AC207960.qual # ncbi_eutil -search db=protein term='chicken[orgn]+AND+hox' -fetch rettype=fasta retmode=text outfile=Gallus-gallus_NCBI_2006-08-30_HOX.pfa3 # ncbi_eutil -search db=protein term='chicken[orgn]+AND+hox' -fetch rettype=fasta > Gallus-gallus_NCBI_2006-08-30_HOX.pfa3 # ncbi_eutil -search db=protein term='chicken[orgn]+AND+hox' -fetch 1 > Gallus-gallus_NCBI_2006-08-30_HOX.pfa3 use lib qw(/home/mec/local/src/NCBI_PowerScripting); use strict; use NCBI_PowerScripting; use Getopt::Long; my (%search, %fetch, %post, %fetch, %summary, %uids); my %params; my $result=GetOptions( "post=s{,}" => \%post, # typically db, id (could be a filename) "search=s{,}" => \%search, # db, term "fetch:s{,}" => \%fetch, #rettype retmode outfile "summary=s{,}" => \%summary, # outfile ); ################################################################################ # SET DEFAULTS ################################################################################ if (%summary) { $summary{outfile} ||= '-'; } if (%fetch) { $fetch{outfile} ||= '-'; # instead of 'fetch.out' $fetch{rettype} ||= 'fasta'; $fetch{retmode} ||= 'text'; } ################################################################################ # PROCESS ################################################################################ %params = epost_file(%params, %post) if %post; %params = esearch(%params, %search) if %search; if (%uids) { my @uids = get_uids(%params); foreach (@uids) { print "$_ "; } print "\n"; } %params = efetch_batch(%fetch, %params) if %fetch; %params = esummary_batch(%summary, %params) if %summary; exit 0;