Using shell loop with entrez

This one's been a head-scratcher for me all this time - posting here just in case anyone else ran into the same issue.

Essentially, creating a shell while loop with entrez direct cli tools can't be done in the usual way, since standard input stream will continue to direct into the (already processed) entrez command, cutting out the loop. In these cases you need to redirect the first entrez command of the pipe.

Here's a quick example bash function - notice the /dev/null redirects:

multi_acc_search () {
    while IFS= read -r line; do
    echo $line > /dev/null
    esearch -db assembly -query $line < /dev/null | efetch -format docsum | xtract -pattern DocumentSummary -element AssemblyAccession
    done < $input   }

Login or Signup to leave a comment
Find your community. Ask questions. Science is better when we troubleshoot together.
Find your community. Ask questions. Science is better when we troubleshoot together.

Have a question?

Contact support@scifind.net or check out our support page.