#!/bin/csh
# 14 Dec. 1998

# given a set of names or accessions, create a file
# containing the corresponding genbank entries
#
#  $1 file containing LOCUS names or ACCESSION numbers
#  $2 file to contain all of the GenBank entries

set JOBID = $$

# From P. Rioux, Dec. 14, 1998:
# NCBI moved all Entrez access function to their WEB server,
# and the old TCP server is no longer maintained (I think it just reroutes
# the queries to the web server). Since the web server is stateless, this
# forces a tool such as nclever to reconnect all the time. At least, that's
# what I think is happening, I'm not sure. In the meantime, what you can
# do is NOT use trunctation mode for your queries. The server side is
# supposed (according to them) do the truncation for you, if necessary.
# This means that at the beginning of your nclever scripts, insert the
# command
#
#    option notruncation

echo "option notruncation" > infile.$JOBID

# This is allowed by the documentation, but
# doesn't work.
#echo "option noTruncationMode" > infile.$JOBID

echo "database nucleotide" >> infile.$JOBID
echo "report GenBank" >> infile.$JOBID

foreach name (`cat $1`)
      echo accession $name >> infile.$JOBID
end

echo union all >>  infile.$JOBID

echo save $2  all >>  infile.$JOBID

echo quit >>  infile.$JOBID

nclever -b  < infile.$JOBID

/usr/bin/rm  infile.$JOBID
