Beispiel #1
0
    def testWhetherAllElementsAreSupported(self):
        """Check whether a new element has been correctly added"""
        N = 0
        while ob.GetSymbol(N+1):
            N += 1
            # Is the symbol parsed?
            symbol = ob.GetSymbol(N)
            self.assertEqual(N, ob.GetAtomicNum(symbol))
            self.assertEqual(N, ob.GetAtomicNum(symbol.lower())) # test lowercase version
            # Has an exact mass been set?
            self.assertNotEqual(0.0, ob.GetExactMass(N))
            # Has the symbol been added to the SMILES parser?
            numatoms = pybel.readstring("smi", "[%s]" % symbol).OBMol.NumAtoms()
            self.assertEqual(numatoms, 1)
            # Check whether the element is available as a constant
            self.assertEqual(N, getattr(ob, ob.GetName(N)))

        self.assertTrue(N > 100)
Beispiel #2
0
def get_mass(types):

    m = []
    if OB_version == 3:
        for value in types:
            a = ob.GetAtomicNum(value)
            print("debug readFiles.py: get_mass - a -", a)
            c = ob.GetMass(a)
            m.append(c)
    elif OB_version == 2:
        etab = ob.OBElementTable()
        for value in types:
            a = etab.GetAtomicNum(value)
            c = etab.GetMass(a)
            m.append(c)
    else:
        raise Exception("Unknown openbabel version")

    return m
Beispiel #3
0
 def testHydrogenIsotopes(self):
     """Are D and T supported by GetAtomicNum?"""
     for symbol in "DT":
         self.assertEqual(1, ob.GetAtomicNum(symbol))