コード例 #1
0
 def read_text( self, text):
   # reaction support
   if ">" in text:
     if text.count(">") != 2:
       raise oasa_exceptions.oasa_smiles_error( "Only two '>' characters are supported in SMILES reactions. %d present" % text.count(">"))
     parts = text.split( ">")
     res = []
     for part in parts:
       res.append( self._read_string( part))
       if not self.last_status == self.STATUS_OK:
         res = []
         break
     if not res:
       self.result = []
       return []
     else:
       react = reaction.reaction()
       for p in res[0]:
         react.reactants.append( reaction.reaction_component( p))
       for p in res[2]:
         react.products.append( reaction.reaction_component( p))
       for p in res[1]:
         react.reagents.append( reaction.reaction_component( p))
       self.result = [react]
       return self.result
   else:
     return self._read_string( text)
コード例 #2
0
ファイル: unittests.py プロジェクト: Robot-Will/OASA
 def test1(self):
   mol = smiles.text_to_mol( "CCCO")
   rc = reaction.reaction_component( mol, 2)
   self.assertEqual( rc.stoichiometry, 2)
   self.assertRaises( Exception, reaction.reaction_component, mol, "x")
   self.assertRaises( Exception, rc._set_stoichiometry, "x")
   self.assertRaises( Exception, reaction.reaction_component, 2, 2)
   self.assertRaises( Exception, rc._set_molecule, "x")    
コード例 #3
0
 def test1(self):
     mol = smiles.text_to_mol("CCCO")
     rc = reaction.reaction_component(mol, 2)
     self.assertEqual(rc.stoichiometry, 2)
     self.assertRaises(Exception, reaction.reaction_component, mol, "x")
     self.assertRaises(Exception, rc._set_stoichiometry, "x")
     self.assertRaises(Exception, reaction.reaction_component, 2, 2)
     self.assertRaises(Exception, rc._set_molecule, "x")