Exemple #1
0
def get_all_workspaces(get_latest_exposures=False,
    url="http://models.cellml.org/workspace/rest/contents.json"):
    """
    List all available CellML models.
    
    :param bool get_latest_exposures: Query models.cellml.org for latest 
        exposure for each model? This can take several minutes.
    :param str url: URL to list of cellml.org workspaces.
    :return: Record array with fields "title", "uri", "workspace",
        and optionally "exposure", "ew", where the latter can be passed to the 
        :meth:`Cellmlmodel` constructor.
    
    If you wanted to check out every workspace at cellml.org, 
    you could run the following in IPython::
    
        from cgp.physmod.cellmlmodels import get_all_workspaces
        w = get_all_workspaces()
        for uri in w.uri:
            !hg clone $uri
    """
    d = json.loads(urlcache(url))
    w = OrderedDict((k.lower(), v) 
                    for k, v in zip(d["keys"], zip(*d["values"])))
    w["workspace"] = [i.split("/")[-1] for i in w["uri"]]
    if get_latest_exposures:
        m = Cellmlmodel()
        w["exposure"] = []
        for ws in w["workspace"]:
            m.workspace = ws
            w["exposure"].append(m.get_latest_exposure())
    return dict2rec(w).view(np.recarray)
Exemple #2
0
 def __array__(self):
     """
     Convert timing to record array.
     
     >>> np.array(Timing())  # ...ellipsis to allow 0 or 0L
     array([(0..., nan, nan, nan, nan, nan)],
         dtype=[('attempts', '<i8'), ('waiting', '<f8'), ('started', '<f8'), 
         ('finished', '<f8'), ('error', '<f8'), ('seconds', '<f8')])
     """
     return dict2rec(self)
Exemple #3
0
def par2ph(par):
    """
    Phenotype: Equilibrium expression level of gene 2.
    
    This maps a parameter value to a phenotype value.
    """
    model._ReInit_if_required(y=np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]))
    model.pr[:] = par
    _t, y = model.eq(tmax=100, tol=1e-6)
    return dict2rec(dict(Y2=y[2] + y[3]))