Exemplo n.º 1
0
 def testGetMoietys(self):
   m_ss = []
   for stgs in MOIETY_STOICHIOMETRY_STGS.values():
     m_ss.extend([MoietyStoichiometry.make(s) for s in stgs])
   moietys = MoietyStoichiometry.getMoietys(m_ss)
   self.assertEqual(len(MOIETY_STOICHIOMETRY_STGS.keys()),
       len(moietys))
Exemplo n.º 2
0
 def testMakeFromDct(self):
     if IGNORE_TEST:
         return
     config.setConfiguration(TEST_CFG_FILE)
     config_dct = config.getConfiguration()
     dct = config_dct[cn.CFG_MOIETY_STRUCTURE]
     mss1 = MoietyStoichiometry.makeFromDct(dct["ATP"])
     mss2 = [MoietyStoichiometry("A", 1), MoietyStoichiometry("P", 3)]
     self.assertTrue(all([m1.isEqual(m2) for m1, m2 in zip(mss1, mss2)]))
Exemplo n.º 3
0
 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]))
Exemplo n.º 4
0
 def testMake(self):
     if IGNORE_TEST:
         return
     for expected, strings in MOIETY_STOICHIOMETRY_STGS.items():
         for stg in strings:
             result = MoietyStoichiometry.make(stg)
             self.assertEqual(result.moiety.name, expected[0])
             self.assertEqual(result.stoichiometry, expected[1])
Exemplo n.º 5
0
 def testCountMoietys(self):
     if IGNORE_TEST:
         return
     moiety_stoich = MoietyStoichiometry(Molecule(MOIETY_NAME1), NUM1)
     mole_stoich = MoleculeStoichiometry(Molecule(str(moiety_stoich)), NUM2)
     df = mole_stoich.countMoietys()
     self.assertEqual(df.columns.tolist(), [cn.VALUE])
     expected = NUM1 * NUM2
     trues = [expected == n for n in df[cn.VALUE]]
Exemplo n.º 6
0
 def getMoietyStoichiometrys(self):
   """
   :return list-MoietyStoichiometry:
   """
   new_name = self._reformat()
   stgs = new_name.split(cn.MOIETY_DOUBLE_SEPARATOR)
   result = [MoietyStoichiometry.make(ms) for ms in stgs]
   result.sort()
   return result
Exemplo n.º 7
0
 def moiety_stoichiometrys(self):
     done = False
     if self._moiety_stoichiometrys is None:
         config_dct = config.getConfiguration()
         if cn.CFG_MOIETY_STRUCTURE in config_dct:
             dct = config_dct[cn.CFG_MOIETY_STRUCTURE]
             if self.name in dct.keys():
                 self._moiety_stoichiometrys =  \
                     MoietyStoichiometry.makeFromDct(dct[self.name])
                 done = True
     else:
         done = True
     if not done:
         new_name = self._reformat()
         stgs = new_name.split(cn.MOIETY_DOUBLE_SEPARATOR)
         result = [MoietyStoichiometry.make(ms) for ms in stgs]
         result.sort()
         self._moiety_stoichiometrys = result
     return self._moiety_stoichiometrys
Exemplo n.º 8
0
 def testExtractMoietyStoichiometrys(self):
     if IGNORE_TEST:
         return
     for expected, strings in MOLECULE_STOICHIOMETRY_STGS.items():
         moietys = list(set([e[0] for e in expected]))
         moietys.sort()
         m_ss = [MoietyStoichiometry(m, 1) for m in moietys]
         for stg in strings:
             result = Molecule.getMoietyStoichiometrys(stg)
             trues = [x.isEqual(y) for x, y in zip(result, m_ss)]
             self.assertTrue(all(trues))
Exemplo n.º 9
0
 def testExtractMoietyStoichiometrys(self):
     if IGNORE_TEST:
         return
     moiety_stoich = MoietyStoichiometry(Molecule(MOIETY_NAME1), NUM1)
     mole_stoich = MoleculeStoichiometry(Molecule(str(moiety_stoich)), NUM2)
Exemplo n.º 10
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)