Example #1
0
def index():
    i = request.vars.i or 0
    #s = "((((((((((T._windsori_oli117:0.10632847,T._windsori_oli116:0.10632847):0.04722967,(T._montislewisi_oli86:0.11755736,T._montislewisi_oli81:0.11755736):0.03600078):0.07131713,(T._sp._nov._oli122:0.02829776,T._sp._nov._oli119:0.02829776):0.19657751):0.01112654,T._carbinensis_oli76:0.23600181):0.0298459,(((T._nashi_OLI83:0.02125559,T._nashi_OLI29:0.02125559):0.02378355,T._nashi_oli23:0.04503914):0.10589362,(T._nashi_oli67:0.1104632,(T._liber_Paris:0.03137278,T._liber_oli88:0.03137278):0.07909041):0.04046956):0.11491495):0.015917,T._sp._nov._oli85:0.28176471):0.00699509,((((T._terrareginae_oli79:0.12986896,(T._canaliculatus_oli82:0.05718215,T._canaliculatus_oli10:0.05718215):0.07268681):0.02825186,(T._canaliculatus_oli92:0.08427881,(T._canaliculatus_OLI37:0.01226744,T._canaliculatus_OLI31:0.01226744):0.07201137):0.07384202):0.03424563,T._kuranda_oli55:0.19236646):0.06071168,T._miseriae_oli77:0.25307813):0.03568166):0.00806363,T._mcilwraithi_oli75:0.29682342):0.01063206,(T._grandis_oli126:0.0,T._grandis_oli125:0.0):0.30745548):0.03417052,(((T._phalacrus_oli90:0.09751735,T._phalacrus_oli44:0.09751735):0.16894837,(T._millamilla_oli48:0.0,T._millamilla_oli39:0.0):0.26646572):0.0285159,((T._erici_oli91:0.11421808,T._erici_oli89:0.11421808):0.06572013,(T._erici_oli57:0.1279707,(T._erici_OLI35:0.03200512,T._erici_43:0.03200512):0.09596559):0.05196751):0.11504341):0.04664438):0.01293956;"
    m = current_model()
    s = m.treelist.trees[i].newick
    root = newick.parse(s)
    return dict(treediv=nodes2css(root))
def upload_newick():
    #n = "_".join(request.vars.name.strip().split())
    n = None
    age = request.vars.age.strip()
    if age:
        try:
            age = float(age)
        except:
            session.flash = "Age must be a number"
    s = request.vars.newick_string.strip()
    if s:
        r = None
        try:
            r = newick.parse(s)
        except:
            session.flash = "Problem with newick string"
        if r:
            m = current_model()
            m.treelist.append(s, name=n, age=age)
            t = m.treelist.trees[-1]
            t.parse()
            if not t.scaled:
                for n in t.root.iternodes():
                    if n.parent and (n.length is None):
                        n.length = 1
                t.calibrate()
                t.scaled = True
                t.newick = newick.tostring(t.root)+";"
                session.flash = "Branches without lengths assigned a value of 1"
            if not t.is_ultrametric():
                session.flash = "Tree is not ultrametric"
    redirect(URL(r=request, f=request.vars.f or "index"))
def upload_newick():
    #n = "_".join(request.vars.name.strip().split())
    n = None
    age = request.vars.age.strip()
    if age:
        try:
            age = float(age)
        except:
            session.flash = "Age must be a number"
    s = request.vars.newick_string.strip()
    if s:
        r = None
        try:
            r = newick.parse(s)
        except:
            session.flash = "Problem with newick string"
        if r:
            m = current_model()
            m.treelist.append(s, name=n, age=age)
            t = m.treelist.trees[-1]
            t.parse()
            if not t.scaled:
                for n in t.root.iternodes():
                    if n.parent and (n.length is None):
                        n.length = 1
                t.calibrate()
                t.scaled = True
                t.newick = newick.tostring(t.root) + ";"
                session.flash = "Branches without lengths assigned a value of 1"
            if not t.is_ultrametric():
                session.flash = "Tree is not ultrametric"
    redirect(URL(r=request, f=request.vars.f or "index"))
Example #4
0
 def parse(self, s=None):
     if s:
         self.newick = s
     self.root = newick.parse(self.newick)
     scaled = True
     for i, n in enumerate(self.root.iternodes(phylo.POSTORDER)):
         n.number = i
         if (not n.istip) and (not n.label):
             n.label = "N%s" % n.number
         n.age = None
         if n.parent and (n.length is None):
             scaled = False
     if scaled:
         for i, n in enumerate(self.root.iternodes(phylo.POSTORDER)):
             if n.length == 0:
                 n.length = 1e-05
     self.newick = newick.tostring(self.root) + ";"
     self.scaled = scaled
Example #5
0
 def parse(self, s=None):
     if s:
         self.newick = s
     self.root = newick.parse(self.newick)
     scaled = True
     for i, n in enumerate(self.root.iternodes(phylo.POSTORDER)):
         n.number = i
         if (not n.istip) and (not n.label):
             n.label = "N%s" % n.number
         n.age = None
         if n.parent and (n.length is None):
             scaled = False
     if scaled:
         for i, n in enumerate(self.root.iternodes(phylo.POSTORDER)):
             if n.length == 0:
                 n.length = 1e-05
     self.newick = newick.tostring(self.root)+";"
     self.scaled = scaled
Example #6
0
def datamatrix_default_from_tree():
    try:
        i = int(request.vars.t)
    except:
        session.flash = "no tree '%s'" % i
        redirect(URL(r=request,f=request.vars.f or "index"))
    try:
        nareas = int(request.vars.nareas)
        if nareas > 8:
            session.flash = "that is a lot of areas! (more than 8)"
    except:
        session.flash = "areas must be an integer"
        redirect(URL(r=request,f=request.vars.f or "index"))
        
    m = current_model()
    m.datamatrix = bridge.DataMatrix(m)
    t = newick.parse(m.treelist.trees[i].newick)
    m.datamatrix.default_from_tree(i, nareas)
    u = URL(r=request, f=request.vars.f or "index")
    redirect(u)
Example #7
0
def upload_newick():
    n = "_".join(request.vars.name.strip().split())
    age = request.vars.age.strip()
    print "age:", age
    if age:
        try:
            age = float(age)
        except:
            session.flash = "Age must be a number"
    s = request.vars.newick_string.strip()
    if s:
        r = None
        try:
            r = newick.parse(s)
            if r:
                m = current_model()
                m.treelist.append(s, name=n, age=age)
        except:
            session.flash = "Problem with newick string"
    redirect(URL(r=request, f=request.vars.f or "index"))
def datamatrix_default_from_tree():
    try:
        i = int(request.vars.t)
    except:
        session.flash = "no tree '%s'" % i
        redirect(URL(r=request,f=request.vars.f or "index"))
    try:
        nareas = int(request.vars.nareas)
        if nareas > 8:
            session.flash = "sorry, more than 8 areas not supported at this time"
            redirect(URL(r=request,f=request.vars.f or "index"))
    except:
        session.flash = "areas must be an integer"
        redirect(URL(r=request,f=request.vars.f or "index"))
        
    m = current_model()
    m.datamatrix = models.DataMatrix(m)
    t = newick.parse(m.treelist.trees[i].newick)
    m.datamatrix.default_from_tree(i, nareas)
    u = URL(r=request, f=request.vars.f or "index")
    session.ti = 0
    redirect(u)
def datamatrix_default_from_tree():
    try:
        i = int(request.vars.t)
    except:
        session.flash = "no tree '%s'" % i
        redirect(URL(r=request, f=request.vars.f or "index"))
    try:
        nareas = int(request.vars.nareas)
        if nareas > 8:
            session.flash = "sorry, more than 8 areas not supported at this time"
            redirect(URL(r=request, f=request.vars.f or "index"))
    except:
        session.flash = "areas must be an integer"
        redirect(URL(r=request, f=request.vars.f or "index"))

    m = current_model()
    m.datamatrix = models.DataMatrix(m)
    t = newick.parse(m.treelist.trees[i].newick)
    m.datamatrix.default_from_tree(i, nareas)
    u = URL(r=request, f=request.vars.f or "index")
    session.ti = 0
    redirect(u)
Example #10
0
def newick2css():
    i = request.vars.i or 0
    m = current_model()
    s = m.treelist.trees[i].newick
    root = newick.parse(s)
    return nodes2css(root)