Deep Neural Network
Classifies structures from their TSR key frequencies using a feed-forward network, reporting accuracy, loss and a confusion matrix.
On this page
Overview
This tool treats TSR key frequencies as a feature vector and trains a feed-forward neural network to classify structures from them.
It runs in two steps: build the feature table from triplet files, then train on it.
BioTSR and this model
BioTSR can compute the keys and write a key-frequency table from Python:
biotsr.analysis.feature_matrix(samples).to_header_csv() gives a sample_id
column followed by one column per key, as in
tutorial 08, §3.
That table is not the one this model reads: key_frequency_drug.py writes
different columns, including the residue_type class column the model trains
on, and the two have not been tested together. To reproduce the published
model, use the research scripts as described below.
Installation
git clone https://github.com/KrishnaRauniyar/Nucleotide_Analysis.git
cd Nucleotide_Analysis/dnnCreate a virtual environment and install the dependencies:
python3 -m venv tsrenv
source tsrenv/bin/activate # macOS / Linux
tsrenv\Scripts\activate # Windows
pip install -r requirements.txtStep 1 — build the feature table
python key_frequency_drug.py -p triplets_directory -H yes| Option | Description |
|---|---|
-p | Directory containing the triplet files. |
-H | Whether to write a header row. Use yes here. |
The result is one row per structure, one column per key:
| Protein | key1 | key2 | key3 |
|---|---|---|---|
| 4NGF_H_15_U | 4 | 0 | 0 |
| 5VM9_D_3_A | 1 | 5 | 9 |
Each cell is how often that triplet key occurs in that structure.
Step 2 — train the model
python drug_model.py -p input_csv_fileArchitecture
Five hidden layers, each ReLU, narrowing 128 → 64 → 32 → 16 → 8, with L2 regularisation on all but the first. The output is a softmax layer.
| Layer | Units | Activation | Notes |
|---|---|---|---|
| Hidden 1 | 128 | ReLU | Input dimension is the number of key columns |
| Hidden 2 | 64 | ReLU | L2 regularisation |
| Hidden 3 | 32 | ReLU | L2 regularisation |
| Hidden 4 | 16 | ReLU | L2 regularisation |
| Hidden 5 | 8 | ReLU | L2 regularisation |
| Output | one per class | softmax | Sized from the data, not fixed |
Categorical columns are label-encoded and features are standardised before training. The model uses the Adam optimiser with sparse categorical cross-entropy, trains for up to 50 epochs at batch size 32 against a held-out split, and stops early when validation stops improving.
Output
Three image files:
| File | Contents |
|---|---|
accuracy_plot.png | Training and validation accuracy per epoch |
loss_plot.png | Training and validation loss per epoch |
confusion_matrix.png | Confusion matrix for the held-out data |
Source code
Nucleotide_Analysis (opens on GitHub)
Research code
The model and its input preparation live in the `dnn/` directory of this repository.
Licence No licence stated