本文整理汇总了Python中rmgpy.molecule.group.GroupAtom.copy方法的典型用法代码示例。如果您正苦于以下问题:Python GroupAtom.copy方法的具体用法?Python GroupAtom.copy怎么用?Python GroupAtom.copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rmgpy.molecule.group.GroupAtom
的用法示例。
在下文中一共展示了GroupAtom.copy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testApplyActionLoseRadical
# 需要导入模块: from rmgpy.molecule.group import GroupAtom [as 别名]
# 或者: from rmgpy.molecule.group.GroupAtom import copy [as 别名]
def testApplyActionLoseRadical(self):
"""
Test the GroupAtom.applyAction() method for a LOSE_RADICAL action.
"""
action = ['LOSE_RADICAL', '*1', 1]
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1', lonePairs=[0])
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.decrementRadical))
for a in atomType.incrementRadical:
self.assertTrue(a in atom.atomType, "LOSE_RADICAL on {0} gave {1} not {2}".format(atomType, atom.atomType, atomType.decrementRadical))
self.assertEqual(atom0.radicalElectrons, [r + 1 for r in atom.radicalElectrons])
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
self.assertEqual(atom0.lonePairs, atom.lonePairs)
except ActionError:
self.assertEqual(len(atomType.decrementRadical), 0)
#test when radicals unspecified
group = Group().fromAdjacencyList("""
1 R ux
""") #ux causes a wildcare for radicals
atom1 = group.atoms[0]
atom1.applyAction(action)
self.assertListEqual(atom1.radicalElectrons, [0,1,2,3])
示例2: testApplyActionLosePair
# 需要导入模块: from rmgpy.molecule.group import GroupAtom [as 别名]
# 或者: from rmgpy.molecule.group.GroupAtom import copy [as 别名]
def testApplyActionLosePair(self):
"""
Test the GroupAtom.applyAction() method for a LOSE_PAIR action when lonePairs is either specified or not.
"""
action = ['LOSE_PAIR', '*1', 1]
# lonePairs specified:
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1', lonePairs=[1])
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.decrementLonePair))
for a in atomType.decrementLonePair:
self.assertTrue(a in atom.atomType,
"LOSE_PAIR on {0} gave {1} not {2}".format(atomType, atom.atomType,
atomType.decrementLonePair))
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
self.assertEqual(atom0.lonePairs, [r + 1 for r in atom.lonePairs])
except ActionError:
self.assertEqual(len(atomType.decrementLonePair), 0)
#lonePairs unspecified:
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.decrementLonePair))
for a in atomType.decrementLonePair:
self.assertTrue(a in atom.atomType,
"LOSE_PAIR on {0} gave {1} not {2}".format(atomType, atom.atomType,
atomType.decrementLonePair))
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
self.assertEqual([1,2,3,4], [r + 1 for r in atom.lonePairs])
except ActionError:
self.assertEqual(len(atomType.decrementLonePair), 0)
示例3: testApplyActionDecrementBond
# 需要导入模块: from rmgpy.molecule.group import GroupAtom [as 别名]
# 或者: from rmgpy.molecule.group.GroupAtom import copy [as 别名]
def testApplyActionDecrementBond(self):
"""
Test the GroupAtom.applyAction() method for a CHANGE_BOND action.
"""
action = ['CHANGE_BOND', '*1', -1, '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.decrementBond))
for a in atomType.decrementBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.decrementBond), 0)
示例4: testApplyActionLoseRadical
# 需要导入模块: from rmgpy.molecule.group import GroupAtom [as 别名]
# 或者: from rmgpy.molecule.group.GroupAtom import copy [as 别名]
def testApplyActionLoseRadical(self):
"""
Test the GroupAtom.applyAction() method for a LOSE_RADICAL action.
"""
action = ['LOSE_RADICAL', '*1', 1]
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.decrementRadical))
for a in atomType.incrementRadical:
self.assertTrue(a in atom.atomType, "LOSE_RADICAL on {0} gave {1} not {2}".format(atomType, atom.atomType, atomType.decrementRadical))
self.assertEqual(atom0.radicalElectrons, [r + 1 for r in atom.radicalElectrons])
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.decrementRadical), 0)
示例5: testApplyActionFormBond
# 需要导入模块: from rmgpy.molecule.group import GroupAtom [as 别名]
# 或者: from rmgpy.molecule.group.GroupAtom import copy [as 别名]
def testApplyActionFormBond(self):
"""
Test the GroupAtom.applyAction() method for a FORM_BOND action.
"""
action = ["FORM_BOND", "*1", "S", "*2"]
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label="*1")
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.formBond))
for a in atomType.formBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.formBond), 0)
示例6: testApplyActionBreakBond
# 需要导入模块: from rmgpy.molecule.group import GroupAtom [as 别名]
# 或者: from rmgpy.molecule.group.GroupAtom import copy [as 别名]
def testApplyActionBreakBond(self):
"""
Test the GroupAtom.applyAction() method for a BREAK_BOND action.
"""
action = ['BREAK_BOND', '*1', 1, '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1', lonePairs=[0])
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.breakBond))
for a in atomType.breakBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
self.assertEqual(atom0.label, atom.label)
self.assertEqual(atom0.lonePairs, atom.lonePairs)
except ActionError:
self.assertEqual(len(atomType.breakBond), 0)
示例7: TestGroupAtom
# 需要导入模块: from rmgpy.molecule.group import GroupAtom [as 别名]
# 或者: from rmgpy.molecule.group.GroupAtom import copy [as 别名]
class TestGroupAtom(unittest.TestCase):
"""
Contains unit tests of the GroupAtom class.
"""
def setUp(self):
"""
A method called before each unit test in this class.
"""
self.atom = GroupAtom(atomType=[atomTypes['Cd']], radicalElectrons=[1], charge=[0], label='*1')
def testApplyActionBreakBond(self):
"""
Test the GroupAtom.applyAction() method for a BREAK_BOND action.
"""
action = ['BREAK_BOND', '*1', 1, '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.breakBond))
for a in atomType.breakBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.breakBond), 0)
def testApplyActionFormBond(self):
"""
Test the GroupAtom.applyAction() method for a FORM_BOND action.
"""
action = ['FORM_BOND', '*1', 1, '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.formBond))
for a in atomType.formBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.formBond), 0)
def testApplyActionIncrementBond(self):
"""
Test the GroupAtom.applyAction() method for a CHANGE_BOND action.
"""
action = ['CHANGE_BOND', '*1', 1, '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.incrementBond))
for a in atomType.incrementBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.incrementBond), 0)
def testApplyActionDecrementBond(self):
"""
Test the GroupAtom.applyAction() method for a CHANGE_BOND action.
"""
action = ['CHANGE_BOND', '*1', -1, '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.decrementBond))
for a in atomType.decrementBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.decrementBond), 0)
def testApplyActionGainRadical(self):
"""
Test the GroupAtom.applyAction() method for a GAIN_RADICAL action.
"""
action = ['GAIN_RADICAL', '*1', 1]
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.incrementRadical))
for a in atomType.incrementRadical:
self.assertTrue(a in atom.atomType, "GAIN_RADICAL on {0} gave {1} not {2}".format(atomType, atom.atomType, atomType.incrementRadical))
#.........这里部分代码省略.........
示例8: TestGroupAtom
# 需要导入模块: from rmgpy.molecule.group import GroupAtom [as 别名]
# 或者: from rmgpy.molecule.group.GroupAtom import copy [as 别名]
class TestGroupAtom(unittest.TestCase):
"""
Contains unit tests of the GroupAtom class.
"""
def setUp(self):
"""
A method called before each unit test in this class.
"""
self.atom = GroupAtom(atomType=[atomTypes['Cd']], radicalElectrons=[1], charge=[0], label='*1')
def testApplyActionBreakBond(self):
"""
Test the GroupAtom.applyAction() method for a BREAK_BOND action.
"""
action = ['BREAK_BOND', '*1', 'S', '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.breakBond))
for a in atomType.breakBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.breakBond), 0)
def testApplyActionFormBond(self):
"""
Test the GroupAtom.applyAction() method for a FORM_BOND action.
"""
action = ['FORM_BOND', '*1', 'S', '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.formBond))
for a in atomType.formBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.formBond), 0)
def testApplyActionIncrementBond(self):
"""
Test the GroupAtom.applyAction() method for a CHANGE_BOND action.
"""
action = ['CHANGE_BOND', '*1', 1, '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.incrementBond))
for a in atomType.incrementBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.incrementBond), 0)
def testApplyActionDecrementBond(self):
"""
Test the GroupAtom.applyAction() method for a CHANGE_BOND action.
"""
action = ['CHANGE_BOND', '*1', -1, '*2']
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.decrementBond))
for a in atomType.decrementBond:
self.assertTrue(a in atom.atomType)
self.assertEqual(atom0.radicalElectrons, atom.radicalElectrons)
self.assertEqual(atom0.charge, atom.charge)
self.assertEqual(atom0.label, atom.label)
except ActionError:
self.assertEqual(len(atomType.decrementBond), 0)
def testApplyActionGainRadical(self):
"""
Test the GroupAtom.applyAction() method for a GAIN_RADICAL action.
"""
action = ['GAIN_RADICAL', '*1', 1]
for label, atomType in atomTypes.iteritems():
atom0 = GroupAtom(atomType=[atomType], radicalElectrons=[1], charge=[0], label='*1')
atom = atom0.copy()
try:
atom.applyAction(action)
self.assertEqual(len(atom.atomType), len(atomType.incrementRadical))
for a in atomType.incrementRadical:
self.assertTrue(a in atom.atomType, "GAIN_RADICAL on {0} gave {1} not {2}".format(atomType, atom.atomType, atomType.incrementRadical))
#.........这里部分代码省略.........