Elektrine lite

← Feed

@molecule@mstdn.science

Post #1978205

2026-04-13 22:26 UTC

@dalke here's another example where this affects the match count on even a relatively small molecule ``` mol = Chem.MolFromSmiles("FS(F)(F)(F)(F)N(S(F)(F)(F)(F)(F))S(F)(F)(F)(F)(F)") pat = Chem.MolFromSmarts("[$([d6](*)(*)(*)(*)(*)*)]") print(len(mol.GetSubstructMatches(pat))) ``` only 2 matches! (the N(SF5)3 molecule actually exists: https://doi.org/10.1016/j.molstruc.2016.05.089 )

Replies (2)

  • @dalke@toots.nu 2026-04-14 07:12

    @molecule Nice. 6! = 720 hence only 2 matches with a default max of 1,000. Looks like "d" is an RDKit extension for non-hydrogen degree. I didn't know about it. I've been toying with a new SMARTS extension: '#' ('-' | '=' | '#' | ':') = for n single (implicit and explicit), double, triple, or aromatic bonds Your pattern might then be written "[d6#-6]", since I don't think you need to match aromatic bonds. "Atom with at least one a double or triple bond" would be "[!#=0;!##0]".

    Open ##1978206

  • @dalke@toots.nu 2026-04-15 14:32

    @molecule With my modifications to the RDKit SMARTS matcher: >>> mol = Chem.MolFromSmiles("FS(F)(F)(F)(F)N(S(F)(F)(F)(F)(F))S(F)(F)(F)(F)(F)") >>> pat = Chem.MolFromSmarts("[$([d6](*)(*)(*)(*)(*)*)]") >>> print(len(mol.GetSubstructMatches(pat))) 2 >>> pat = Chem.MolFromSmarts("[d6#-6]") >>> print(len(mol.GetSubstructMatches(pat))) 3 >>>

    Open ##1978209