<jupyter_start><jupyter_text>Imports<jupyter_code>import importlib
from matplotlib.pyplot import figure
from AIBind.import_modules import *
from AIBind import AIBind
importlib.reload(AIBind)<jupyter_output><empty_output><jupyter_text>GPU Settings<jupyter_code>str(subprocess.check_output('nvidia-smi', shell = True)).split('\\n')
os.environ["CUDA_VISIBLE_DEVICES"] = "1"<jupyter_output><empty_output><jupyter_text>VecNet Object Definition<jupyter_code># Read In drugs and targets dataframes to pass to AIBind after changing column names 
with open('/root/data/chemicals_01_w_embed.pkl', 'rb') as file: 
    drugs = pkl.load(file)
    
with open('/root/data/amino_01_w_embed.pkl', 'rb') as file: 
    targets = pkl.load(file)

# Ensure correct column names    
drugs = drugs.rename(columns = {'Label' : 'InChiKey'})
targets = targets.rename(columns = {'Label' : 'target_aa_code'})
targets_test = []
targets_validation = []
edges_test = []
edges_validation = []
train_sets = []

for run_number in tqdm(range(5)):
    
    targets_test.append(pd.read_csv('/root/data/test_unseen_nodes_' + str(run_number) + '.csv'))
    edges_test.append(pd.read_csv('/root/data/test_unseen_edges_' + str(run_number) + '.csv'))    
    targets_validation.append(pd.read_csv('/root/data/validation_unseen_nodes_' + str(run_number) + '.csv'))    
    edges_validation.append(pd.read_csv('/root/data/validation_unseen_edges_' + str(run_number) + '.csv'))    
    train_sets.append(pd.read_csv('/root/data/train_' + str(run_number) + '.csv'))    
vecnet_object = AIBind.AIBind(interactions_location = '/root/data/Network_Derived_Negatives.csv',
                              interactions = None,
                              interaction_y_name = 'Y',

                              absolute_negatives_location = None,
                              absolute_negatives = None,

                              drugs_location = None,
                              drugs_dataframe = drugs,
                              drug_inchi_name = 'InChiKey',
                              drug_smile_name = 'SMILE',

                              targets_location = None,
                              targets_dataframe = targets, 
                              target_seq_name = 'target_aa_code',

                              mol2vec_location = None,
                              mol2vec_model = None,

                              protvec_location = None, 
                              protvec_model = None,

                              nodes_test = targets_test, 
                              nodes_validation = targets_validation, 

                              edges_test = edges_test, 
                              edges_validation = edges_validation, 

                              model_out_dir = '/root/data/',

                              debug = False)<jupyter_output><empty_output><jupyter_text>Loading Pre-trained VecNet<jupyter_code>with open('/root/data/VecNet_unseen_nodes.pickle', 'rb') as file:
    vecnet_object = pkl.load(file) 
vecnet_object.mol2vec_location = '/root/data/model_300dim.pkl',
vecnet_object.protvec_location = '/root/data/protVec_100d_3grams.csv',

vecnet_object.protvec_model = pd.read_csv('/root/data/protVec_100d_3grams.csv', delimiter = '\t')
vecnet_object.mol2vec_model = word2vec.Word2Vec.load('/root/data/model_300dim.pkl')
# Unzip the models into the right folders
# Can run directly in shell too
try: 
    subprocess.check_output('mkdir /root/data/vecnet-final/; cd /root/data/vecnet-final; unzip ../vecnet-final.zip', shell = True)
except: 
    None

# Update model paths 
for _model, _path in vecnet_object.model_out_dir.items():
    vecnet_object.model_out_dir[_model] = '/root/data/' + _path.split('/')[-2] + '/'
    
vecnet_object.drugs_dataframe = drugs
vecnet_object.targets_dataframe = targets
vecnet_object.get_protvec_embeddings()
vecnet_object.get_mol2vec_embeddings()<jupyter_output><empty_output><jupyter_text>Prediction<jupyter_code>## Expected to have 'InChiKey', 'SMILE', and 'target_aa_code'

nodes_df = pd.read_csv('some_csv_file_path')

# Example entries
#nodes_df['InChiKey'] = ['<KEY>']
#nodes_df['SMILE'] = ['C1=CC=C(C=C1)C=O']
#nodes_df['target_aa_code'] = sars_targets['Sequence'].tolist()[0]
unseen_nodes_example_5fold_average = vecnet_object.get_fold_averaged_prediction_results(model_name = None,
                                                                                     version_number = None,
                                                                                     model_paths = [],
                                                                                     optimal_validation_model = None,
                                                                                     test_sets = [targets_test[1].dropna()],
                                                                                     get_drug_embed = True,
                                                                                     get_target_embed = True,
                                                                                     drug_filter_list = [],
                                                                                     target_filter_list = [],
                                                                                     return_dataframes = True )<jupyter_output>Testing on model :  /root/data/vecnet-final/Run_0/vecnet_ds2_5_fold_unseen_nodes_v00_run0_07-13_15h58_epoch_19_idx_0.model
filtered_nodes_test :  (122, 11)
Drugs :  98
Targets :  71
{'fraction_non_alphanumeric': 0.09852038975099242, 'fraction_numerical': 0.010645976181883796, 'mean_word_length': 1.8208651399491094, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 27, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '576665', 'license': 'MIT', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1558, 'n_words': 235, 'path': 'VecNet-User-Frontend.ipynb', 'repo_name': 'ChatterjeeAyan/AI-Bind', 'size': '5564'}