def submit_blast(request): if (request.method == "POST"): postDict = request.POST fileDict = request.FILES response = "" if (postDict.has_key('blast_db')): database = postDict['blast_db'] root = settings.STATIC_ROOT media_root = settings.MEDIA_ROOT landmark = Landmark.objects.get(organism_id__exact=int(database)) os.system("formatdb -p F -i " + root + "/" + str(landmark.name).lower() + ".fasta") sequence = postDict['sequence'] if (sequence != ""): tmp_fasta_file = open(root + "/tmp.fasta", "w") tmp_fasta_file.write(sequence) tmp_fasta_file.close() blast_result = os.popen("blastall -p blastn -d " + root + "/" + str(landmark.name).lower() + ".fasta -T T -i " + root + "/tmp.fasta") response = "<pre>" + " ".join( blast_result.readlines()) + "</pre>" os.system("rm " + root + "/" + str(landmark.name).lower() + ".fasta.n*") os.system("rm " + root + "/tmp.fasta") elif (fileDict.has_key('file')): uploadedFile = fileDict['file'] fasta = BlastUpload(fasta_file=uploadedFile, name=uploadedFile.name) fasta.save() blast_result = os.popen("blastall -p blastn -d " + root + "/" + str(landmark.name).lower() + ".fasta -T T -i " + media_root + "/" + str(fasta.fasta_file)) response = "<pre>" + " ".join( blast_result.readlines()) + "</pre>" os.system("rm " + root + "/" + str(landmark.name).lower() + ".fasta.n*") os.system("rm " + media_root + "/" + str(fasta.fasta_file)) fasta.delete() #response = "blastall -p blastn -d " + root + "/" + landmark.name.lower() + ".fasta -m 0 -i " + media_root + "/" + str(fasta.fasta_file) # change this to the results page #return HttpResponseRedirect(reverse('mycoplasma_home.views.blast')) return HttpResponse(response) else: error = "Not a Post" return HttpResponse("Error: " + error)
def doProcessRender(self, request): self.setLayout('public/blast.html') if (request.method == "POST"): fileDict = request.FILES response = "" if (request.POST.has_key('blast_db')): database = request.POST['blast_db'] root = settings.STATIC_ROOT media_root = settings.MEDIA_ROOT landmark = Landmark.objects.get( organism_id__exact=int(database)) #os.system("formatdb -p F -i " + root + "/" + str(landmark.name).lower() + ".fasta") sequence = request.POST['sequence'] if (sequence != ""): tmp_fasta_file = NamedTemporaryFile(mode='w+b', suffix='.fasta', dir='/tmp', delete=False) tmp_fasta_file.write(sequence) tmp_fasta_file.close() blast_result = os.popen("blastall -p blastn -d " + root + "/" + str(landmark.name).lower() + ".fasta -T T -i " + root + "/tmp.fasta") response = "<pre>" + " ".join( blast_result.readlines()) + "</pre>" os.remove(tmp_fasta_file.name) elif (fileDict.has_key('file')): uploadedFile = fileDict['file'] fasta = BlastUpload(fasta_file=uploadedFile, name=uploadedFile.name) fasta.save() blast_result = os.popen("blastall -p blastn -d " + root + "/" + str(landmark.name).lower() + ".fasta -T T -i " + media_root + "/" + str(fasta.fasta_file)) response = "<pre>" + " ".join( blast_result.readlines()) + "</pre>" os.system("rm " + root + "/" + str(landmark.name).lower() + ".fasta.n*") os.system("rm " + media_root + "/" + str(fasta.fasta_file)) fasta.delete() return {'response': response}
def doProcessRender(self, request): self.setLayout('public/blast.html') if (request.method == "POST"): fileDict = request.FILES response = "" if (request.POST.has_key('blast_db')): database = request.POST['blast_db'] root = settings.STATIC_ROOT media_root = settings.MEDIA_ROOT landmark = Landmark.objects.get(organism_id__exact=int(database)) #os.system("formatdb -p F -i " + root + "/" + str(landmark.name).lower() + ".fasta") sequence = request.POST['sequence'] if (sequence != ""): tmp_fasta_file = NamedTemporaryFile(mode='w+b', suffix='.fasta', dir='/tmp', delete=False) tmp_fasta_file.write(sequence) tmp_fasta_file.close() blast_result = os.popen("blastall -p blastn -d " + root + "/" + str(landmark.name).lower() + ".fasta -T T -i " + root + "/tmp.fasta") response = "<pre>" + " ".join(blast_result.readlines()) + "</pre>" os.remove(tmp_fasta_file.name) elif (fileDict.has_key('file')): uploadedFile = fileDict['file'] fasta = BlastUpload(fasta_file=uploadedFile, name=uploadedFile.name) fasta.save() blast_result = os.popen("blastall -p blastn -d " + root + "/" + str(landmark.name).lower() + ".fasta -T T -i " + media_root + "/" + str(fasta.fasta_file)) response = "<pre>" + " ".join(blast_result.readlines()) + "</pre>" os.system("rm " + root + "/" + str(landmark.name).lower() + ".fasta.n*") os.system("rm " + media_root + "/" + str(fasta.fasta_file)) fasta.delete() return { 'response' : response }
def submit_blast(request): if request.method == "POST": postDict = request.POST fileDict = request.FILES response = "" if postDict.has_key("blast_db"): database = postDict["blast_db"] root = settings.STATIC_ROOT media_root = settings.MEDIA_ROOT landmark = Landmark.objects.get(organism_id__exact=int(database)) os.system("formatdb -p F -i " + root + "/" + str(landmark.name).lower() + ".fasta") sequence = postDict["sequence"] if sequence != "": tmp_fasta_file = open(root + "/tmp.fasta", "w") tmp_fasta_file.write(sequence) tmp_fasta_file.close() blast_result = os.popen( "blastall -p blastn -d " + root + "/" + str(landmark.name).lower() + ".fasta -T T -i " + root + "/tmp.fasta" ) response = "<pre>" + " ".join(blast_result.readlines()) + "</pre>" os.system("rm " + root + "/" + str(landmark.name).lower() + ".fasta.n*") os.system("rm " + root + "/tmp.fasta") elif fileDict.has_key("file"): uploadedFile = fileDict["file"] fasta = BlastUpload(fasta_file=uploadedFile, name=uploadedFile.name) fasta.save() blast_result = os.popen( "blastall -p blastn -d " + root + "/" + str(landmark.name).lower() + ".fasta -T T -i " + media_root + "/" + str(fasta.fasta_file) ) response = "<pre>" + " ".join(blast_result.readlines()) + "</pre>" os.system("rm " + root + "/" + str(landmark.name).lower() + ".fasta.n*") os.system("rm " + media_root + "/" + str(fasta.fasta_file)) fasta.delete() # response = "blastall -p blastn -d " + root + "/" + landmark.name.lower() + ".fasta -m 0 -i " + media_root + "/" + str(fasta.fasta_file) # change this to the results page # return HttpResponseRedirect(reverse('mycoplasma_home.views.blast')) return HttpResponse(response) else: error = "Not a Post" return HttpResponse("Error: " + error)