Package: rxn-reaction-preprocessing
RXN reaction preprocessingThis repository is devoted to preprocessing chemical reactions: standardization, filtering, etc.
It also includes code for stable train/test/validation splits and data augmentation.Links:GitHub repositoryDocumentationPyPI packageSystem RequirementsThis package is supported on all operating systems.
It has been tested on the following systems:macOS: Big Sur (11.1)Linux: Ubuntu 18.04.4A Python version of 3.7 or greater is recommended.Installation guideThe package can be installed from Pypi:pipinstallrxn-reaction-preprocessing[rdkit]You can leave out[rdkit]if you prefer to installrdkitmanually (via Conda or Pypi).For local development, the package can be installed with:pipinstall-e".[dev]"UsageThe following command line scripts are installed with the package.rxn-data-pipelineWrapper for all other scripts. Allows constructing flexible data pipelines. Entrypoint for Hydra structured configuration.For an overview of all available configuration parameters and default values, run:rxn-data-pipeline --cfg job.Configuration using YAML (see the fileconfig.pyfor more options and their meaning):defaults:-base_configdata:path:/tmp/inference/input.csvproc_dir:/tmp/rxn-preproc/expcommon:sequence:# Define which steps and in which order to execute:-IMPORT-STANDARDIZE-PREPROCESS-SPLIT-TOKENIZEfragment_bond:TILDEpreprocess:min_products:0split:split_ratio:0.05tokenize:input_output_pairs:-inp:${data.proc_dir}/${data.name}.processed.train.csvout:${data.proc_dir}/${data.name}.processed.train-inp:${data.proc_dir}/${data.name}.processed.validation.csvout:${data.proc_dir}/${data.name}.processed.validation-inp:${data.proc_dir}/${data.name}.processed.test.csvout:${data.proc_dir}/${data.name}.processed.testrxn-data-pipeline--config-dir.--config-nameexample_configConfiguration using command line arguments (example):rxn-data-pipeline\data.path=/path/to/data/rxns-small.csv\data.proc_dir=/path/to/proc/dir\common.fragment_bond=TILDE\rxn_import.data_format=TXT\tokenize.input_output_pairs.0.out=train.txt\tokenize.input_output_pairs.1.out=validation.txt\tokenize.input_output_pairs.2.out=test.txtNote about reading CSV filesPandas appears not to always be able to write a CSV and re-read it if it contains Windows carriage returns.
In order for the scripts to work despite this, all thepd.read_csvfunction calls should include the argumentlineterminator='\n'.ExamplesA pipeline supporting augmentationA config supporting augmentation of the training split calledtrain-augmentation-config.yaml:defaults:-base_configdata:name:pipeline-with-augmentationpath:/tmp/file-with-reactions.txtproc_dir:/tmp/rxn-preprocessing/experimentcommon:sequence:# Define which steps and in which order to execute:-IMPORT-STANDARDIZE-PREPROCESS-SPLIT-AUGMENT-TOKENIZEfragment_bond:TILDErxn_import:data_format:TXTpreprocess:min_products:1split:input_file_path:${preprocess.output_file_path}split_ratio:0.05augment:input_file_path:${data.proc_dir}/${data.name}.processed.train.csvoutput_file_path:${data.proc_dir}/${data.name}.augmented.train.csvpermutations:10tokenize:falserandom_type:rotatedtokenize:input_output_pairs:-inp:${data.proc_dir}/${data.name}.augmented.train.csvout:${data.proc_dir}/${data.name}.augmented.trainreaction_column_name:rxn_rotated-inp:${data.proc_dir}/${data.name}.processed.validation.csvout:${data.proc_dir}/${data.name}.processed.validation-inp:${data.proc_dir}/${data.name}.processed.test.csvout:${data.proc_dir}/${data.name}.processed.testrxn-data-pipeline--config-dir.--config-nametrain-augmentation-config