I'm running a script which finds regions of interest, outputs them to a fasta, then passes them to blastn. Both steps work independently, but the script wont wait for the file to be generated and says:
./seq_targeter.py -i ecoli.fa -o tester -B
Testing if regions match guidelines.
Running blastn for all generated sequences.
('', 'Warning: [blastn] Query is Empty!\n')
All done, see files: tester-table.txt, tester.fasta and tester.bln
The script is basically this:
def main():
outfasta = open(args.o + ".fasta", 'w')
seqTargeter(outfasta) # Outputs a fasta file as expected
blastFunc(args.o + ".fasta") # Outputs a blank file and gives error above
seqTargeter(outfasta):
print "Testing if regions match guidelines."
.................
outfasta.write('...........')
def blastFunc(blastfasta):
print "Running blastn for all generated sequences."
blastn_cline = NcbiblastnCommandline(query=blastfasta, db=args.d, outfmt=7, out=args.o + ".bln")()
print blastn_cline
If I comment out the seqTargeter parts and let the script run on the already generated output.fasta file, then blastn will be called correctly and give the correct output. But if I want them both to work after the other, then nothing. I've been looking at something like this from Stackexchange, but I think the file exists doesn't work as it's still being generated...
Thanks
Reposted comment as answer.
Perfect, totally what I'd missed. If you put this as an answer I could accept it.