Пример #1
0
 def test_mcsdr2(self):
     # Disconnected
     mol1 = smiles_to_compound("C1CCCC1CCCC(=O)O")
     mol2 = reader.mol_from_text(MOL["CaAcO2"])
     arr1 = mcsdr.DescriptorArray(mol1)
     arr2 = mcsdr.DescriptorArray(mol2)
     self.assertEqual(mcsdr.from_array(arr1, arr2).edge_count(), 3)
     # No line graph
     mol1 = smiles_to_compound("CO")
     mol2 = smiles_to_compound("CC")
     arr1 = mcsdr.DescriptorArray(mol1)
     arr2 = mcsdr.DescriptorArray(mol2)
     self.assertEqual(mcsdr.from_array(arr1, arr2).edge_count(), 0)
     # TODO: minimum MCS edge size is 2
     mol1 = smiles_to_compound("CCO")
     mol2 = smiles_to_compound("CCC")
     arr1 = mcsdr.DescriptorArray(mol1)
     arr2 = mcsdr.DescriptorArray(mol2)
     self.assertEqual(mcsdr.from_array(arr1, arr2).edge_count(), 0)
     # This works well
     mol1 = smiles_to_compound("CCCO")
     mol2 = smiles_to_compound("CCCC")
     arr1 = mcsdr.DescriptorArray(mol1)
     arr2 = mcsdr.DescriptorArray(mol2)
     self.assertEqual(mcsdr.from_array(arr1, arr2).edge_count(), 2)
     # TODO: pitfall in line graph
     mol1 = smiles_to_compound("CO(C)(C)C")
     mol2 = smiles_to_compound("OC(O)(O)O")
     arr1 = mcsdr.DescriptorArray(mol1)
     arr2 = mcsdr.DescriptorArray(mol2)
Пример #2
0
 def test_mcsdr1(self):
     # TODO: pi mismatch is not acceptable
     mol1 = reader.mol_from_text(MOL["Phe"])
     mol2 = reader.mol_from_text(MOL["Arg"])
     arr1 = mcsdr.DescriptorArray(mol1)
     arr2 = mcsdr.DescriptorArray(mol2)
     self.assertEqual(mcsdr.from_array(arr1, arr2).edge_count(), 5)
     # Delta-y exchange will not occur due to distance descriptor
     mol1 = smiles_to_compound("C1OC1CCC(=O)O")
     mol2 = smiles_to_compound("CC(O)CCC(=O)O")
     arr1 = mcsdr.DescriptorArray(mol1)
     arr2 = mcsdr.DescriptorArray(mol2)
     self.assertEqual(mcsdr.from_array(arr1, arr2).edge_count(), 7)
Пример #3
0
 def test_timeout(self):
     mol = reader.mol_from_text(MOL["Buckminsterfullerene"])
     tout = mcsdr.DescriptorArray(mol, timeout=0.1)
     self.assertFalse(tout.valid)
     arr = mcsdr.DescriptorArray(mol, diameter=5, timeout=0.1)
     sim = mcsdr.from_array(arr, arr, timeout=0.1)
     self.assertGreater(sim.local_sim(), 0)
Пример #4
0
g1 = nx.read_gexf('temp_1.gexf')
g2 = nx.read_gexf('temp_2.gexf')

c1 = Compound()
c2 = Compound()

for node in g1.nodes():
    c1.add_atom(node, Atom(g1.node[node]['type']))
for edge in g1.edges():
    b = Bond()
    b.order = int(g1[edge[0]][edge[1]]['valence'])
    c1.add_bond(edge[0], edge[1], b)
for node in g2.nodes():
    c2.add_atom(node, Atom(g2.node[node]['type']))
for edge in g2.edges():
    b = Bond()
    b.order = int(g2[edge[0]][edge[1]]['valence'])
    c2.add_bond(edge[0], edge[1], b)

descriptor.assign_valence(c1)
descriptor.assign_valence(c2)

a1 = comparison_array(c1, ignore_hydrogen=False)
a2 = comparison_array(c2, ignore_hydrogen=False)

g = from_array(a1, a2)

f = open('mcs_result.txt', 'w')
f.write(str(g.edge_count()))
f.close()