main#
Functions
|
Seed all necessary random number generators. |
|
Print a message to the console with optional color formatting. |
|
Main entry point for training the BRIDGE model. |
- main.log_print(text, color=None, on_color=None, attrs=None)[source]#
Print a message to the console with optional color formatting.
This utility function attempts to use third-party libraries (termcolor and pycrayon) to produce colored or styled console output. If these libraries are not available, it gracefully falls back to standard print without formatting.
- Parameters:
text (str) – The message to be printed to the console.
color (str, optional) – Text color name supported by termcolor (e.g., ‘red’, ‘green’). If None, the default terminal color is used.
on_color (str, optional) – Background color name supported by termcolor (e.g., ‘on_blue’, ‘on_yellow’).
attrs (list of str, optional) – List of text attributes supported by termcolor, such as [‘bold’, ‘underline’].
- main.main(args)[source]#
Main entry point for training the BRIDGE model.
- This function orchestrates the full training pipeline, including:
random seed initialization
device (CPU/GPU) configuration
data loading and preprocessing
sequence embedding extraction using a pretrained transformer
construction of structural, biochemical, and motif prior features
dataset splitting and DataLoader creation
model training, validation, learning-rate scheduling, and early stopping
model checkpointing and performance reporting
persistent logging/config/metrics under results/{logs,model,metrics}
- Parameters:
args (argparse.Namespace) – Parsed command-line arguments specifying runtime configuration. Expected attributes include (but are not limited to):
- seedint
Random seed for reproducibility.
- use_cpubool
Whether to force CPU execution.
- device_numint
GPU device index to use when CUDA is available.
- trainbool
Whether to run the training procedure.
- data_filestr
Dataset identifier used to locate input files.
- data_pathstr
Root directory containing input FASTA and feature files.
- Transformer_pathstr
Path to the pretrained RBPformer model.
- lrfloat
Initial learning rate for the optimizer.
- early_stoppingint
Number of epochs without improvement before early stopping.