<commit_before>from django.http import HttpResponse
from django.core import serializers
import json
import httplib

import models

from django.shortcuts import redirect
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response
from django.template import RequestContext


"""
post view: post a sequence and run the sequence through blat and orf
detection.

    expects: db and sequence
    response:
        1. if 'next' is specified as a CGI argument, redirect to that
        URL with '/hash/db_name/' appended, where 'hash' is the hash
        ID of the sequence and 'db_name' is the name of the features
        database.
        2. otherwise, redirects to the 'get' view that returns JSON
        array of features.
"""
def post(request):
    assert (request.method == 'POST')
    db_name = request.POST['db']
    sequence = request.POST['sequence']
    hash = models.Giraffe_Mappable_Model.detect_features(sequence,db_name)
    if 'next' in request.POST:
        u = request.POST['next']
        if u.endswith('/'):
            u = u+hash+'/'+db_name
        else:
            u = u+'/'+hash+'/'+db_name
        return redirect(u)<commit_msg>Remove unnecessary inmports<commit_after>from django.http import HttpResponse
import json
import httplib

import models

from django.shortcuts import redirect
from django.core.urlresolvers import reverse


"""
post view: post a sequence and run the sequence through blat and orf
detection.

    expects: db and sequence
    response:
        1. if 'next' is specified as a CGI argument, redirect to that
        URL with '/hash/db_name/' appended, where 'hash' is the hash
        ID of the sequence and 'db_name' is the name of the features
        database.
        2. otherwise, redirects to the 'get' view that returns JSON
        array of features.
"""
def post(request):
    assert (request.method == 'POST')
    db_name = request.POST['db']
    sequence = request.POST['sequence']
    hash = models.Giraffe_Mappable_Model.detect_features(sequence,db_name)
    if 'next' in request.POST:
        u = request.POST['next']
        if u.endswith('/'):
            u = u+hash+'/'+db_name
        else:
            u = u+'/'+hash+'/'+db_name
        return redirect(u)
{'fraction_non_alphanumeric': 0.09276520195295163, 'fraction_numerical': 0.001775410563692854, 'mean_word_length': 2.9131944444444446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '342544', 'n_tokens_mistral': 650, 'n_tokens_neox': 635, 'n_words': 233}