コード例 #1
0
ファイル: task.py プロジェクト: muromec/enodev.ikari
def task_up(project, s):

    s('updating')
    ret = ops.do_up(project.name)
    if ret:
        return s(ret)

    project.rev = rev(project.name)
    s('ok', rev=project.rev)
コード例 #2
0
ファイル: task.py プロジェクト: muromec/enodev.ikari
def task_setup(project, s):
    s('install')

    ret = ops.do_setup(
            project=project.name,
            clone_url=project.repo_url,
            domain=project.domain,
            static=project.template=='static'
    )

    if ret:
        return s(ret)

    project.rev = rev(project.name)
    s('ok', rev=project.rev)

    copy_key(project.name, s._id)
コード例 #3
0
ファイル: server2.py プロジェクト: mnevado02/practices-2021
    def do_GET(self):
        """This method is called whenever the client invokes the GET method
        in the HTTP protocol request"""

        # Print the request line
        termcolor.cprint(self.requestline, 'green')
        termcolor.cprint(self.path, "blue")

        o = urlparse(self.path)
        path_name = o.path
        arguments = parse_qs(o.query)
        print("Resource requested:", path_name)
        print("Parameters:", arguments)

        context = {}
        if path_name == "/":
            context["n_sequences"] = len(LIST_SEQUENCES)
            context["list_genes"] = LIST_GENES
            context["list_operations"] = LIST_OPERATIONS
            contents = su.read_template_html_file("./html/index.html").render(
                context=context)
        elif path_name == "/test":
            contents = su.read_template_html_file("./html/test.html").render()
        elif path_name == "/ping":
            contents = su.read_template_html_file("./html/ping.html").render()
        elif path_name == "/get":
            number_sequence = arguments["sequence"][0]
            contents = su.get(LIST_SEQUENCES, number_sequence)
        elif path_name == "/gene":
            gene = arguments["gene"][0]
            contents = su.gene(gene)
        elif path_name == "/operation":
            try:
                sequence = arguments["sequence"][0]
            except KeyError:
                sequence = ""
            operation = arguments["calculation"][0]
            if operation == "Info":
                contents = su.calc(sequence)
            elif operation == "Rev":
                contents = su.rev(sequence)
            elif operation == "Comp":
                contents = su.comp(sequence)
        else:
            contents = su.read_template_html_file("html/error.html").render()

        # Message to send back to the client

        # Generating the response message
        self.send_response(200)  # -- Status line: OK!

        # Define the content-type header:
        self.send_header('Content-Type', 'text/html')
        self.send_header('Content-Length', len(contents.encode()))

        # The header is finished
        self.end_headers()

        # Send the response message
        self.wfile.write(contents.encode())

        return
コード例 #4
0
def model2igraph(modelID,
                 resList,
                 C,
                 Idef1,
                 Iopt1,
                 P,
                 model="",
                 addGRF=True,
                 plotIt=False,
                 verbose=False):
    #from igraph import *
    Idef = deepcopy(Idef1)
    Iopt = deepcopy(Iopt1)
    ngenes = len(C)
    resList = resList[modelID]
    Is = resList[0][1]
    I = Idef
    nIdef = len(Idef)
    Iopt = rev(Iopt)
    for i in range(len(Iopt)):
        if (int(Is[i]) == 1):
            I.append(Iopt[i])
    edges = [[C.index(y) for y in x[:2]] for x in I]
    verboseIt("Edges: " + str([[C[i] for i in e] for e in edges]), verbose)
    elabels = [x[2] for x in I]
    verboseIt("Edge signs: " + str(elabels), verbose)
    color = ["white"] * ngenes
    for i in range(len(P)):
        condKO = "-" in P[i]
        condFE = "+" in P[i]
        if (condKO and condFE):
            color[i] = "yellow"
        elif (condKO):
            color[i] = "red"
        elif (condFE):
            color[i] = "green"
    verboseIt(
        "Node colors: " +
        str([C[i] + " is " + color[i] for i in range(ngenes)]), verbose)
    grf = [str(x[1]) for x in resList[1:(ngenes + 1)]]
    verboseIt(
        "Node GRFs: " +
        str([C[i] + " uses rule #" + grf[i] for i in range(ngenes)]), verbose)
    vertex_attrs = {
        "label": [
            C[i] + (" (" + grf[i] + ")" if (addGRF) else "")
            for i in range(ngenes)
        ],
        "size": [60 + 20 * (len(c) / 2 - 1) for c in C] * ngenes,
        "color":
        color
    }
    edge_attrs = {
        "label": elabels,
        "color": [ifthenelse(el == "-", "red", "green") for el in elabels],
        "lty": [0] * nIdef + [4] * (len(I) - nIdef)
    }
    g = Graph(n=ngenes,
              edges=edges,
              directed=True,
              vertex_attrs=vertex_attrs,
              edge_attrs=edge_attrs)
    ## Get a GraphViz version         ##
    filename = model + "_model" + str(modelID + 1)
    write_dot_file(g, filename, addGRF)
    ## Delete 0-degree vertices       ##
    g.vs.select(_degree=0).delete()
    if (plotIt):
        plot(g,
             layout=g.layout("kk"),
             bbox=((g.vcount() + 1) * 100, (g.vcount() + 1) * 100),
             margin=100)
    else:
        out = plot(g,
                   layout=g.layout("kk"),
                   bbox=((g.vcount() + 1) * 100, (g.vcount() + 1) * 100),
                   margin=100)
        out.save("grn_model" + str(modelID) + ".png")
    return (g)
コード例 #5
0
def launch_model(modelID,
                 C,
                 CRM,
                 resList,
                 Idef,
                 Iopt,
                 R,
                 q0,
                 nstep,
                 typeT,
                 KO,
                 FE,
                 P,
                 solmax=10,
                 steadyStates=False,
                 verbose=False):
    resList = resList[modelID]
    ## Computing the whole set of interactions I for the given model ##
    Is = resList[0][1]
    I = Idef
    Iopt = rev(Iopt)
    for i in range(len(Iopt)):
        if (int(Is[i])):
            I.append(Iopt[i])
    ## Building the constraints for the initial state                ##
    exp_name = "Experiment"
    if (str(type(q0)) == "<type 'str'>"):
        E = [[exp_name, [[0, C[i], int(q0[i])] for i in range(len(C))]]]
    else:
        E = [[exp_name, [[0, x[1], int(x[2])] for x in q0]]]
    Fixpoint = ifthenelse(steadyStates, [[nstep, exp_name]], [])
    grfsres = [str(x[0]) for x in resList]
    R = [[resList[grfsres.index("grf_" + c)][1]] for c in C]
    KO = [[exp_name, x[1]] for x in KO]
    FE = [[exp_name, x[1]] for x in FE]
    ## Get solmax trajectories from the given initial state          ##
    res = grn_solver(C,
                     CRM,
                     nstep,
                     I, [],
                     R,
                     E,
                     typeT,
                     solmax,
                     KO,
                     FE,
                     "paths",
                     "",
                     P,
                     Fixpoint,
                     verbose=verbose,
                     printSolutions=verbose,
                     printmain=verbose)
    try:
        [resList, _, _] = res
    except:
        verboseIt("No model has been returned", verbose=True)
        return (res)
    trajectories = []
    for k in range(len(resList)):
        res = resList[k]
        statesnames = [getState(i, "Experiment") for i in range(nstep + 1)]
        resnames = [str(x[0]) for x in res]
        statesIDX = [resnames.index(sn) for sn in statesnames]
        trajectory = [[resnames[i], rev(res[i][1])] for i in statesIDX]
        trajectories.append(["Trajectory #" + str(k + 1), trajectory])
    return (trajectories)
コード例 #6
0
    formatted_message = utils.format_command(msg)
    formatted_message = formatted_message.split(" ")
    if len(formatted_message) == 1:
        command = formatted_message[0]
    else:
        command = formatted_message[0]
        argument = formatted_message[1]
    if command == "PING":
        utils.ping()
        # -- Send a response message to the client
        response = "OK!"
        # -- The message has to be encoded into bytes
        cs.send(str(response).encode())
    elif command == "GET":
        utils.get(cs, list_sequences, argument)
    elif command == "INFO":
        utils.calc(cs)
    elif command == "COMP":
        utils.comp(cs, list_sequences, argument)
    elif command == "REV":
        utils.rev(cs, list_sequences, argument)
    elif command == "GENE":
        utils.gene(cs, argument)

    else:
        response = "Not available command"
        cs.send(str(response).encode())

    # -- Close the data socket
    cs.close()