# TM_inter_helical_structural_features_alphafold
Use structural features to improve the performance of TM protein structures from Alphafold 2
### Create the conda environment 
conda env create -f environment.yml
### Activate the environment
conda activate atomic_pdb 
### source the package
source scripts/source.sh

### DeepHelicon data - PDB structures(.pdb files), Labels(.lb files), Helices (.xml with TM annotations), DeepHelicon predictions(.rr files)
- Available from  
	- https://www.sciencedirect.com/science/article/abs/pii/S1047847720301477?via%3Dihub
	- https://data.mendeley.com/datasets/k8tfvgftv3/1
	- https://github.com/2003100127/deephelicon

### Alphafold data 
- ./data/alphafold_structures/ - Alphafold2 predicted structures in PDB format 
- match_file_<dataset>.csv - Mapping of PDB name in DeepHelicon dataset to Alphafold 
- adjust_file_<dataset>.csv - Offset to align sequence in DeepHelicon dataset with Uniprot

### PDB structural features generate
- Example usage with pdbtm (TM positions determined using PDBTM annotations - TMDET), window 3, sequence separation 5, center excluded, only inter helical positions considered
- .pkl (pickled files) are generated for edge features, edge labels , deephelicon predictions, sequence names and sequence helix lengths
- I used the following naming convention:-
	- edge features - seq_edge_features_pdbtm_tm_zone_seq_sep_5_window_size_3_exclude_center_True_inter_helical_True.pkl
		- for every sequence, relevant contact positions and corresponding feature vector
	- edge labels  - seq_edge_labels_pdbtm_tm_zone_seq_sep_5_window_size_3_exclude_center_True_inter_helical_True.pkl
			- for every sequence, relevant contact positions and corresponding feature label
	- helix lengths - seq_helix_lengths_pdbtm_tm_zone_seq_sep_5_window_size_3_exclude_center_True_inter_helical_True.pkl
			- for every sequence, combined helical length - used for evaluation of L metrics 
	- sequence names - sequence_names_pdbtm_tm_zone_seq_sep_5_window_size_3_exclude_center_True_inter_helical_True.pkl
		- pdb names of sequences. Order in this array is the seq-id in other datastructures
	- deephelicon predictions - seq_deephelicon_predictions_pdbtm_tm_zone_seq_sep_5_window_size_3_exclude_center_True_inter_helical_True.pkl
		- for every sequence, relevant contact positions and corresponding deephelicon prediction
	- feature order - feature_order_pdbtm_tm_zone_seq_sep_5_window_size_3_exclude_center_True_inter_helical_True.pkl
		- order and name of features
- The datastructures are hand coded in the files that call them. Edit these if regenerating these
```
python -u src/pdb_structural_features_generate.py --feature_generate --output_folder ./outputs/structural_features/pdb/ --dataset train --labels_folder ./data/Labels/  --pdb_folder ./data/PDB/ --deephelicon_predictions ./data/Predictions/ --pdbtm_helix --helices_folder ./data/Helices/
```

### AlphaFold structural features generate 
```
python -u src/alphafold_structural_features_generate.py --feature_generate --output_folder ./outputs/structural_features/alphafold/ --dataset train --true_atomic_input_folder ./outputs/structural_features/pdb/ --alphafold_pdb_folder ./data/alphafold_structures/ --true_pdb_folder ./data/PDB/  --helices_folder ./data/Helices/ --pdbtm_helix  --match_file ./data/alphafold_structures/match_file_TRAIN.csv --adjust_pdb_file ./data/alphafold_structures/adjust_file_TRAIN.csv
```

### PDB coordinate features generate 
```
python -u src/pdb_coordinate_features_generate.py --feature_generate --output_folder ./outputs/coordinate_features/pdb/  --labels_folder ./data/Labels/ --pdb_folder ./data/PDB/ --dataset train --deephelicon_predictions_folder ./data/Predictions/ --pdbtm_helix --helices_folder ./data/Helices/
```


### AlphaFold coordinate features generate 
```
python -u src/alphafold_coordinate_features_generate.py --feature_generate  --output_folder ./outputs/coordinate_features/alphafold/ --dataset train  --deephelicon_predictions_folder ./data/Predictions/ --pdbtm_helix --helices_folder ./data/Helices/ --match_file ./data/alphafold_structures/match_file_TRAIN.csv --adjust_pdb_file ./data/alphafold_structures/adjust_file_TRAIN.csv --true_atomic_input_folder ./outputs/coordinate_features/pdb/  --alphafold_pdb_folder ./data/alphafold_structures/  --pdb_folder ./data/PDB/
```
### Classification - cross validation
- using structural features 
	- change the features to coordinate features for cross validation using coordinate features
```
python -u src/classification_experiment.py --cross_validation --dataset train --alphafold_input_folder ./outputs/structural_features/alphafold/ --true_atomic_input_folder ./outputs/structural_features/pdb/ --random_state 2458923456 --output_folder ./outputs/cross_validation_structural/ 
```
### Classification - Full - training on TRAIN and testing on TEST & PREVIOUS
- using coordinate features 
	- change the features to structural features for classification using structural features
```
python -u src/classification_experiment.py --classification --alphafold_input_folder ./outputs/coordinate_features/alphafold/ --true_atomic_input_folder ./outputs/coordinate_features/pdb/  --output_folder ./outputs/classification_coordinate/ --coordinate_features --mean_variance_calculate
```
### Classifier divergence
```
python -u src/classifier_divergence.py --classifier_divergence --dataset train --true_atomic_input_folder  ./outputs/coordinate_features/pdb/ --alphafold_input_folder  ./outputs/coordinate_features/alphafold/ --subtract_features
```
