-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathcompartment.py
40 lines (32 loc) · 1.1 KB
/
compartment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from copy import deepcopy
from cobra.util.util import format_long_string
from cobra.core.object import Object
class Compartment(Object):
"""Compartment is a class for holding information regarding
a compartment in a cobra.Model object
Parameters
----------
id : string
An identifier for the compartment
name : string
A human readable name.
"""
def __init__(self, id=None, name=""):
Object.__init__(self, id, name)
def copy(self):
return deepcopy(self)
def _repr_html_(self):
return """
<table>
<tr>
<td><strong>Compartment identifier</strong></td><td>{id}</td>
</tr><tr>
<td><strong>Name</strong></td><td>{name}</td>
</tr><tr>
<td><strong>Memory address</strong></td>
<td>{address}</td>
</tr>
</table>""".format(id=self.id, name=format_long_string(self.name),
address='0x0%x' % id(self))