#! /usr/bin/bash

# The initial position that contains data.sh and other files download from Zenodo should be located in READRetro/READRetro_data/(here)
# 1. Reorganize the folder system
# data
unzip data.zip


# result 
mkdir result

mv bionavi_clean.txt result
mv debug.txt result
mv g2s_laser.txt result
mv g2s_pathnum_2 result
mv graph2smiles_biochem.txt result
mv graph2smiles_clean.txt result
mv megan_bochem_iter100_failure_all.txt result
mv readretro_*.txt result
mv retroformer_*.txt result
mv retroformer_pathnum result


# model
mkdir model

unzip model_g2s.zip
unzip model_megan.zip
unzip model_retroformer.zip
unzip model_bionavi.zip

mv model_g2s model/g2s
mv model_megan model/mega
mv model_retroformer model/retroformer
mv model_bionavi model/bionavi


# scripts
mkdir scripts

# scripts - crossval
mkdir scripts/crossval
mkdir scripts/crossval/bionavi_crossval
mkdir scripts/crossval/g2s_crossval 
mkdir scripts/crossval/retroformer_crossval

unzip bionavi_biochem_star_1.zip
unzip bionavi_biochem_star_2.zip
unzip bionavi_biochem_star_3.zip
unzip bionavi_biochem_star_4.zip
unzip g2s_biochem_star_1.zip
unzip g2s_biochem_star_2.zip
unzip g2s_biochem_star_3.zip
unzip g2s_biochem_star_4.zip
unzip retroformer_biochem_star_1.zip
unzip retroformer_biochem_star_2.zip
unzip retroformer_biochem_star_3.zip
unzip retroformer_biochem_star_4.zip

mv bionavi_biochem_star_1 scripts/crossval/bionavi_crossval/biochem_star_1
mv bionavi_biochem_star_2 scripts/crossval/bionavi_crossval/biochem_star_2
mv bionavi_biochem_star_3 scripts/crossval/bionavi_crossval/biochem_star_3
mv bionavi_biochem_star_4 scripts/crossval/bionavi_crossval/biochem_star_4
mv g2s_biochem_star_1 scripts/crossval/g2s_crossval/biochem_star_1
mv g2s_biochem_star_2 scripts/crossval/g2s_crossval/biochem_star_2
mv g2s_biochem_star_3 scripts/crossval/g2s_crossval/biochem_star_3
mv g2s_biochem_star_4 scripts/crossval/g2s_crossval/biochem_star_4
mv retroformer_biochem_star_1 scripts/crossval/retroformer_crossval/biochem_star_1
mv retroformer_biochem_star_2 scripts/crossval/retroformer_crossval/biochem_star_2
mv retroformer_biochem_star_3 scripts/crossval/retroformer_crossval/biochem_star_3
mv retroformer_biochem_star_4 scripts/crossval/retroformer_crossval/biochem_star_4

# scripts - multistep_eval, pathnum, preprocessing, casestudy.sh
mkdir scripts/mutlistep_eval
mkdir scripts/pathnum
mkdir scripts/preprocessing

unzip scripts_multistep_eval.zip
unzip scripts_pathnum.zip
unzip scripts_preprocessing.zip

mv scripts_multistep_eval scripts/multistep_eval
mv scripts_pathnum scripts/pathnum
mv scripts_preprocessing scripts/preprocessing
mv scripts_casestudy.sh scripts/casestudy.sh

# scripts - singlestep_eval
mkdir scripts/singlestep_eval

unzip bionavi.zip
unzip ensemble.zip
unzip g2s.zip
unzip graphretro.zip
unzip megan.zip
unzip mhnreact.zip
unzip retroformer.zip
unzip rsmiles.zip

mv bionavi scripts/singlestep_eval
mv ensemble scripts/singlestep_eval
mv g2s scripts/singlestep_eval
mv graphretro scripts/singlestep_eval
mv megan scripts/singlestep_eval
mv mhnreact scripts/singlestep_eval
mv retroformer scripts/singlestep_eval
mv rsmiles scripts/singlestep_eval
mv sseval_singlestep_eval.py scripts/singlestep_eval/singlestep_eval.py

# 2. decompress all files for running READRetro
tar -zxvf data.tar.gz

cd scripts/crossval/bionavi_crossval
tar -zxvf biochem_star_1.tar.gz
tar -zxvf biochem_star_2.tar.gz
tar -zxvf biochem_star_3.tar.gz
tar -zxvf biochem_star_4.tar.gz
cd -

cd scripts/crossval/g2s_crossval
tar -zxvf biochem_star_1.tar.gz
tar -zxvf biochem_star_2.tar.gz
tar -zxvf biochem_star_3.tar.gz
tar -zxvf biochem_star_4.tar.gz
cd -

cd scripts/crossval/retroformer_crossval
tar -zxvf biochem_star_1.tar.gz
tar -zxvf biochem_star_2.tar.gz
tar -zxvf biochem_star_3.tar.gz
tar -zxvf biochem_star_4.tar.gz
cd -

cd scripts/singlestep_eval
tar -zxvf bionavi.tar.gz
tar -zxvf ensemble.tar.gz
tar -zxvf g2s.tar.gz
tar -zxvf graphretro.tar.gz
tar -zxvf megan.tar.gz
tar -zxvf mhnreact.tar.gz
tar -zxvf retroformer.tar.gz
tar -zxvf rsmiles.tar.gz
cd -

# 3. Set on READRetro
# For READRetro/retroformer/saved_models
mkdir ../retroformer/saved_models
cp -r model/retroformer/saved_models/* ../retroformer/saved_models

# For READRetro/g2s/saved_models
mkdir ../g2s/saved_models
cp -r model/g2s/saved_models/* ../g2s/saved_models

# For READRetro/data
mkdir ../data
cp -r data/multistep_data/* ../data

# For READRetro/result
mkdir ../result
cp -r result/* ../result

# For READRetro/scripts
mkdir ../scripts
cp -r scripts/* ../scripts