Giter Club home page Giter Club logo

Comments (4)

arabidopsis avatar arabidopsis commented on August 17, 2024 2

Ok... I created a pull request. Let's see what happens :)

from driven.

arabidopsis avatar arabidopsis commented on August 17, 2024

Yes. sympy is using a 5 argument version of ast.Call which was
removed in Py3.5. see https://greentreesnakes.readthedocs.io/en/latest/nodes.html#Call

from driven.

arabidopsis avatar arabidopsis commented on August 17, 2024

Here's a monkey patch (might create a pull request if I have time)

from cobra.core.gene import parse_gpr
from sympy import Mul, Add, Symbol, Max, Min
from ast import And, Or, NodeTransformer

class Transform(NodeTransformer):

    def visit_Name(self, node):
        return Symbol(node.id)
    def visit_BoolOp(self, node):
        values = [self.visit(v) for v in node.values]
        if isinstance(node.op, And):
            return Mul(*values)
        if isinstance(node.op, Or):
            return Add(*values)
        return node

def parse_expr(s):
    a, genes = parse_gpr(s.strip())
    a = Transform().visit(a)
    return a.body

def _map_gene_to_rxn(self, reaction, gene_values, by):
    rule = reaction.gene_reaction_rule
    expression = parse_expr(rule)
    if by == "or2max_and2min":
        expression = expression.replace(Mul, Min).replace(Add, Max)
    elif by == "or2sum_and2min":
        expression = expression.replace(Mul, Min)
    return expression.subs(gene_values).evalf()

from driven.data_sets.expression_profile import ExpressionProfile
ExpressionProfile._map_gene_to_rxn = _map_gene_to_rxn

from driven.

jotech avatar jotech commented on August 17, 2024

thank you very much it helped indeed :)

from driven.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.