| ## SMILES Splitter Script |
|
|
| The file splitter script (`split_file.sh`) is used to split large SMILES files into smaller parts. |
|
|
| ### Usage |
|
|
| ```bash |
| ./split_smi.sh <input_file> [max_size_mb] |
| ``` |
|
|
| - `<input_file>`: The SMILES file to split |
| - `[max_size_mb]`: Optional. The maximum size of each part in MB (default: 1024) |
|
|
| ### Running with xargs for parallel processing |
|
|
| To split multiple files in parallel: |
|
|
| ```bash |
| find . -name "*.smi" | xargs -n1 -P$(nproc) ./split_file.sh |
| ``` |
|
|
| To specify a custom size (e.g., 500 MB): |
|
|
| ```bash |
| find . -name "*.smi" | xargs -n2 -P$(nproc) ./split_file.sh {} 500 |
| ``` |
|
|
| Note: This script will delete the original file if it was split successfully. |
|
|
| ## SELFIES Converter Script |
|
|
| The SELFIES converter script (`selfies_converter.py`) converts SMILES files to SELFIES format. |
|
|
| ### Usage |
|
|
| ```bash |
| python selfies_converter.py <input_file> [-v] [-b BATCH_SIZE] |
| ``` |
|
|
| - `<input_file>`: The SMILES file to convert |
| - `-v, --verbose`: Optional. Increase output verbosity |
| - `-b BATCH_SIZE, --batch-size BATCH_SIZE`: Optional. Batch size for processing (default: 10000) |
|
|
| ### Running with find and xargs for parallel processing |
|
|
| To convert all .smi files in parallel: |
|
|
| ```bash |
| find . -name "*.smi" | xargs -I {} -P$(nproc) sh -c 'python selfies_converter.py {}' |
| ``` |
|
|
| To convert files and remove the original .smi files after successful conversion: |
|
|
| ```bash |
| find . -name "*.smi" | xargs -I {} -P$(nproc) sh -c 'python selfies_converter.py {} && rm {}' |
| ``` |
|
|
| Note: Be cautious when using the command that removes original files. Ensure you have backups before running it. |
|
|
| With gz: |
| ```bash |
| find . -name "*.smi.gz" | xargs -P$(nproc) -I {} sh -c 'f="{}"; g="${f%.gz}"; gzip -dc "$f" > "$g" && python selfies_converter.py "$g" && rm "$g" && rm "$f"' |
| ``` |
|
|
|
|
| ## Output |
|
|
| Both scripts will create output files in the same directory as the input files: |
|
|
| - The file splitter creates `<original_name>.part01.smi`, `<original_name>.part02.smi`, etc. |
| - The SELFIES converter creates `<original_name>.selfies` for the converted file and `<original_name>.alph` for the alphabet file. |
|
|