예제 #1
0
   def test_fromAugmentedInChI(self):
      aug_inchi = 'InChI=1S/CH4/h1H4'
      mol = parser.fromAugmentedInChI(Molecule(), aug_inchi)
      self.assertTrue(not mol.InChI == '')

      aug_inchi = 'InChI=1/CH4/h1H4'
      mol = parser.fromAugmentedInChI(Molecule(), aug_inchi)
      self.assertTrue(not mol.InChI == '')
예제 #2
0
   def test_OptionalMultLayer(self):
      """Test that multiplicity layer be optional in cases where the layer is not needed."""

      aug_inchi = 'InChI=1S/CH3/h1H3'
      mol = parser.fromAugmentedInChI(Molecule(), aug_inchi)
      self.assertTrue(mol.multiplicity == 2)

      aug_inchi = 'InChI=1S/CH3/h1H3/mult2'
      mol = parser.fromAugmentedInChI(Molecule(), aug_inchi)
      self.assertTrue(mol.multiplicity == 2)

      aug_inchi = 'InChI=1S/CH3/h1H3/mult2/u0'
      mol = parser.fromAugmentedInChI(Molecule(), aug_inchi)
      self.assertTrue(mol.multiplicity == 2)

      aug_inchi = 'InChI=1S/CH2/h1H2/mult3'
      mol = parser.fromAugmentedInChI(Molecule(), aug_inchi)
      self.assertTrue(mol.multiplicity == 3)

      aug_inchi = 'InChI=1S/CH2/h1H2/mult1'
      mol = parser.fromAugmentedInChI(Molecule(), aug_inchi)
      self.assertTrue(mol.multiplicity == 1)

      aug_inchi = 'InChI=1S/CH2/h1H2/mult3/u0'
      mol = parser.fromAugmentedInChI(Molecule(), aug_inchi)
      self.assertTrue(mol.multiplicity == 3)

      aug_inchi = 'InChI=1S/CH2/h1H2/mult1/u0'
      mol = parser.fromAugmentedInChI(Molecule(), aug_inchi)
      self.assertTrue(mol.multiplicity == 1)
예제 #3
0
    def compare(self, inchi, mult, u_indices = None):
        u_layer = ','.join([str(i) for i in u_indices]) if u_indices else None

        if u_layer:
            aug_inchi = 'InChI=1/' + inchi  + '/mult' + str(mult) + '/u' + u_layer
        else: 
            aug_inchi = 'InChI=1/' + inchi  + '/mult' + str(mult)

        mol = Molecule()
        mol = fromAugmentedInChI(mol, aug_inchi)
        self.assertEqual(mol.getNumberOfRadicalElectrons(), mult - 1)
        return mol