def create(self): """POST /fastas: Create a new item.""" # url_for('fastas') uploadfile = request.POST['uploadfile'] fasta_file = open(os.path.join(permanent_store, uploadfile.filename.lstrip(os.sep)), 'w') shutil.copyfileobj(uploadfile.file, fasta_file) uploadfile.file.close() fasta_file.close() handle = open( fasta_file.name ) # if false: it = Bio.Fasta.Iterator(handle, Bio.Fasta.SequenceParser()) seq = it.next() c.sequences = [] output_string = "" while seq: c.sequences.append(seq) output_string += seq.description output_string += "<br /> " log.debug("seq : %s" , seq.description) seq = it.next() handle.close() fastafile.formatdb(fasta_file.name) log.debug('Hello Kenglish' ) print "Hello Kenglish" return render('/fastas/created_fasta.mako') return 'Successfully uploaded: %s, description: %s, <br /> results: <br /> %s ' % \ (uploadfile.filename, request.POST['description'], output_string)
def blast_2_files(input_filename,input_db): blast_db = fastafile.PERMANENT_STORE + input_db blast_file = fastafile.PERMANENT_STORE + input_filename if not os.path.exists(blast_db + ".nin"): fastafile.formatdb(blast_db) blast_out, error_handle = NCBIStandalone.blastall(BLAST_EXE, BLAST_PROGRAM, blast_db, blast_file) return blast_out
def upload(self): message = "They called file upload " + request.POST["Filedata"].filename log.debug(message) uploadfile = request.POST["Filedata"] fasta_file = open(os.path.join(permanent_store, uploadfile.filename.lstrip(os.sep)), 'w') shutil.copyfileobj(uploadfile.file, fasta_file) uploadfile.file.close() fasta_file.close() fastafile.formatdb(fasta_file.name)
def create(self): """POST /flexfastas: Create a new item.""" # url_for('flexfastas') message = "They called file upload " + request.POST["Filedata"].filename log.debug(message) uploadfile = request.POST["Filedata"] fasta_file = open(os.path.join(permanent_store, uploadfile.filename.lstrip(os.sep)), 'w') shutil.copyfileobj(uploadfile.file, fasta_file) uploadfile.file.close() fasta_file.close() fastafile.formatdb(fasta_file.name)