Git Product home page Git Product logo

janus's Introduction

JANUS: Parallel Tempered Genetic Algorithm Guided by Deep Neural Networks for Inverse Molecular Design

This repository contains code for the paper: JANUS: Parallel Tempered Genetic Algorithm Guided by Deep Neural Networks for Inverse Molecular Design.

Originally by: AkshatKumar Nigam, Robert Pollice, Alán Aspuru-Guzik

Updated by: Gary Tom

Prerequsites:

Use Python 3.7 or up.

You will need to separately install RDKit version >= 2020.03.1. The easiest is to do this on conda.

JANUS uses SELFIES version 1.0.3. If you want to use a different version, pip install your desired version; this package will still be compatible. Note that you will have to change your input alphabets to work with other versions of SELFIES.

Major changes:

  • Support the use of any version of SELFIES (please check your installation).
  • Improved multiprocessing. Fitness function is not parallelized, in the case that the function already spawns multiple processes.
  • GPU acceleration of neural networks.
  • Early stopping for classifier.
  • Included SMILES filtering option.
  • Additional hyperparameters for controlling JANUS. Defaults used in paper are given in tests directory.

How to run:

Install JANUS using

pip install janus-ga

Example script of how to use JANUS is found in tests/example.py:

from janus import JANUS, utils
from rdkit import Chem, RDLogger
from rdkit.Chem import AllChem, RDConfig, Descriptors
RDLogger.DisableLog("rdApp.*")

import selfies

def fitness_function(smi: str) -> float:
    """ User-defined function that takes in individual smiles 
    and outputs a fitness value.
    """
    # logP fitness
    return Descriptors.MolLogP(Chem.MolFromSmiles(smi))

def custom_filter(smi: str):
    """ Function that takes in a smile and returns a boolean.
    True indicates the smiles PASSES the filter.
    """
    # smiles length filter
    if len(smi) > 81 or len(smi) == 0:
        return False
    else:
        return True

# all parameters to be set, below are defaults
params_dict = {
    # Number of iterations that JANUS runs for
    "generations": 200,

    # The number of molecules for which fitness calculations are done, 
    # exploration and exploitation each have their own population
    "generation_size": 5000,
    
    # Number of molecules that are exchanged between the exploration and exploitation
    "num_exchanges": 5,

    # Callable filtering function (None defaults to no filtering)
    "custom_filter": custom_filter,

    # Fragments from starting population used to extend alphabet for mutations
    "use_fragments": True,

    # An option to use a classifier as selection bias
    "use_classifier": True,
}

# Set your SELFIES constraints (below used for manuscript)
default_constraints = selfies.get_semantic_constraints()
new_constraints = default_constraints
new_constraints['S'] = 2
new_constraints['P'] = 3
selfies.set_semantic_constraints(new_constraints)  # update constraints

# Create JANUS object.
agent = JANUS(
    work_dir = 'RESULTS',                                   # where the results are saved
    fitness_function = fitness_function,                    # user-defined fitness for given smiles
    start_population = "./DATA/sample_start_smiles.txt",   # file with starting smiles population
    **params_dict
)

# Alternatively, you can get hyperparameters from a yaml file
# Descriptions for all parameters are found in default_params.yml
params_dict = utils.from_yaml(
    work_dir = 'RESULTS',  
    fitness_function = fitness_function, 
    start_population = "./DATA/sample_start_smiles.txt",
    yaml_file = 'default_params.yml',       # default yaml file with parameters
    **params_dict                           # overwrite yaml parameters with dictionary
)
agent = JANUS(**params_dict)

# Run according to parameters
agent.run()     # RUN IT!

Within this file are examples for:

  1. A function for calculting property values (see function fitness_function).
  2. Custom filtering of SMILES (see function custom_filter).
  3. Initializing JANUS from dictionary of parameters.
  4. Generating hyperparameters from provided yaml file (see function janus.utils.from_yaml).

You can run the file with provided test files

cd tests
python ./example.py

Important parameters the user should provide:

  • work_dir: directory for outputting results
  • fitness_function: fitness function defined for an input smiles that will be maximized
  • start_population: path to text file of starting smiles one each new line
  • generations: number if evolution iterations to perform
  • generation_size: number of molecules in the populations per generation
  • custom_filter: filter function checked after mutation and crossover, returns True for accepted molecules
  • use_fragments: toggle adding fragments from starting population to mutation alphabet
  • use_classifier: toggle using classifier for selection bias

See tests/default_params.yml for detailed description of adjustable parameters.

Outputs:

All results from running JANUS will be stored in specified work_dir.

The following files will be created:

  1. fitness_explore.txt: Fitness values for all molecules from the exploration component of JANUS.
  2. fitness_local_search.txt: Fitness values for all molecules from the exploitation component of JANUS.
  3. generation_all_best.txt: Smiles and fitness value for the best molecule encountered in every generation (iteration).
  4. init_mols.txt: List of molecules used to initialte JANUS.
  5. population_explore.txt: SMILES for all molecules from the exploration component of JANUS.
  6. population_local_search.txt: SMILES for all molecules from the exploitation component of JANUS.
  7. hparams.json: Hyperparameters used for initializing JANUS.

Paper Results/Reproducibility:

Our code and results for each experiment in the paper can be found here:

Questions, problems?

Make a github issue 😄. Please be as clear and descriptive as possible. Please feel free to reach out in person: (akshat[DOT]nigam[AT]mail[DOT]utoronto[DOT]ca, rob[DOT]pollice[AT]utoronto[DOT]ca)

License

Apache License 2.0

janus's People

Contributors

akshat998 avatar gkwt avatar natkusanda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

janus's Issues

Creating same molecule across generations, what may be the problem?

Hi Janus team,

Very interesting algorithm. However, the algorithm seems to be stuck perhaps in only creating one kind of molecule for my starting data. I played with "81" as length max or "111" as max smiles length in example.py. Both options seem to be stuck in some kind of minima that it's spitting same molecule in RESULTS/generation_all_best.txt. Attached please find two generation_all_best.txt files, one from each filter. It keep generating same molecule at each generation.

With n=200 generations, I assumed we will have 200 different molecules. Can you please clarify what i should expect from the algorithm and what is the correct result file to look at? My results are below. 31 molecules generated so far with 81 length in example.py and 24 generated with 111 length in example.py. All look the same across generations and just seems to be long chains. Obviously, my starting structures are different from yours.

I have ~2400 molecules as starting structures and not sure what is the next step for me to be able to use JANUS. Should I use your starting structures and add mine to original 9999 structures to see better results?
Thanks so much,
JL
Email: [email protected]


With 81 length

Gen:0, CCCCCC=CCC=CCCCCCCCCN(CCCCCCCCC=CCC=CCCCCC)CCCNC(=O)c1cc(C(=O)NCCCN(CCCCCCCCC=CCC=CCCCCC)CCCCCCCCC=CCC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CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSSSSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCI, 43.519199999999906
Gen:18, CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSSSSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCI, 43.519199999999906
Gen:19, CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSSSSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCI, 43.519199999999906
Gen:20, CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSSSSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCI, 43.519199999999906
Gen:21, CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSSSSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCI, 43.519199999999906
Gen:22, CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSSSSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCI, 43.519199999999906
Gen:23, CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSCCCCCCCSSSSSSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCI, 43.5982999999999
Gen:24, CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCSSSSSSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCI, 44.035399999999896

freeze_support runtime error with provided example

Hello, I'm trying out JANUS and if I just run the example inside the tests as provided I get

  File "/Users/nsofroniew/opt/anaconda3/envs/chem/lib/python3.9/multiprocessing/spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

This can be fixed by wrapping the creation and running of the JANUS agent and inside

if __name__ == '__main__':
    torch.multiprocessing.freeze_support()

see for a similar fix pytorch/pytorch#5858 (comment)

I'm happy to submit a PR to fix if you like - it will be very simple

Enquiring on multi-objective fitness function

Hi, I would like to ask if there are multiple objectives which I want the fitness function to fulfil, how would I write out the function because the example on the README.md is only for one objective (logP)?

Thank you! :D

error in numpy/ list multiplication inside mutate_smi_list

Hello, I am trying to run the provided example, but get the following error

$ python ./example.py
    Unique and valid fragments generated: 107308
    Unique and valid fragments generated: 107308
On generation 0/200
/Users/nsofroniew/opt/anaconda3/envs/chem/lib/python3.9/site-packages/janus/janus.py:457: RuntimeWarning: overflow encountered in power
  prob_ = 1.0 / (3.0 ** ((F_50_val - fitness) / (F_50_val - F_25_val)) + 1)
    (Explr) Top Fitness: 15.811199999999957
    (Explr) Top Smile: CCCCCCCCCCCCCCCCOP(=O)(O)Oc1ccc(C=Cc2ccc(OP(=O)(O)OCCCCCCCCCCCCCCCC)cc2)cc1
Traceback (most recent call last):
  File "/Users/nsofroniew/Documents/code/chem/janus/tests/./example.py", line 81, in <module>
  File "/Users/nsofroniew/opt/anaconda3/envs/chem/lib/python3.9/site-packages/janus/janus.py", line 317, in run
    mut_smi_loc = self.mutate_smi_list(smiles_local_search, "local")
  File "/Users/nsofroniew/opt/anaconda3/envs/chem/lib/python3.9/site-packages/janus/janus.py", line 137, in mutate_smi_list
    smi_list = smi_list * num_random_samples
numpy.core._exceptions._UFuncNoLoopError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U98'), dtype('int64')) -> None

It looks like smi_list has become a numpy array, which is unintended and it should be a list. This can be fixed by making this line

smi_list = smi_list * num_random_samples
be

    smi_list = list(smi_list) * num_random_samples

There could be other, more desirable fixes that avoid this problem altogether. I am happy to submit a PR if this fix is desired though.

Question: How sensitive is the model to molecule initialization?

Hello, great work! I'm excited to try this out for a chemical design project I'm working on. One question that I had after reading the pre-print— how sensitive is the model to molecule initialization?

I read that you can start JANUS with random molecules or provide it with defined molecules. Did you perform any tests on what happens if the best molecule's scaffold was ablated from the initial bank of molecules? And how much, if at all, does rational initialization improve over random molecular initialization? Does this relate back to being trapped in local minima, and would the choice of initialization help explore more chemical space?

Thank you!

Unhandled exceptions and KeyError

I tried running JANUS.py but got a number of exceptions. In addition, the script terminated with a KeyError.

Initial population obtained!
Forming Fragments!
    Fragment creation: 0/10000
    Fragment creation: 1000/10000
    Fragment creation: 2000/10000
    Fragment creation: 3000/10000
    Fragment creation: 4000/10000
    Fragment creation: 5000/10000
    Fragment creation: 6000/10000
    Fragment creation: 7000/10000
    Fragment creation: 8000/10000
    Fragment creation: 9000/10000
Process Process-5:
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 205, in calc_parr_prop
    props_collect[property_name][smile] = get_prop_material(smile, alphabet=alphabet, num_random_samples=num_random_samples, num_mutations=num_mutations)  # TODO: TESTING
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in get_prop_material
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in 
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 59, in decoder
    rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 147, in _derive_mol_from_symbols
    _raise_decoder_error(selfies, symbol)
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 179, in _raise_decoder_error
    raise DecoderError(err_msg)
selfies.exceptions.DecoderError: invalid symbol '[Branch3_1]'
	SELFIES: [S][C][=N][N][=C][Branch1][Ring1][C][C][C][Branch1][#Branch1][O][C][Branch1][C][C][=O][C][Branch1][C][C][Branch1][C][C][C][N][N][N][Branch3_1][C][C][=C][=C][Branch1][C][N][C][=C][Ring1][#Branch1][C][#Branch1][N]
Process Process-7:
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 205, in calc_parr_prop
    props_collect[property_name][smile] = get_prop_material(smile, alphabet=alphabet, num_random_samples=num_random_samples, num_mutations=num_mutations)  # TODO: TESTING
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in get_prop_material
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in 
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 59, in decoder
    rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 124, in _derive_mol_from_symbols
    _raise_decoder_error(selfies, symbol)
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 179, in _raise_decoder_error
    raise DecoderError(err_msg)
selfies.exceptions.DecoderError: invalid symbol '[Expl=Ring3]'
	SELFIES: [C][Expl=Ring3][=C][Branch2][Ring1][=Branch1][C][=C][C][=C][Branch1][#C][C][=C][Ring1][=Branch1][C][=C][C][=C][C][=C][Ring1][=Branch1][Ring1][=C][F][C][Branch1][C][C][C][C][C][N][Branch1][=Branch2][S][Branch1][C][C][=Branch1][C][=O][=O][C][C][Ring1][#Branch2][C][N][Branch1][Branch1][C][C][C][C][C][C][C][C]
Process Process-4:
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 205, in calc_parr_prop
    props_collect[property_name][smile] = get_prop_material(smile, alphabet=alphabet, num_random_samples=num_random_samples, num_mutations=num_mutations)  # TODO: TESTING
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in get_prop_material
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in 
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 59, in decoder
    rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 116, in _derive_mol_from_symbols
    init_state=binit_state, root_atom=prev_atom, rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 147, in _derive_mol_from_symbols
    _raise_decoder_error(selfies, symbol)
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 179, in _raise_decoder_error
    raise DecoderError(err_msg)
selfies.exceptions.DecoderError: invalid symbol '[Branch1_3]'
	SELFIES: [C][C][=C][Branch1][=Branch1][C][C][=Ring1][=Branch1][Branch1_3][C][C][=C][C][=C][Branch1][C][C][=C][C][=C][Branch1][C][N][C][=N][Ring1][#Branch1][#Branch2][C][N][C][O][C][C][Ring1][=Branch1][C][Branch1][C][O][=C][C][=C][Ring1][=C][O][Ring1][P]
Process Process-6:
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 205, in calc_parr_prop
    props_collect[property_name][smile] = get_prop_material(smile, alphabet=alphabet, num_random_samples=num_random_samples, num_mutations=num_mutations)  # TODO: TESTING
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in get_prop_material
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in 
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 59, in decoder
    rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 116, in _derive_mol_from_symbols
    init_state=binit_state, root_atom=prev_atom, rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 147, in _derive_mol_from_symbols
    _raise_decoder_error(selfies, symbol)
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 179, in _raise_decoder_error
    raise DecoderError(err_msg)
selfies.exceptions.DecoderError: invalid symbol '[Branch3_2]'
	SELFIES: [C][C][=Branch1][#C][=C][C][=C][C][=Ring1][=Branch1][C][Branch1][C][F][Branch1][C][F][F][C][C][Branch1][C][C][=N][N][C][=Branch1][C][C][C][N][C][C][C][Branch1][C][N][C][C][Ring1][#Branch1][C][O][=C][C][Branch1][O][C][Branch3_2][C][N][C][C][O][C][C][Ring1][=Branch1][=O]
Process Process-8:
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 205, in calc_parr_prop
    props_collect[property_name][smile] = get_prop_material(smile, alphabet=alphabet, num_random_samples=num_random_samples, num_mutations=num_mutations)  # TODO: TESTING
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in get_prop_material
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in 
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 59, in decoder
    rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 116, in _derive_mol_from_symbols
    init_state=binit_state, root_atom=prev_atom, rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 116, in _derive_mol_from_symbols
    init_state=binit_state, root_atom=prev_atom, rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 147, in _derive_mol_from_symbols
    _raise_decoder_error(selfies, symbol)
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 179, in _raise_decoder_error
    raise DecoderError(err_msg)
selfies.exceptions.DecoderError: invalid symbol '[Branch2_1]'
	SELFIES: [C][=Branch1][C][=O][Branch1][C][O][C][N][C][=Branch1][C][=O][C][Branch2][Ring1][=Branch1][N][C][=Branch1][C][=O][C][Branch1][N][C][=C][C][=C][C][Branch2_1][Ring2][=N][Ring1][=Branch1][N][=N][O][C][Ring2][Ring1][C][S][C][C][=Ring2][Ring1][=Branch1][S][C][S][N][=C][Branch1][Ring2][N][=Ring1][Branch1][S][C][C][N]
Process Process-11:
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 205, in calc_parr_prop
    props_collect[property_name][smile] = get_prop_material(smile, alphabet=alphabet, num_random_samples=num_random_samples, num_mutations=num_mutations)  # TODO: TESTING
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in get_prop_material
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in 
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 59, in decoder
    rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 147, in _derive_mol_from_symbols
    _raise_decoder_error(selfies, symbol)
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 179, in _raise_decoder_error
    raise DecoderError(err_msg)
selfies.exceptions.DecoderError: invalid symbol '[Branch2_3]'
	SELFIES: [C][C][=C][C][Branch1][=C][C][N][Branch1][C][C][N][C][=Branch1][C][=O][C][S][C][C][C][Ring1][#Branch1][=C][C][=Ring1][O][C][=C][C][=C][C][=C][Ring1][=Branch1][O][C][=C][Branch2_3][Branch1]
Process Process-10:
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 205, in calc_parr_prop
    props_collect[property_name][smile] = get_prop_material(smile, alphabet=alphabet, num_random_samples=num_random_samples, num_mutations=num_mutations)  # TODO: TESTING
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in get_prop_material
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in 
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 59, in decoder
    rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 116, in _derive_mol_from_symbols
    init_state=binit_state, root_atom=prev_atom, rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 116, in _derive_mol_from_symbols
    init_state=binit_state, root_atom=prev_atom, rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 147, in _derive_mol_from_symbols
    _raise_decoder_error(selfies, symbol)
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 179, in _raise_decoder_error
    raise DecoderError(err_msg)
selfies.exceptions.DecoderError: invalid symbol '[Branch3_3]'
	SELFIES: [F][C][=C][C][=C][Branch2][Ring2][O][C][N][C][Branch2][Ring2][Ring2][C][Branch1][#C][C][C][=C][Branch1][=Branch2][C][=C][C][=C][C][=Branch1][C][=O][N][Branch1][C][C][Branch3_3][C][Branch1][C][F][C][=Ring1][#Branch1][F][=N][C][C][Ring1][C][N][C][C][N][C][C][Ring1][=Branch1][=C][=N][C][=Branch1][Branch1][=N][C][=Ring1][=Branch1][N][Branch1][C][C][C][=O][C][=C][Ring2][Ring1][=N]
Process Process-9:
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 205, in calc_parr_prop
    props_collect[property_name][smile] = get_prop_material(smile, alphabet=alphabet, num_random_samples=num_random_samples, num_mutations=num_mutations)  # TODO: TESTING
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in get_prop_material
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in 
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 59, in decoder
    rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 116, in _derive_mol_from_symbols
    init_state=binit_state, root_atom=prev_atom, rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 116, in _derive_mol_from_symbols
    init_state=binit_state, root_atom=prev_atom, rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 147, in _derive_mol_from_symbols
    _raise_decoder_error(selfies, symbol)
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 179, in _raise_decoder_error
    raise DecoderError(err_msg)
selfies.exceptions.DecoderError: invalid symbol '[Branch3_3]'
	SELFIES: [C][C][Branch1][#Branch2][C][=C][C][=Branch1][Ring2][=C][=Branch1][F][=N][C][=C][Branch2][Ring2][Branch1][N][Branch1][Branch2][C][=N][C][Ring1][=Branch1][=Ring1][=C][N][=C][C][=C][C][=C][Branch1][P][C][=Branch1][Ring2][=C][Ring1][=Branch1][C][Branch3_3][C][N][=C][C][=C][C][=Ring1][=Branch1][O][C][O]
On generation 0/200
    (Explr) Top Fitness: 1.0
    (Explr) Top Smile: C=C1N=CC=C(N=CNc2ccc(N)cc2)N=C(C)[SH]1C
Process Process-27:
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 205, in calc_parr_prop
    props_collect[property_name][smile] = get_prop_material(smile, alphabet=alphabet, num_random_samples=num_random_samples, num_mutations=num_mutations)  # TODO: TESTING
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in get_prop_material
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/software/JANUS/mutate_parr.py", line 129, in 
    mutated_smiles = [decoder(x) for x in mutated_sf]
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 59, in decoder
    rings=rings
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 147, in _derive_mol_from_symbols
    _raise_decoder_error(selfies, symbol)
  File "/home/ubuntu/anaconda3/envs/reinvent.v3.2/lib/python3.7/site-packages/selfies/decoder.py", line 179, in _raise_decoder_error
    raise DecoderError(err_msg)
selfies.exceptions.DecoderError: invalid symbol '[Branch3_2]'
	SELFIES: [C][O][=C][N][C][N][C][=Branch1][C][=O][N][Branch1][=Branch1][N+1][=Branch1][C][=O][O-1][C][Ring1][=Branch2][N][Ring1][N][O][C][=C][C][C][N][C][N][C][N][C][=C][C][=C][Branch1][C][F][C][Branch1][C][F][=C][Ring1][Branch2][=N][C][Branch1][C][C][Branch3_2][Branch1][=Branch1][C][Branch1][C][C][=O][S][Ring1][=Branch2][=C][C][=Ring1][#Branch1][N][C][N][C][C][=C][C][=C][C][=C][Ring1][=Branch1][C][N][=C][Branch1][=C][SH1][Branch1][C][C][C][=C][C][=C][C][=C][Ring1][=Branch1][=Branch1][C][=C][N][=C][C][=Ring1][#Branch2][C]
Traceback (most recent call last):
  File "./JANUS.py", line 308, in 
    mut_smi_dict_local  = mut_smi_dict_local[population[top_idx]]
KeyError: 'C=C1N=CC=C(N=CNc2ccc(N)cc2)N=C(C)[SH]1C'

multiprocessing in windows

Hi.
I was run the code, but I met errors in all codes that used multiprocessing.
As I know these errors came from the difference of OS.

Since I use Windows, I wonder how to correct the code for Windows.

Thanks.

Save all molecules from each generation

I am running the experiments for N generations but the model only gives the generated molecules of N-th generation. How can I also save the molecules from previous generation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.