How to use the selfies.selfies_alphabet function in selfies

To help you get started, we’ve selected a few selfies examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aspuru-guzik-group / selfies / examples / selfies_examples.py View on Github external
print('equal: '+str(test_molecule3==smiles3)+'\n\n\n')

test_molecule4='Cc1c(C)c(S(=O)(=O)NC(=N)NCCC[C@H](NC(=O)[C@@H]2CCCN2C(=O)[C@H](CCC(=O)NC(c2ccccc2)(c2ccccc2)c2ccccc2)NC(=O)[C@H](CC(C)C)NC(=O)[C@H](CCCCNC(=O)OC(C)(C)C)NC(=O)[C@H](C)NC(=O)[C@@H]2CCCN2C(=O)[C@@H]2CCCN2C(=O)[C@H](CCCCNC(=O)OC(C)(C)C)NC(=O)[C@H](CCCCNC(=O)OC(C)(C)C)NC(=O)[C@H](COC(C)(C)C)NC(=O)[C@H](CCC(=O)OC(C)(C)C)NC(=O)[C@H](CCCCNC(=O)OC(C)(C)C)NC(=O)[C@H](CCCNC(=N)NS(=O)(=O)c2c(C)c(C)c3c(c2C)CCC(C)(C)O3)NC(=O)[C@H](CCC(=O)NC(c2ccccc2)(c2ccccc2)c2ccccc2)NC(=O)[C@H](CCC(=O)NC(c2ccccc2)(c2ccccc2)c2ccccc2)NC(=O)[C@@H](NC(=O)[C@H](CCCNC(=N)NS(=O)(=O)c2c(C)c(C)c3c(c2C)CCC(C)(C)O3)NC(=O)[C@H](CCC(=O)NC(c2ccccc2)(c2ccccc2)c2ccccc2)NC(=O)[C@H](Cc2cn(C(=O)OC(C)(C)C)cn2)NC(=O)[C@H](CCC(=O)OC(C)(C)C)NC(=O)[C@@H]2CCCN2C(=O)[C@H](COC(C)(C)C)NC(=O)[C@H](CC(C)C)NC(=O)[C@H](Cc2ccccc2)NC(=O)[C@H](COC(c2ccccc2)(c2ccccc2)c2ccccc2)NC(=O)[C@H](COC(C)(C)C)NC(=O)CNC(=O)OC(C)(C)C)C(C)C)C(=O)O)c(C)c2c1OC(C)(C)CC2'
selfies4=encoder(test_molecule4)
smiles4=decoder(selfies4)
print('test_molecule4: '+test_molecule4+'\n')
print('selfies4: '+selfies4+'\n')
print('smiles4: '+smiles4+'\n')
print('equal: '+str(test_molecule4==smiles4)+'\n\n\n')



#Create a random Molecule, test robustness


my_alphabet=selfies_alphabet()                                                 # this is a very small alphabet from which the random selfies are generated
                                                                               # This alphabet can be extended with additional elements. For example, see the list start_alphabet in the function smiles_to_selfies.
                                                                               # Also when you run the three test-molecules above, you see the brackets that are used, and can use some of them.


len_of_molecule=50 # Number of selfies symbols of the random string. The final SMILES string will not necessarily be of the same size, because some elements of this alphabet stop the derivation (such as Flour, as it can form only a single bond)

rnd_selfies=''
for ii in range(len_of_molecule):
    rnd_selfies+=my_alphabet[randint(0,len(my_alphabet)-1)]

smiles4=decoder(rnd_selfies)

        
    
    
print('Random Molecule: '+str(smiles4)+'\n')

selfies

SELFIES (SELF-referencIng Embedded Strings) is a general-purpose, sequence-based, robust representation of semantically constrained graphs.

Apache-2.0
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis

Similar packages