Beispiel #1
0
    def cansmiles(self, isomeric=0):
        if isomeric: draw = Traverse.drawIsomeric
        else: draw = Traverse.draw

        if self.dirty:
            # XXX FIX ME
            # Move equivalence_class setter outside?
            # recompute the equivalence classes
            for atom in self.atoms:
                atom.equiv_class = compute_equiv_class(atom)
            Disambiguate.FreedDisambiguate(self)
            self._canonical, self.canonical_list = Traverse.draw(self)
            self.dirty = 0

        if isomeric:
            return Traverse.drawIsomeric(self)[0]
        return self._canonical
Beispiel #2
0
    def cansmiles(self, isomeric=0):
        if isomeric: draw = Traverse.drawIsomeric
        else: draw = Traverse.draw
        
        if self.dirty:
            # XXX FIX ME
            # Move equivalence_class setter outside?
            # recompute the equivalence classes
            for atom in self.atoms:
                atom.equiv_class = compute_equiv_class(atom)
            Disambiguate.FreedDisambiguate(self)
            self._canonical, self.canonical_list = Traverse.draw(self)
            self.dirty = 0

        if isomeric:
            return Traverse.drawIsomeric(self)[0]
        return self._canonical
Beispiel #3
0
 def arbsmarts(self, isomeric=0):
     # XXX FIX ME
     # compute canonicalization smarts
     # without hydrogens and charges
     canonical, canonical_list = Traverse.drawSmarts(self)
     return canonical
Beispiel #4
0
 def arbsmarts(self, isomeric=0):
     # XXX FIX ME
     # compute canonicalization smarts
     # without hydrogens and charges
     canonical, canonical_list = Traverse.drawSmarts(self)
     return canonical
Beispiel #5
0
def test():
    from frowns import Smiles
    import RingDetection
    import sssr as sssr2
    import time
    from frowns.Canonicalization import Disambiguate, Traverse

    ##mol = Smiles.smilin("C12C3C4C1C5C4C3C25CCCCCC12C3C4C1C5C4C3C25")
    ##mol1 = Smiles.smilin("C1O[CH]1C2=CC=CC=C2",
    ##                    transforms = [])
    ##print mol1.cansmiles()
    smiles = "COC(=O)[CH]1C2CCC(CC2)[CH]1C(=O)OCC"
    smiles = "CC1(C)[CH]2CC[CH](CC(O)=O)[CH]1C2"
    smiles = "C[CH]1C(=O)O[CH]2CCN3CC=C(COC(=O)[C](C)(O)[C]1(C)O)[CH]23"
    #smiles = "CC1=CC(=O)C=CC1=O"
    smiles = "NC1=CC2=C(C=C1)C(=O)C3=C(C=CC=C3)C2=O"
    smiles = "COC1=CC2=C(C=C1OC)[C]34CCN5CC6=CCO[CH]7CC(=O)N2[CH]3[CH]7[CH]6C[CH]45.OS(O)(=O)=O"

    mol1 = Smiles.smilin(smiles, transforms=[])

    print mol1.cansmiles()
    NUM = 1

    t1 = time.time()
    for i in range(NUM):
        sssr(mol1)
    t2 = time.time()
    print(t2 - t1) / NUM
    symbols = []
    for atom in mol1.atoms:
        symbols.append(atom.symbol)

    for atom in mol1.atoms:
        atom.symbol += ".%s." % atom.index
        atom.symorder = mol1.atoms.index(atom)

    index = 0
    for cycle in mol1.cycles:
        print cycle.atoms
        print cycle.bonds
        for atom in cycle.atoms:
            atom.symbol += "<%s>" % index
        index += 1

    print Traverse.draw(mol1)[0]

    for atom, symbol in zip(mol1.atoms, symbols):
        atom.symbol = symbol

    for atom in mol1.atoms:
        atom.symbol += ".%s." % atom.index
        atom.symorder = mol1.atoms.index(atom)

    t1 = time.time()
    for i in range(NUM):
        RingDetection.sssr(mol1)
    t2 = time.time()
    print(t2 - t1) / NUM
    index = 0
    for cycle in mol1.cycles:
        print cycle.atoms
        print cycle.bonds
        for atom in cycle.atoms:
            atom.symbol += "<%s>" % index
        index += 1

    print Traverse.draw(mol1)[0]
Beispiel #6
0
def test():
    from frowns import Smiles
    import RingDetection
    import sssr as sssr2
    import time
    from frowns.Canonicalization import Disambiguate, Traverse
    
    ##mol = Smiles.smilin("C12C3C4C1C5C4C3C25CCCCCC12C3C4C1C5C4C3C25")
    ##mol1 = Smiles.smilin("C1O[CH]1C2=CC=CC=C2",
    ##                    transforms = [])
    ##print mol1.cansmiles()
    smiles = "COC(=O)[CH]1C2CCC(CC2)[CH]1C(=O)OCC"
    smiles = "CC1(C)[CH]2CC[CH](CC(O)=O)[CH]1C2"
    smiles = "C[CH]1C(=O)O[CH]2CCN3CC=C(COC(=O)[C](C)(O)[C]1(C)O)[CH]23"
    #smiles = "CC1=CC(=O)C=CC1=O"
    smiles = "NC1=CC2=C(C=C1)C(=O)C3=C(C=CC=C3)C2=O"
    smiles = "COC1=CC2=C(C=C1OC)[C]34CCN5CC6=CCO[CH]7CC(=O)N2[CH]3[CH]7[CH]6C[CH]45.OS(O)(=O)=O"

    mol1 = Smiles.smilin(smiles,
                         transforms = [])
    
    print mol1.cansmiles()
    NUM = 1
    
    t1 = time.time()
    for i in range(NUM):
        sssr(mol1)
    t2 = time.time()
    print (t2-t1)/NUM
    symbols = []
    for atom in mol1.atoms:
        symbols.append(atom.symbol)

    for atom in mol1.atoms:
        atom.symbol += ".%s."%atom.index
        atom.symorder = mol1.atoms.index(atom)
        
    index = 0
    for cycle in mol1.cycles:
        print cycle.atoms
        print cycle.bonds
        for atom in cycle.atoms:
            atom.symbol += "<%s>"%index
        index += 1

    print Traverse.draw(mol1)[0]

    for atom, symbol in zip(mol1.atoms, symbols):
        atom.symbol = symbol

    for atom in mol1.atoms:
        atom.symbol += ".%s."%atom.index
        atom.symorder = mol1.atoms.index(atom)
        
    t1 = time.time()
    for i in range(NUM):
        RingDetection.sssr(mol1)
    t2 = time.time()
    print (t2-t1)/NUM
    index = 0
    for cycle in mol1.cycles:
        print cycle.atoms
        print cycle.bonds
        for atom in cycle.atoms:
            atom.symbol += "<%s>"%index
        index += 1

    print Traverse.draw(mol1)[0]