def test_default_weight(self): self.assertEqual(mapmaker.default_weight(Atom.C), 1) self.assertEqual(mapmaker.default_weight(Atom.N), 0.4) self.assertEqual(mapmaker.default_weight(Atom.O), 0.4) self.assertEqual(mapmaker.default_weight(Atom.P), 0.4) self.assertEqual(mapmaker.default_weight(Atom.S), 1) self.assertEqual(mapmaker.default_weight(Radical('R')), 40.0)
def test_weighted_formula(self): weighted = mapmaker._weighted_formula( Formula.parse('C1H2N3S4R'), mapmaker.default_weight) self.assertEqual(set(weighted), { (Atom.C, 1, 1), # H is discarded (Atom.N, 3, 0.4), (Atom.S, 4, 1), (Radical('R'), 1, 40.0) })
def test_formula_parse_with_numbered_radical(self): f = Formula.parse('C2H4NO2(R1)') self.assertEqual( f, Formula({ Atom.C: 2, Atom.H: 4, Atom.N: 1, Atom.O: 2, Radical('R1'): 1 }))
def test_formula_parse_with_radical(self): f = Formula.parse('C2H4NO2R') self.assertEqual( f, Formula({ Atom('C'): 2, Atom('H'): 4, Atom('N'): 1, Atom('O'): 2, Radical('R'): 1 }))
def test_default_weight(self): self.assertEqual(findprimarypairs.element_weight(Atom.C), 1) self.assertEqual(findprimarypairs.element_weight(Atom.H), 0) self.assertEqual(findprimarypairs.element_weight(Atom.N), 0.82) self.assertEqual(findprimarypairs.element_weight(Radical('R')), 0.82)