File size: 654 Bytes
49c5855
 
 
 
 
 
 
 
3f03685
49c5855
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import torch

def validate_sequence(sequence):
    valid_amino_acids = set("ACDEFGHIKLMNPQRSTVWY")  # 20 standard amino acids
    return all(aa in valid_amino_acids for aa in sequence) and len(sequence) <= 200

def load_model():
    # Assuming the model is a simple PyTorch model, adjust the path as needed
    model = torch.load('model.pth', map_location=torch.device('cpu'))
    model.eval()
    return model

def predict(model, sequence):
    # Dummy tensor conversion, replace with your actual model's input handling
    tensor = torch.tensor([ord(char) for char in sequence], dtype=torch.float32)
    output = model(tensor)
    return output.item()