Views
No views yet
PDeepPP is a hybrid protein language model designed to predict post-translational modification (PTM) sites and extract biologically relevant features from protein sequences. By leveraging pretrained embeddings from ESM and incorporating both transformer and convolutional neural network (CNN) architectures, PDeepPP provides a robust framework for analyzing protein sequences in various contexts.PDeepPP is a flexible model architecture that integrates the power of transformer-based self-attention mechanisms with convolutional operations for capturing local and global sequence features. The model consists of:transformers library, allowing seamless integration with other tools and workflows.PDeepPP was developed and validated using PTM and BPS datasets, but its applications are not limited to these specific tasks. Leveraging its flexible architecture and robust feature extraction capabilities, PDeepPP can be applied to a wide range of protein sequence-related analysis tasks. Specifically, the model has been validated on the following datasets:PDeepPP’s architecture enables users to generalize and extend its capabilities to other protein sequence analysis tasks, such as embedding generation, sequence classification, or task-specific analyses.PDeepPP is trained on PTM and BPS datasets, demonstrating its effectiveness in identifying specific sequence features (e.g., post-translational modification sites) and extracting biologically relevant regions.PDeepPP to other protein sequence-based tasks by customizing input data and task objectives.PDeepPP, you need to install the required dependencies, including torch and transformers:1pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
2pip install transformersDataProcessor and Pretraining files are in the same directory as the example file.
Here is an example of how to use PDeepPP to process protein sequences and obtain predictions:1import torch
2import esm
3from DataProcessor_pdeeppp import PDeepPPProcessor
4from Pretraining_pdeeppp import PretrainingPDeepPP
5from transformers import AutoModel
6
7# Global parameter settings
8device = torch.device("cpu")
9pad_char = "X" # Padding character
10target_length = 33 # Target length for sequence padding
11mode = "BPS" # Mode setting (only configured in example.py)
12esm_ratio = 1 # Ratio for ESM embeddings
13
14# Load the PDeepPP model
15model_name = "fondress/PDeepPP_TTCA"
16model = AutoModel.from_pretrained(model_name, trust_remote_code=True) # Directly load the model
17
18# Initialize the PDeepPPProcessor
19processor = PDeepPPProcessor(pad_char=pad_char, target_length=target_length)
20
21# Example protein sequences (test sequences)
22protein_sequences = ["VELYP", "YPLDL", "ESHINQKWVCK"]
23
24# Preprocess the sequences
25inputs = processor(sequences=protein_sequences, mode=mode, return_tensors="pt") # Dynamic mode parameter
26processed_sequences = inputs["raw_sequences"]
27
28# Load the ESM model
29esm_model, esm_alphabet = esm.pretrained.esm2_t33_650M_UR50D()
30esm_model = esm_model.to(device)
31esm_model.eval()
32
33# Initialize the PretrainingPDeepPP module
34pretrainer = PretrainingPDeepPP(
35 embedding_dim=1280,
36 target_length=target_length,
37 esm_ratio=esm_ratio,
38 device=device
39)
40
41# Extract the vocabulary and ensure the padding character 'X' is included
42vocab = set("".join(protein_sequences))
43vocab.add(pad_char) # Add the padding character
44
45# Generate pretrained features using the PretrainingPDeepPP module
46pretrained_features = pretrainer.create_embeddings(
47 processed_sequences, vocab, esm_model, esm_alphabet
48)
49
50# Ensure pretrained features are on the same device
51inputs["input_embeds"] = pretrained_features.to(device)
52
53# Perform prediction
54model.eval()
55outputs = model(input_embeds=inputs["input_embeds"]) # Use pretrained features as model input
56logits = outputs["logits"]
57
58# Compute probability distributions and generate predictions
59softmax = torch.nn.Softmax(dim=-1) # Apply softmax on the last dimension
60probabilities = softmax(logits)
61predicted_labels = (probabilities >= 0.5).long()
62
63# Print the prediction results for each sequence
64print("\nPrediction Results:")
65for i, seq in enumerate(processed_sequences):
66 print(f"Sequence: {seq}")
67 print(f"Probability: {probabilities[i].item():.4f}")
68 print(f"Predicted Label: {predicted_labels[i].item()}")
69 print("-" * 50)PDeepPP supports fine-tuning on custom datasets. The model uses a configuration class (PDeepPPConfig) to specify hyperparameters such as:PDeepPPConfig for details.PDeepPP in your research, please cite the associated paper or repository:@article{your_reference,
title={`PDeepPP`: A Hybrid Model for Protein Sequence Analysis},
author={Author Name},
journal={Journal Name},
year={2025}
}