Beispiel #1
0
def csv(request):
    import csv
    path=eval(request.POST['path'])
    org=request.POST['org']
    maincmps,rxns,name=zip(*path)
    rxns=list(rxns[:-1])
    response = HttpResponse(mimetype='text/csv')
    response['Content-Disposition'] = 'attachment; filename=imp.csv'
    writer = csv.writer(response)
    writer.writerow(['Reaction','Reactants','Products','Enzyme','Genes'])
    csvmaker.csv1(writer,rxns, org)
    writer.writerow(['','','','',''])
    writer.writerow(['','','','',''])
    writer.writerow(['Stoichiometric Matrix'])
    (mat,seen)=matrix(rxns)
    csvmaker.csv2(writer,rxns,mat,seen)
    return response
Beispiel #2
0
def detail(request):
    c = {}
    c.update(csrf(request))
    path=eval(request.POST['path'])
    wt1=float(request.POST['wt1'])
    wt2=float(request.POST['wt2'])
    wt3=float(request.POST['wt3'])
    wt4=float(request.POST['wt4'])
    wt5=float(request.POST['wt5']) #Node order
    wt6=float(request.POST['wt6']) #Org
    org=request.POST['orgchoice']
    rmlst=request.POST['rmlst'][:-1]
    starter=request.POST['typein']
    ender=request.POST['typeout']
    try:
        starter=CompoundName.objects.get(Name=starter).comp.KeggID
    except:
        try:
            starter= CompoundName.objects.get(Name=starter + ';').comp.KeggID
        except:
            if not re.match('C[0-9]{5}',starter):
                c.update({'message': 'Search by KeggID or check your spelling.'})
                return render_to_response('igemnopath.html',c)
            #regular expression, also igemnopath
    try:
        ender=CompoundName.objects.get(Name=ender).comp.KeggID
    except:
        try:
            ender = CompoundName.objects.get(Name=ender + ';').comp.KeggID
        except:
            if not re.match('C[0-9]{5}',starter):
                c.update({'message':'Search by KeggID or check your spelling'})
                return render_to_response('igemnopath.html',c)

    maincmps,rxns,name=zip(*path)
    (mat,seen)=matrix(rxns[:-1],maincmps)
    pair=zip(mat,seen)
    #from ybr import optimize
    #print optimize(rxns,maincmps)
    #return HttpResponse(path)
    aux = optimize(rxns,maincmps)
    c.update({'aux':aux})
    c.update({'path':path,'in':starter,'out':ender,'wt1':wt1,'wt2':wt2,'wt3':wt3,'wt4':wt4,'wt5':wt5,'wt6':wt6,'org':org,'removed':rmlst,'pair':pair})
    return render_to_response('igemdetailpage.html',c)