#!/usr/bin/env python import subprocess import sys # 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 # 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 p = subprocess.Popen(['nclever', '-b'], stdin=subprocess.PIPE) p.stdin.write("option notruncation\n") # This is allowed by the documentation, but # doesn't work. #p.stdin.write("option noTruncationMode\n") p.stdin.write("database nucleotide\n") p.stdin.write("report GenBank\n") file_h = open(sys.argv[1], 'r') for line in file_h: for name in line.split(): p.stdin.write("accession " + name + "\n") file_h.close() p.stdin.write("union all\n") p.stdin.write("save $2 all\n") p.stdin.write("quit\n") p.stdin.close() p.wait()