Package: medirect
medirect - a multiprocessed utility for retrieving records and parsing feature tables from ncbiTable of ContentsauthorsutilitiesaboutdependenciesinstallationexamplesissueslicenseauthorsChris RosenthalutilitiesmefetchftractaboutAs a bioinformatician I build a lot of bacterial dna reference databases.
Part of my job is to gather sequences data where it is available from outside
sources. One of those sources is the NCBI nucleotide database.  I designed this
package to help me gather data from NCBI quickly by utilizing multiple processors
to make multiple data requests from the NCBI database servers.  The utilities
mefetch and ftract are designed to work like efetch and xtract and
can be slotted in along with other ncbi utilities and follow the same edirectdocumentation,guidelines and requirementsandusage policies.  The
utilities have primarily been tested on the nucleotide database but should work
on any type of data available through the NCBI servers.The mefetch utility is designed to be fast and can easily overwhelm the NCBI servers.
For this reason I highlight two points from the usage policy:Run retrieval scripts on weekends or between 9 pm and 5 am Eastern Time weekdays for any series of more than 100 requests.Make no more than 3 requests every 1 second.The ftract utility pattern matches features based on the three column table
structure described here:feature tablesIt is designed to parse data and coordinates from feature tables which are
magnitudes smaller and faster to parse than the xml tables and xtract parser utility
available as part of the standard edirect package.  The entire edirect package
is available here:ftp downloadsdependenciesPython 3.xbiopython>= 1.68retrying>= 1.3.3installationmedirect can be installed in two ways:For regular users:% pip3 install medirectFor developers:% pip3 install git://github.com/crosenth/medirect.git
# or
% git clone git://github.com/crosenth/medirect.git
% cd medirect
% python3 setup.py installexamplesThe mefetch executable works exactly like edirectefetchwith a an
additional multiprocessing argument-procand a few more features.By allowing additional processes to download records The-procargument
allows a linear download speed increase downloading large datasets.Here is an example downloading 255,303 Rhizobium sequence accessions using one processor:% esearch -db nucleotide -query 'Rhizobium' | time mefetch -email user@ema.il -mode text -format acc -proc 1 > accessions.txt
0.53s user 0.11s system 0% cpu 12:43.11 totalWhich is equivalent to ncbi efetch:% esearch -db nucleotide -query 'Rhizobium' | time efetch -mode text -format acc > accessions.txt
0.53s user 0.11s system 0% cpu 12:47.54 totalAdding another processor-proc2:% esearch -db nucleotide -query 'Rhizobium' | time mefetch -email user@ema.il -proc 2 -mode text -format acc > accessions.txt
0.46s user 0.08s system 0% cpu 5:17.51 totalAnd another-proc3(default):% esearch -db nucleotide -query 'Rhizobium' | time mefetch -email user@ema.il -proc 3 -mode text -format acc > accessions.txt
0.35s user 0.10s system 0% cpu 2:57.01 totalAnd-proc4(see usage policy):% esearch -db nucleotide -query 'Rhizobium' | time mefetch -email user@ema.il -proc 4 -mode text -format acc > accessions.txt
0.35s user 0.08s system 0% cpu 1:40.54 totalResults can be returned in the exact order they intended by the NCBI
server using the-in-orderargument.  Otherwise, the order will be
determined by how fast ncbi returns results per process.The-retmaxargument (or chunksize) determines the number of results
returned per-proc.  By default, it is set to the 10,000 max records perdocumentation.
Setting the-retmaxto higher than 10,000 will automatically be set back
down to 10,000.By default the-idreads stdin xml output fromesearch.  The-idargument can also take input as a comma delimited list of ids or text
file of ids.  When coupled with the-csvargument the input can be a csv
file with additional argument columns.  This is useful for bulk downloads with
different positional arguments.ftract allows csv output of different features from ncbifeature tables.
The required-featureargument is comma separated
feature_key:qualifier_key:qualifier_value% mefetch -id KN150849 -db nucleotide -email user@ema.il -format ft | ftract --feature rrna:product:16s
id,seq_start,seq_stop,strand
KN150849.1,594136,595654,2
KN150849.1,807985,809503,2
KN150849.1,2227751,2229271,1And pipe this back into mefetch to download these three regions in genbank format:% mefetch -id KN150849 -db nucleotide -email user@ema.il -format ft | ftract --feature rrna:product:16s | mefetch -db nucleotide -email crosenth@uw.edu -csv -format gbAnd finally combining all these concepts, return all the Burkholderia gladioli 16s rrna products in fasta format using the default-proc3like this:% esearch -query 'Burkholderia gladioli AND sequence_from_type[Filter]' -db 'nucleotide' | mefetch -email user@ema.il -format ft | ftract --feature rrna:product:16s | mefetch -db nucleotide -email user@ema.il -csv -format fasta
0.24s user 0.05s system 1% cpu 18.596 totalissuesPlease use the Issue Tracker(s) available on Github or Bitbucket to report any bugs
or feature requests.  For all other inquiries emailChris Rosenthal.licenseCopyright (c) 2016 Chris RosenthalReleased under theGPLv3License