Exemplo n.º 1
0
 def format_class2ms(class2m_ids, m_id2count):
     format_m_ids = lambda m_ids: \
         ', '.join(('%s [%d]' % (format_m_name(model.getSpecies(m_id), model, False, False), m_id2count[m_id])
                    for m_id in sorted(m_ids, key=lambda m_id: (-m_id2count[m_id], m_id))))
     result = '\n\t'.join('%sS: %s' % (name.upper(), format_m_ids(m_ids)) for (name, m_ids) in class2m_ids.items())
     others = set(m_id2count.keys()) - reduce(lambda s1, s2: s1 | s2, class2m_ids.values(), set())
     if others:
         result += ('\n\tOTHER: ' if result else '\tOTHER: ') + format_m_ids(others)
     return result
    def format_r(r_id):
        r2st, p2st = S.st_matrix.get_inputs_outputs(r_id)
        formatter = lambda m_id, st: '%s %s' % ("" if st == 1 else ("%g" % st),
                                                format_m_name(model.getSpecies(m_id), model, show_id=False))
        rs, ps = sorted(formatter(it) for it in r2st.items()), sorted(formatter(it) for it in p2st.items())
        r = model.getReaction(r_id)
        reversible = r.getReversible() if r else True

        return " + ".join(rs) + (" ↔ " if reversible else " → ") + " + ".join(ps)