def testGetMoietys(self):
     if IGNORE_TEST:
         return
     m_s1 = MoietyStoichiometry(Moiety(MOIETY_NAME1), NUM1)
     m_s2 = MoietyStoichiometry(MOIETY_NAME2, NUM2)
     m_s3 = MoietyStoichiometry(MOIETY_NAME1, NUM2)
     molecule = Molecule(str(m_s1))
     molecule = molecule.append(Moiety(str(m_s2)))
     moietys = molecule.getMoietys()
     expected = [Moiety(MOIETY_NAME1), Moiety(MOIETY_NAME2)]
     for moiety in moietys:
         self.assertTrue(any([moiety.isEqual(e) for e in expected]))
 def testAppend(self):
     if IGNORE_TEST:
         return
     moiety2 = Moiety(MOIETY_NAME2)
     molecule = Molecule(MOIETY_NAME1)
     new_molecule = molecule.append(moiety2)
     self.assertEqual(new_molecule.name, Molecule(MOLECULE_NAME).name)
Exemple #3
0
 def getMoietys(self):
     """
 Extracts the unique moieties in the molecule.
 :return list-Moiety: Unique Moiety in molecule
 """
     names = list(
         set([m_s.moiety.name for m_s in self.moiety_stoichiometrys]))
     names.sort()
     return [Moiety(n) for n in names]
Exemple #4
0
 def _getMoietys(self):
     """
 Sees if there is a valid moiety structure.
 If not, the molecule is a single moiety.
 """
     moietys = []
     for molecule in self.molecules:
         try:
             new_moietys = ([
                 m_s.moiety for m_s in molecule.moiety_stoichiometrys
             ])
         except ValueError:
             new_moietys = [Moiety(molecule.name)]
         moietys.extend(new_moietys)
     return util.uniqueify(moietys)
 def testHasMoiety(self):
     if IGNORE_TEST:
         return
     molecule = Molecule(MOLECULE_NAME)
     self.assertTrue(molecule.hasMoiety(Moiety(MOIETY_NAME1)))
     self.assertTrue(molecule.hasMoiety(Moiety(MOIETY_NAME2)))
import os
import tesbml
import unittest

IGNORE_TEST = False
NUM1 = 2
NUM2 = 3
MOIETY_NAME1 = "first"
MOIETY_NAME2 = "second"
MOIETY_NAME3 = "third"
NAME = "name"
NO_NAME = 'not_a_name'
MOLECULE_NAME = "%s%s%s" % (MOIETY_NAME1, cn.MOIETY_DOUBLE_SEPARATOR,
                            MOIETY_NAME2)
MOLECULE_STOICHIOMETRY_STGS = {
    ((Moiety("A"), 1), (Moiety("P"), 1)):
    [Molecule("A_P"), Molecule("A_1__P"),
     Molecule("A__P")],
    ((Moiety("AA"), 1), (Moiety("PP"), 1)): [
        Molecule("AA_PP"),
        Molecule("AA_1__PP"),
        Molecule("AA__PP"),
    ],
}
NAMES = [MOIETY_NAME1, MOIETY_NAME2, MOIETY_NAME3]
iterator = itertools.product([0, 1], [0, 1], [0, 1])
MOLECULE_NAME_SET = []  # A set of names from moiety combinations
for item in iterator:
    name = ""
    for idx, ele in enumerate(item):
        if ele == 1:
Exemple #7
0
 def testStoichiometry(self):
     moiety_stoichiometry = MoietyStoichiometry(Moiety(MOIETY_NAME1), NUM1)
     self.assertEqual(moiety_stoichiometry.moiety.name, MOIETY_NAME1)
     self.assertEqual(moiety_stoichiometry.stoichiometry, NUM1)
Exemple #8
0
 def testConstructor(self):
     if IGNORE_TEST:
         return
     self.assertEqual(Moiety(MOIETY_NAME1).name, MOIETY_NAME1)