#!/usr/bin/env python import os import os.path import subprocess import sys # SEARCH - a c-shell script # SEARCH searches GenBank using fasta # $1 is a FILESET containing the DNA sequence to search for # $2 is a FILESET containing the GenBank divisions (3-letter code) # you wish to be searched. testseq = os.path.splitext(sys.argv[1])[0] file_h = open(sys.argv[2], 'r') div = file_h.readlines() file_h.close() if os.environ.has_key('GB'): GB = os.environ.get('GB') if os.environ.has_key('THREADED'): THREADED = os.environ.get('THREADED') os.nice(10) for line in div: for token in line.split(): if os.path.exists(os.path.join(GB, 'gb' + token + '.ind')): NAMESET = (token) else: index = 1 NAMESET = () while os.path.exists(os.path.join(GB, 'gb' + token + str(index) + '.wrp')): NAMESET.append(token + str(index)) index += 1 for name in NAMESET: subprocess.call(['fasta3' + THREADED, sys.argv[1], os.path.join(GB, 'gb' + name + '.wrp'), \ '-k', '-o3', '-Q'], stdout=open(testseq + '.' + name + '.fasta', 'w')) os.nice(0)