Esempio n. 1
0
from frowns import Smiles, Smarts
for smiles in ['OC1C=CC(=O)C=C1', 'c1ccccc1']:
    mol = Smiles.smilin(smiles)
    print mol.cansmiles()

    print "with square brackets"    
    pattern = Smarts.compile('OC(C)[A]')
    match = pattern.match(mol)
    if match:
        for path in match:
            print path.atoms

    print
    print "without square brackets" 
    pattern2 = Smarts.compile('O=C(C)A')
    match2 = pattern2.match(mol)
    if match2:
        for path2 in match2:
            print path2.atoms

m = Smiles.smilin("c1ccccc1")
p = Smarts.compile("c1ccccc1")
assert p.match(m)


Esempio n. 2
0
            break

        for atom in to_remove:
            m.remove_atom(atom)

    return m


m = Smiles.smilin("c1ccccc1CCNc1cccc1CCC")

print m.cansmiles()
removeTerminalAtoms(m)
smarts = m.arbsmarts()
print smarts

pat = Smarts.compile(smarts)
assert pat.match(m)

smiles = []

file = open("F:\\Chemical Libraries\\Libraries to Purchase\\Nat_425.sdf")

reader = MDL.mdlin(file)
mol = reader.next()

print "reading natural products"
i = 0
while mol:
    fp = Fingerprint.generateFingerprint(mol)
    smile = mol.cansmiles()
    mol = removeTerminalAtoms(mol)
Esempio n. 3
0
# TIC library selection criteria
from frowns import utils, Smarts
# we want to remove steroids
steriod = Smarts.compile("C1CCC2C(C1)CCC3C2CC=C4CCCCC34")

# collect the molecules that we should keep
keep = file("MoleculesToKeep.sdf")
for molecule, error, record in MDLSDIN(file("PotentialMolecules.sf")):    
    if frowns.utils.saturationScore(molecule) < 0.5 and \
       frowns.utils.getStereoCenters(molecule) > 0 and \
       not steroid.match(molecule):
        # keep this molecule
        keep.write(record)
        
       
Esempio n. 4
0
from frowns import Smarts, Smiles

mol = Smiles.smilin('O=[N+]([O-])c1ccc(NC(C(C)(C)O)=O)cc1')
pattern = Smarts.compile('[cH0]-[!C;!N]')
match = pattern.match(mol)
if match:
    for path in match:
        a1, a2 = path.atoms
        b1 = path.bonds[0]
        print a1, a1.index, a1.aromatic, b1.aromatic, b1.bondtype, b1.bondorder, a2, a2.index, a2.aromatic


Esempio n. 5
0
import time
from frowns import Smiles
from frowns import Smarts
mol = Smiles.smilin("CCCCC(C)CCCC(C)CCCCCC(C)C(C)CCCCCC(C)CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCN")
pat = Smarts.compile("C*")
print len(pat.match(mol))

pat2 = Smarts.compile("[#6]")
t1 = time.time()
print len(pat2.match(mol))
t2 = time.time()
print t2-t1
t1 = time.time()
print len(pat2.match(mol))
t2 = time.time()
print t2-t1

print mol.vfgraph
from frowns import Smiles
from frowns import Smarts
from frowns.perception import sssr
from frowns.perception import RingDetection

## '*' is ok
mol=Smiles.smilin("SCCCCSCCCC",transforms=[RingDetection.sssr])
#pattern=Smarts.compile("S*CC")

##!! '~' has problem
pattern=Smarts.compile("S~C~C")

##!! pattern can't match itself
mol=Smiles.smilin("C[CH](C1=CC=CC=C1)[C](C)(C#N)C2=CC=CC=C2")
pattern = Smarts.compile(mol.arbsmarts())
print mol.arbsmarts()
pattern=Smarts.compile("CC(C1=CC=CC=C1)C(C)(C#N)C2=CC=CC=C2")

match=pattern.match(mol)
assert match
index=1
for path in match:
    print "match",index
    print "\tatoms",path.atoms
    print "\tbond",path.bonds
    index=index+1
Esempio n. 7
0
from frowns import Smiles
from frowns import Smarts

mol = Smiles.smilin("CCN")
pattern = Smarts.compile("CCN")

# simple match
match = pattern.match(mol)
assert match
index = 1
for path in match:
    print "match", index
    print "\tatoms", path.atoms
    print "\tbond", path.bonds
    index = index + 1

print "*" * 33
# more complicated match
pattern = Smarts.compile("C*")
match = pattern.match(mol)
assert match
index = 1
for path in match:
    print "match", index
    print "\tatoms", path.atoms
    print "\tbond", path.bonds
    index = index + 1

print "*" * 33
pattern = Smarts.compile("[!N]-[!C]")
match = pattern.match(mol)
Esempio n. 8
0
import time
from frowns import Smiles
from frowns import Smarts
mol = Smiles.smilin(
    "CCCCC(C)CCCC(C)CCCCCC(C)C(C)CCCCCC(C)CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCN")
pat = Smarts.compile("C*")
print len(pat.match(mol))

pat2 = Smarts.compile("[#6]")
t1 = time.time()
print len(pat2.match(mol))
t2 = time.time()
print t2 - t1
t1 = time.time()
print len(pat2.match(mol))
t2 = time.time()
print t2 - t1

print mol.vfgraph
Esempio n. 9
0
from frowns import Smiles, Smarts
for smiles in ['OC1C=CC(=O)C=C1', 'c1ccccc1']:
    mol = Smiles.smilin(smiles)
    print mol.cansmiles()

    print "with square brackets"
    pattern = Smarts.compile('OC(C)[A]')
    match = pattern.match(mol)
    if match:
        for path in match:
            print path.atoms

    print
    print "without square brackets"
    pattern2 = Smarts.compile('O=C(C)A')
    match2 = pattern2.match(mol)
    if match2:
        for path2 in match2:
            print path2.atoms

m = Smiles.smilin("c1ccccc1")
p = Smarts.compile("c1ccccc1")
assert p.match(m)
Esempio n. 10
0
from frowns import Smiles
from frowns import Smarts

mol = Smiles.smilin("CCN")
pattern = Smarts.compile("CCN")

# simple match
match = pattern.match(mol)
assert match
index = 1
for path in match:
    print "match", index
    print "\tatoms", path.atoms
    print "\tbond", path.bonds
    index = index + 1

print "*"*33
# more complicated match
pattern = Smarts.compile("C*")
match = pattern.match(mol)
assert match
index = 1
for path in match:
    print "match", index
    print "\tatoms", path.atoms
    print "\tbond", path.bonds
    index = index + 1

print "*"*33
pattern = Smarts.compile("[!N]-[!C]")
match = pattern.match(mol)
Esempio n. 11
0
        if not to_remove:
            break

        for atom in to_remove:
            m.remove_atom(atom)

    return m
            
m = Smiles.smilin("c1ccccc1CCNc1cccc1CCC")

print m.cansmiles()
removeTerminalAtoms(m)
smarts = m.arbsmarts()
print smarts

pat = Smarts.compile(smarts)
assert pat.match(m)

smiles = []

file = open("F:\\Chemical Libraries\\Libraries to Purchase\\Nat_425.sdf")

reader = MDL.mdlin(file)
mol = reader.next()

print "reading natural products"
i = 0
while mol:
    fp = Fingerprint.generateFingerprint(mol)
    smile = mol.cansmiles()
    mol = removeTerminalAtoms(mol)
Esempio n. 12
0
# Just some simple postive testing for smarts
# negative testing is a little harder to come by

from frowns import Smiles
from frowns import Smarts

mol = Smiles.smilin("C1CCCCC1CCN(=O)OCCN=C")

# search for ring atoms
matcher = Smarts.compile("[R1]")
print matcher.dump()
pathset = matcher.match(mol)
assert pathset
print pathset.atoms
print pathset.bonds

# search for CCN=O or CCN=C
matcher = Smarts.compile("CCN=[O,C]")
print matcher.dump()
pathset = matcher.match(mol)
assert pathset
for path in pathset:
    print path.atoms, path.bonds


# search for a wildcard
matcher = Smarts.compile("*=O")
print matcher.dump()
pathset = matcher.match(mol)
assert pathset
for path in pathset:
Esempio n. 13
0
from frowns import Smarts, Smiles

mol = Smiles.smilin("O=[N+]([O-])c1ccc(NC(C(C)(C)O)=O)cc1")
pattern = Smarts.compile("[cH0]-[!C;!N]")
match = pattern.match(mol)
if match:
    for path in match:
        a1, a2 = path.atoms
        b1 = path.bonds[0]
        print a1, a1.index, a1.aromatic, b1.aromatic, b1.bondtype, b1.bondorder, a2, a2.index, a2.aromatic
Esempio n. 14
0
from frowns import Smiles
from frowns import Smarts
from frowns.perception import sssr
from frowns.perception import RingDetection

## '*' is ok
mol = Smiles.smilin("SCCCCSCCCC", transforms=[RingDetection.sssr])
#pattern=Smarts.compile("S*CC")

##!! '~' has problem
pattern = Smarts.compile("S~C~C")

##!! pattern can't match itself
mol = Smiles.smilin("C[CH](C1=CC=CC=C1)[C](C)(C#N)C2=CC=CC=C2")
pattern = Smarts.compile(mol.arbsmarts())
print mol.arbsmarts()
pattern = Smarts.compile("CC(C1=CC=CC=C1)C(C)(C#N)C2=CC=CC=C2")

match = pattern.match(mol)
assert match
index = 1
for path in match:
    print "match", index
    print "\tatoms", path.atoms
    print "\tbond", path.bonds
    index = index + 1