AChemKit.reactionnet — AChemKit v0.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- AChemKit v0.1 documentation »
- AChemKit »

# AChemKit.reactionnet

Core for all ReactionNetwork classes

Of particular note are the alternative constructors for `ReactionNetwork`, `ReactionNetwork.from_file()`, `ReactionNetwork.from_filename()` and `ReactionNetwork.from_string()`.

Classes

`ReactionNetwork`(rates) | A dictionary of reactions where each key is a reaction composed of (tuple(sorted(reactants)), sorted(tuple(products))) and each value is the rate.
`SimpleDot`([name, digraph, strict]) | Repsents a graphviz .dot file (also known as .gv).

class `AChemKit.reactionnet.` `ReactionNetwork`(rates)

  Bases: `object`

  A dictionary of reactions where each key is a reaction composed of (tuple(sorted(reactants)), sorted(tuple(products))) and each value is the rate.

  ReactionNetwork objects are immutable and hashable.

  ReactionNetwork objects support __eq__ and __ne__, but none of the other rich comparison operators (__lt__, __le__, __gt__, __ge__).

  Different subclassess should be implemented to generate reaction networks on demand (artificial chemistries, etc) and provide additional functionallity, such as visualization or metrics.

  Can be cast to string to get a .chem representation.

  `dot`

    Property wrapper around `to_dot()` to provide attribute-like access.

  classmethod `from_file`(infile)

    Alternative constructor that accepts a `file` object (or equivalent).

    Source must be formatted as a .chem file, see .chem Format.

  classmethod `from_filename`(infilename)

    Wrapper around `from_file()` that opens the provided filename as a file to read.

  classmethod `from_string`(instr)

    Wrapper around `from_file()` that uses `StringIO`.

  `reactions`

    Sorted tuple of all reactions in the network

  `seen`

    Sorted tuple of all molecular species in the network

  `to_dot`(names=None, rates=None, shown=(), hidden=())

    Return a .dot format string constructed using a `AChemKit.utils.simpledot.SimpleDot` view of this reaction network.

    Molecular species are shown as either full names, identifier numbers, or as blank circles. This is determined by the names parameter, which is a string indicating which to use:

    “full”
      This will use the full molecule name specified in the .chem file
    “id”
      This will use a shortened identifier of that molecules index in the `seen()` tuple.
    “blank”
      This will not name any molecules, but will put an empty circle instead.

    A sub-set of the reaction network can be drawn using the shown and hidden parameters.

    Reactions involving only molecular species on the hidden list are not shown. Molecular species on the hidden list are not shown unless they are involved in a reaction with molecular species not on the hidden list, in which case the molecular species on the hidden list is unlabeled and shown as a point.

    The shown list in the inverse of the hidden list. If it is used, any molecular species not on the shown list is treated as being on the hidden list. If a molecular species is on both shown and hidden lists, the hidden lists wins.

    Catalysts (defined as molecules that are required for but unchanged by a reaction) are indicated with a grey line.

    Reversible reactions (defined as a pair of reactions where reactants of one are the products of the other and visa versa) are combined and indicated with double arrows resembling a diamond shape.

### Navigation

- index
- modules |
- next |
- previous |
- AChemKit v0.1 documentation »
- AChemKit »