File size: 1,527 Bytes
cf004a6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
"""
In this file, the input functions for query and support set molecules are defined.
Input is assumed to be either a SMILES string, a list of SMILES strings, or a pandas
dataframe.
"""
#---------------------------------------------------------------------------------------
# Dependencies
import pandas as pd
from typing import List
import torch
from src.data_preprocessing.create_descriptors import preprocess_molecules
#---------------------------------------------------------------------------------------
# Define main functions
def create_query_input(smiles_input: [str, List[str], pd.DataFrame]):
"""
This function creates the input for the query molecules.
"""
# Create vector representation
numpy_vector_representation = preprocess_molecules(smiles_input)
assert len(numpy_vector_representation.shape) == 2
# Create pytorch tensor
tensor = torch.from_numpy(numpy_vector_representation).unsqueeze(1).float()
return tensor
def create_support_set_input(smiles_input: [str, List[str], pd.DataFrame]):
"""
This function creates the input for the support set molecules.
"""
# Create vector representation
numpy_vector_representation = preprocess_molecules(smiles_input)
assert len(numpy_vector_representation.shape) == 2
size = numpy_vector_representation.shape[0]
# Create pytorch tensors
tensor = torch.from_numpy(numpy_vector_representation).unsqueeze(0).float()
size = torch.tensor(size)
return tensor, size |