<commit_before># ECNet Tools

## Database creation

ECNet databases are comma-separated value (CSV) formatted files that provide information such as the ID of each data point, an optional explicit sort type, various strings and groups to identify data points, target values and input parameters. Row 1 is used to identify which columns are used for ID, explicit sorting assignment, various strings and groups, and target and input data, and row 2 contains the names of these strings/groups/targets/inputs. Additional rows are data points.

Our [databases](https://github.com/ECRL/ECNet/tree/master/databases) directory on GitHub contains databases for cetane number, cloud point, kinetic viscosity, pour point and yield sooting index, as well as a database template.

You can create an ECNet-formatted database with molecule names or SMILES and (optionally) target values. The following programs must be installed for you to do so:
- [Open Babel](http://openbabel.org/wiki/Main_Page) software
- [Java JRE](https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html) version 6 and above

Supplied names or SMILES must exist in a text file, one entry per line:
```
Acetaldehyde
Acetaldehyde dimethyl acetal
Acetic acid
Acetic anhydride
Acetol
Acetone
Acetonitrile
Acetonylacetone
```

If target values are supplied, they must also exist in a text file (of equal length to the supplied names or SMILES):
```
70
147
244
284
295
133
180
376
```

The database can then be constructed with:
```python
from ecnet.tools.database import create_db

create_db('names.txt', 'my_database.csv', targets='targets.txt')
```

If SMILES strings are supplied instead of names:
```python
from ecnet.tools.database import create_db

create_db('smiles.txt', 'my_database.csv', targets='targets.txt', form='smiles')
```

Your database's DATAID column (essentially Bates numbers for each molecule) will increment starting at 0001. If a prefix is desired for these values, specify it with:

```python
from ecnet.tools.database import create_db

create_db('names.txt', 'my_database.csv', targets='targets.txt', id_prefix='MOL')
```

## Chemical file/format conversion

ECNet has a variety of tools for converting chemical files/formats:

### Molecule name to SMILES string

```python
from ecnet.tools.conversions import get_smiles

smiles = get_smiles('Molecule Name')
```

### SMILES string to MDL Molfile

A text file containing SMILES strings, one per line, is required:

```
CC1=CC=C(O1)C(C2=CC=CO2)C3=CC=C(O3)C
CCCCC1=CC=CO1
C1CCOCC1
CC1=CC=C(C)O1
C1C=CCO1
```

```python
from ecnet.tools.conversions import smiles_to_mdl

# An MDL file is generated
smiles_to_mdl('smiles.txt', 'molfile.mdl')
```

Note that [Open Babel](http://openbabel.org/wiki/Main_Page) is required to execute this function.

### MDL to QSPR descriptors

An existing MDL file is required, as well as an installation of [Java JRE](https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html).

```python
from ecnet.tools.conversions import mdl_to_descriptors

# A CSV file with descriptors is generated
mdl_to_descriptors('molfile.md', 'descriptors.csv')
```

## ECNet .prj file usage

Once an ECNet project has been created, the resulting .prj file can be used to predict properties for new molecules. A text file containing names or SMILES strings of new molecules, one per line, is required in addition to the .prj file.

```python<commit_msg>Documentation update per conversion/database tool changes<commit_after># ECNet Tools

## Database creation

ECNet databases are comma-separated value (CSV) formatted files that provide information such as the ID of each data point, an optional explicit sort type, various strings and groups to identify data points, target values and input parameters. Row 1 is used to identify which columns are used for ID, explicit sorting assignment, various strings and groups, and target and input data, and row 2 contains the names of these strings/groups/targets/inputs. Additional rows are data points.

Our [databases](https://github.com/ECRL/ECNet/tree/master/databases) directory on GitHub contains databases for cetane number, cloud point, kinetic viscosity, pour point and yield sooting index, as well as a database template.

You can create an ECNet-formatted database with molecule names or SMILES and (optionally) target values. [Java JRE](https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html) version 6 and above is required to create a database.

Supplied names or SMILES must exist in a text file, one entry per line:
```
Acetaldehyde
Acetaldehyde dimethyl acetal
Acetic acid
Acetic anhydride
Acetol
Acetone
Acetonitrile
Acetonylacetone
```

If target values are supplied, they must also exist in a text file (of equal length to the supplied names or SMILES):
```
70
147
244
284
295
133
180
376
```

The database can then be constructed with:
```python
from ecnet.tools.database import create_db

create_db('names.txt', 'my_database.csv', targets='targets.txt')
```

If SMILES strings are supplied instead of names:
```python
from ecnet.tools.database import create_db

create_db('smiles.txt', 'my_database.csv', targets='targets.txt', form='smiles')
```

Your database's DATAID column (essentially Bates numbers for each molecule) will increment starting at 0001. If a prefix is desired for these values, specify it with:

```python
from ecnet.tools.database import create_db

create_db('names.txt', 'my_database.csv', targets='targets.txt', id_prefix='MOL')
```

## Chemical file/format conversion

ECNet has a variety of tools for converting chemical files/formats:

### Molecule name to SMILES string

```python
from ecnet.tools.conversions import get_smiles

smiles = get_smiles('Molecule Name')
```

### SMILES string to MDL Molfile

Creating an MDL file requires [Open Babel](http://openbabel.org/wiki/Main_Page) to be installed.

A text file containing SMILES strings, one per line, is required:

```
CC1=CC=C(O1)C(C2=CC=CO2)C3=CC=C(O3)C
CCCCC1=CC=CO1
C1CCOCC1
CC1=CC=C(C)O1
C1C=CCO1
```

```python
from ecnet.tools.conversions import smiles_to_mdl

# An MDL file is generated
smiles_to_mdl('smiles.txt', 'molfile.mdl')
```

Note that [Open Babel](http://openbabel.org/wiki/Main_Page) is required to execute this function.

### MDL to QSPR descriptors

An existing MDL file is required, as well as an installation of [Java JRE](https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html).

```python
from ecnet.tools.conversions import mdl_to_descriptors

# A CSV file with descriptors is generated
mdl_to_descriptors('molfile.md', 'descriptors.csv')
```

### SMILES string to QSPR descriptors

A text file containing SMILES strings, one per line, is required, as well as an installation of [Java JRE](https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html).

*Note: the file extension for the text file containing SMILES strings must be ".smi"

```python
from ecnet.tools.conversions import smiles_to_descriptors

# A CSV file with descriptors is generated
smiles_to_descriptors('molecules.smi', 'descriptors.csv')
```

## ECNet .prj file usage

Once an ECNet project has been created, the resulting .prj file can be used to predict properties for new molecules. A text file containing names or SMILES strings of new molecules, one per line, is required in addition to the .prj file.

```python
{'fraction_non_alphanumeric': 0.08912488237666354, 'fraction_numerical': 0.01720661379217637, 'mean_word_length': 5.231155778894473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, 'lorem ipsum': 0, 'www.': 5, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1414087', 'n_tokens_mistral': 2410, 'n_tokens_neox': 2213, 'n_words': 882}