本文整理汇总了Python中rmgpy.data.base.Database.matchNodeToStructure方法的典型用法代码示例。如果您正苦于以下问题:Python Database.matchNodeToStructure方法的具体用法?Python Database.matchNodeToStructure怎么用?Python Database.matchNodeToStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rmgpy.data.base.Database
的用法示例。
在下文中一共展示了Database.matchNodeToStructure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestBaseDatabase
# 需要导入模块: from rmgpy.data.base import Database [as 别名]
# 或者: from rmgpy.data.base.Database import matchNodeToStructure [as 别名]
class TestBaseDatabase(unittest.TestCase):
"""
Contains unit tests for the base class of rmgpy.data.
"""
def setUp(self):
"""
A function run before each unit test in this class.
"""
# Set up a dummy database
self.database = Database()
def testMatchNodeToStructure(self):
"""
Test that the MatchNodeToStructure family works properly.
"""
entry1 = Entry(
item = Group().fromAdjacencyList(
"""
1 *3 C 1 {2,D} {3,S}
2 C 0 {1,D}
3 *5 Cd 0 {1,S} {4,D}
4 C 0 {3,D}
""")
)
entry2 = Entry(
item= Group().fromAdjacencyList(
"""
1 *3 C 1 {2,D} {3,S}
2 *5 C 0 {1,D}
3 Cd 0 {1,S} {4,D}
4 C 0 {3,D}
""")
)
entry3 = Entry(
item = Group().fromAdjacencyList(
"""
1 *3 C 1 {2,D} {3,S}
2 C 0 {1,D}
3 Cd 0 {1,S} {4,D}
4 C 0 {3,D}
""")
)
# The group should match to itself
self.assertTrue(self.database.matchNodeToStructure(entry1,entry1.item,atoms=entry1.item.getLabeledAtoms()))
# These groups should not match each other
self.assertFalse(self.database.matchNodeToStructure(entry1,entry2.item,atoms=entry2.item.getLabeledAtoms()))
# entry1 contains more labels than entry3, therefore cannot be matched by entry3
self.assertFalse(self.database.matchNodeToStructure(entry3,entry1.item,atoms=entry1.item.getLabeledAtoms()))
# entry3 contains fewer labels than entry1, therefore it can be matched
self.assertTrue(self.database.matchNodeToStructure(entry1,entry3.item,atoms=entry3.item.getLabeledAtoms()))
def testMatchNodeToNode(self):
"""
Test that nodes can match other nodes.
"""
entry1 = Entry(
item = Group().fromAdjacencyList(
"""
1 *1 R!H 1
""")
)
entry2 = Entry(
item= Group().fromAdjacencyList(
"""
1 *1 Cb 1
""")
)
self.assertTrue(self.database.matchNodeToNode(entry1,entry1))
self.assertFalse(self.database.matchNodeToNode(entry1,entry2))