Method and apparatus for generating sequences of phage genomic elements
By employing feature extraction and biological function feedback reinforcement learning methods, the problems of low efficiency and insufficient functionality in phage genome sequence generation were solved, and phage genome element sequence generation guided by target biological function was achieved.
Patent Information
- Application Number
- CN202610359617.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-23
- Publication Date
- 2026-06-30
Smart Images

Figure CN122314093A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of bioinformatics technology, specifically to a method and apparatus for generating sequences of bacteriophage genome elements. Background Technology
[0002] With the increasing severity of bacterial resistance, the effectiveness of traditional antibiotics remains limited. Phage therapy, with its high host specificity and safety profile, has become an important alternative technology for combating drug-resistant bacterial infections. Therefore, designing and modifying the phage genome sequence to obtain engineered phages that meet application requirements is a key technological step in realizing the practical application of phage therapy.
[0003] Existing phage genome sequence generation technologies all model extremely long phage genomes using single base pairs as basic units. Due to the excessive sequence length, these models struggle to efficiently learn features and construct sequences, resulting in poor efficiency and stability in both sequence modeling and generation. Furthermore, the sequence generation process is not regulated in conjunction with the biological functional characteristics of the phage, leading to generated sequences that fail to meet the functional and activity requirements for practical applications. Therefore, existing technologies suffer from difficulties in modeling extremely long sequences and insufficient functionality of the generated sequences, failing to meet the needs of efficient research and development of engineered phages.
[0004] The preceding description is intended to provide general background information and does not necessarily constitute prior art. Summary of the Invention
[0005] This application provides a method and apparatus for generating phage genome element sequences, which can achieve target biological function-oriented phage genome element sequence generation, improving the effectiveness and functionality of sequence generation.
[0006] In a first aspect, embodiments of this application provide a method for generating sequences of bacteriophage genome elements, including: Sequence data of phage genome element samples are obtained, and features are extracted from the sequence data to obtain a global feature vector of uniform dimension; Based on the global feature vector, a phage element sequence generation model is constructed and trained to learn the natural distribution pattern and contextual dependencies of phage element sequences. A reward model based on biological function feedback is constructed to evaluate the biological quality of phage element sequences; The evaluation results of the reward model are used as feedback signals to perform reinforcement learning optimization on the trained phage element sequence generation model, generating phage element sequences that conform to the target biological function.
[0007] Furthermore, in some embodiments of this application, the step of obtaining sequence data of bacteriophage genomic element samples and performing feature extraction on the sequence data to obtain a global feature vector of uniform dimension includes: The obtained phage genome element sequences are input into a pre-trained deep learning sequence representation model to obtain the initial feature tensor corresponding to each element; The initial feature tensor is divided according to a preset block length, and each element sequence is divided into several local feature blocks of fixed length. Each local feature block is sequentially input into a convolutional neural network and a channel space attention mechanism module for intra-block feature extraction. The first feature output by the convolutional neural network and the second feature output by the channel space attention mechanism module are added and fused to obtain a block-level feature vector that fuses local multi-scale information and key channel space features. After adding positional encoding to the block-level feature vectors corresponding to each local feature block, the input is given to the Transformer encoder for global context modeling to obtain a context feature sequence that captures long-range dependencies between blocks. The context feature sequence is input into the attention pooling layer for weighted fusion to generate a global feature vector of uniform dimension.
[0008] Furthermore, in some embodiments of this application, the pre-trained deep learning sequence representation model is the Evo2 model; the dimension of the initial feature tensor is represented as [element base sequence length, 4096], where the element base sequence length is a variable value and 4096 is the number of feature channels.
[0009] Furthermore, in some embodiments of this application, the step of sequentially inputting each local feature block into a convolutional neural network and a channel spatial attention mechanism module for intra-block feature extraction, and then adding and fusing the first feature output by the convolutional neural network and the second feature output by the channel spatial attention mechanism module to obtain a block-level feature vector that fuses local multi-scale information and key channel spatial features, includes: Each local feature block is input into a multi-layer convolutional neural network for multi-scale feature extraction to obtain a sequence of local feature maps under different receptive fields. The local feature map sequence is input into the channel attention module and the spatial attention module respectively to obtain the channel attention weights and the spatial attention weights; The channel attention weights are weighted sequentially with the local feature map sequence to obtain channel-enhanced features; The spatial attention weights are weighted with the local feature map sequence on a spatial location basis to obtain spatial enhancement features; The channel enhancement features and the spatial enhancement features are added and fused element by element to obtain dual attention enhancement features; The dual-attention enhancement features are residually concatenated with the original local features output by the convolutional neural network to obtain the final block-level feature vector.
[0010] Furthermore, in some embodiments of this application, the step of constructing and training a phage element sequence generation model based on the global feature vector to learn the natural distribution pattern and contextual dependencies of phage element sequences includes: An autoregressive neural network based on the Transformer architecture is constructed as the initial sequence generation model, and the global feature vector is used as the input to the embedding layer of the initial sequence generation model. A dataset of natural phage element sequences was obtained, and the initial sequence generation model was pre-trained using an autoregressive language modeling task to optimize the model’s ability to predict the next element, thus obtaining a pre-trained model. A sequence completion training task is constructed by dividing the component sequence into a prompt part and a part to be completed according to a preset ratio. The prompt part is input into the pre-trained model, and the probability distribution of the model generating the part to be completed under the given prompt conditions is optimized to obtain a supervised fine-tuned sequence generation model.
[0011] Furthermore, in some embodiments of this application, a category smoothing loss function is introduced during sequence completion training; the category smoothing loss function is: calculating cross-entropy loss based on the distribution of component functional category labels, and assigning a preset probability weight to all components within the functional category of the real component for the real component, so as to enhance the model's generalization ability to similar functional components.
[0012] Furthermore, in some embodiments of this application, the preset probability weight is controlled by a category smoothing coefficient, which is 0.7; the element functional category includes at least one or more of the following: head morphogenesis coding element, DNA packaging coding element, tail assembly coding element, and host lysis coding element.
[0013] Furthermore, in some embodiments of this application, the construction of a reward model based on biological function feedback, wherein the reward model is used to evaluate the biological quality of phage element sequences, includes: Using a supervised fine-tuned sequence generation model, multiple candidate phage element completion sequences are generated for multiple different input prompts to construct a candidate sequence pool; Bioinformatics tools are used to assess the biological quality of each sequence in the candidate sequence pool, and activity assessment indicators and key functional element content of each sequence are obtained. Based on the activity evaluation index and the inclusion of the key functional elements, the sequences in the candidate sequence pool are compared pairwise to construct a preference dataset containing multiple preference relationship labels, which are used to indicate that the biological quality of the first sequence is better than that of the second sequence. An initial reward model is constructed, and the initial reward model is trained using the preference dataset and preference learning algorithm to obtain a trained reward model; the trained reward model is used to output the corresponding biological quality score for any input phage element sequence.
[0014] Furthermore, in some embodiments of this application, when constructing the preference dataset, the activity evaluation index is preferentially used as the primary comparison basis; when the activity evaluation index is the same, the key functional element inclusion rate is used as the secondary comparison basis.
[0015] Furthermore, in some embodiments of this application, the key functional elements include at least one or more of tail protein-coding elements, head protein-coding elements, and lyase-coding elements.
[0016] Furthermore, in some embodiments of this application, after invoking bioinformatics tools to perform biological quality assessment on each sequence in the candidate sequence pool, the method further includes: The sequences in the candidate sequence pool are combined in pairs to obtain multiple sequence pairs; For each sequence pair, calculate the difference in activity evaluation metrics between the two sequences to obtain the activity difference; calculate the difference in the inclusion rate of key functional elements between the two sequences to obtain the element difference. When the absolute value of the activity difference is less than a preset activity difference threshold and the absolute value of the element difference is less than a preset element difference threshold, the sequence pair is determined to be a fuzzy preference pair and the sequence pair is removed from the preference dataset. Sequence pairs whose activity difference or element difference is greater than the corresponding threshold are retained as the final preference dataset for training the reward model.
[0017] Furthermore, in some embodiments of this application, the step of using the evaluation results of the reward model as a feedback signal to perform reinforcement learning optimization on the trained phage element sequence generation model to generate phage element sequences that conform to the target biological function includes: The supervised fine-tuned sequence generation model is used as the policy model to be optimized, and the parameters of the policy model to be optimized are frozen and copied to obtain a reference policy model. For each input prompt in the current batch, the current strategy model is used to perform multiple samplings to generate a set of output sequences; The set of output sequences is input into the trained reward model, and the reward value corresponding to each output sequence is calculated. Based on the reward values of all output sequences within the same group, the mean and standard deviation of the reward values within the group are calculated, and the reward value of each output sequence is standardized to obtain the relative advantage value of each output sequence. Based on the relative advantage value, a policy optimization objective function is constructed to maximize the probability of generating a high relative advantage value sequence. A KL divergence constraint term is introduced to limit the difference between the current policy model and the reference policy model, thereby obtaining an optimized loss function. The sampling, reward calculation, advantage value calculation, and parameter update processes are iteratively executed until the sequence generated by the current policy model reaches the preset convergence condition in the reward value distribution, and the optimized target sequence generation model is output.
[0018] Furthermore, in some embodiments of this application, the step of using the evaluation results of the reward model as a feedback signal to perform reinforcement learning optimization on the trained phage element sequence generation model to generate phage element sequences that conform to the target biological function further includes: The mean and variance of the reward value for each output sequence are calculated in real time to obtain the reward distribution characteristics; The sampling frequency is dynamically adjusted based on the reward distribution characteristics. When the variance of the reward value is greater than the preset variance threshold, the sampling frequency of the current input prompt is increased; when the variance of the reward value is less than the preset variance threshold, the sampling frequency of the current input prompt is decreased. The weight coefficient of the KL divergence constraint term is dynamically adjusted according to the reward distribution characteristics. When the KL divergence between the current strategy model and the reference strategy model exceeds a preset divergence threshold, the weight coefficient is increased; when the KL divergence is lower than the preset divergence threshold, the weight coefficient is decreased.
[0019] Furthermore, in some embodiments of this application, the phage genome element includes coding elements and non-coding elements; the coding elements are divided based on different positions and biological functions of the phage biological structure, and include at least one or more of head morphogenesis coding elements, DNA packaging coding elements, tail assembly coding elements, and host lysis coding elements; the non-coding elements are base sequence regions for which no specific biological function has been detected.
[0020] Furthermore, in some embodiments of this application, the method further includes: Input the partial phage element sequence to be modified into the optimized target sequence generation model to generate a complete candidate target phage element sequence; The biological rationality of the candidate target bacteriophage element sequences was verified using bioinformatics comparison tools, and the verification results were obtained. The integrity of the candidate target phage element sequence was assessed using an activity assessment tool to obtain the assessment results; Based on the verification and evaluation results, sequences that meet the preset biological activity threshold are selected as the final engineered phage element sequences.
[0021] Secondly, embodiments of this application provide a sequence generation apparatus for bacteriophage genome elements, comprising: The representation learning module is used to acquire sequence data of phage genome element samples and extract features from the sequence data to obtain a global feature vector of uniform dimension. The supervised training module is used to construct and train a phage element sequence generation model based on the global feature vector, so as to learn the natural distribution pattern and contextual dependencies of phage element sequences; A reward model construction module is used to construct a reward model based on biological function feedback, which is used to evaluate the biological quality of phage element sequences; An optimization module is used to optimize the trained phage element sequence generation model by using the evaluation results of the reward model as a feedback signal, thereby generating phage element sequences that conform to the target biological function.
[0022] This application provides a method and apparatus for generating phage genome element sequences. First, feature extraction is performed on phage genome element sample sequence data to obtain a global feature vector of uniform dimension, providing a standardized feature input basis for subsequent model training. Then, a phage element sequence generation model is constructed and trained based on these features, enabling the model to effectively learn the natural distribution patterns and contextual dependencies of phage element sequences, ensuring that the generated sequences conform to the inherent rules of the phage genome. Subsequently, a reward model based on biological function feedback is constructed to provide an objective evaluation basis for sequence quality. Finally, the evaluation results of the reward model are used as feedback signals to perform reinforcement learning optimization on the sequence generation model, ensuring that the sequence generation process is always adjusted towards the target biological function. Therefore, by extracting uniform global features from phage genome element sequences, training the sequence generation model, and performing reinforcement learning optimization based on the biological function reward model, this application can generate phage genome element sequences that both conform to the natural sequence rules of phages and meet the requirements of the target biological function, achieving targeted and efficient generation of phage genome element sequences, thereby improving the effectiveness and functionality of sequence generation. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is an application environment diagram of the phage genome element sequence generation method provided in the embodiments of this application; Figure 2 This is a flowchart illustrating the method for generating sequences of bacteriophage genome elements provided in this application embodiment; Figure 3 This is a flowchart illustrating the dimensionality reduction model provided in the embodiments of this application; Figure 4 This is a schematic diagram of the process for phage element sequence completion and modification provided in the embodiments of this application; Figure 5 This is a schematic diagram of the structure of the phage genome element sequence generation device provided in the embodiments of this application; Figure 6 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0025] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of systems and methods consistent with those detailed in the appended claims or with some aspects of this application.
[0026] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover descriptions such as non-exclusive inclusion, so that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, components, features, and elements with the same names in different embodiments of this application may have the same meaning or different meanings, the specific meaning of which must be determined by its interpretation in that specific embodiment or further in conjunction with the context of that specific embodiment.
[0027] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0028] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.
[0029] To address the aforementioned technical problems and overcome the shortcomings of existing technologies, this application provides a method and apparatus for generating phage genome elements sequences, which can achieve target biological function-oriented phage genome element sequence generation, thereby improving the effectiveness and functionality of sequence generation.
[0030] Figure 1 This is a diagram illustrating the application environment of a phage genome element sequence generation method in one embodiment. (Refer to...) Figure 1 This method for generating phage genome elements is applied to a phage genome element sequence generation system. The system includes a terminal 110 and a server 120. The terminal 110 and server 120 are connected via a network. The terminal 110 can be a desktop terminal or a mobile terminal, specifically a mobile phone, tablet computer, laptop computer, or at least one of these. The server 120 can be a standalone server or a server cluster consisting of multiple servers. The server 120 is configured to execute the aforementioned phage genome element sequence generation method, including: acquiring sequence data of phage genome element samples and extracting features from the sequence data to obtain a global feature vector of uniform dimension; constructing and training a phage element sequence generation model based on the global feature vector to learn the natural distribution pattern and contextual dependencies of the phage element sequences; constructing a reward model based on biological function feedback, which is used to evaluate the biological quality of the phage element sequences; and using the evaluation results of the reward model as feedback signals to perform reinforcement learning optimization on the trained phage element sequence generation model to generate phage element sequences that conform to the target biological function.
[0031] Please see Figure 2 , Figure 2 This is a schematic flowchart of a method for generating phage genome elements according to an embodiment of this application. This embodiment mainly uses the application of this method for generating phage genome elements in a computer device as an example for illustration. The method for generating phage genome elements according to an embodiment of this application may specifically include the following steps: S1. Obtain sequence data of phage genome element samples, and extract features from the sequence data to obtain a global feature vector of uniform dimension; Furthermore, in some embodiments, the phage genome element includes coding elements and non-coding elements; the coding elements are divided based on different positions and biological functions of the phage biological structure, and include at least one or more of head morphogenesis coding elements, DNA packaging coding elements, tail assembly coding elements, and host lysis coding elements; the non-coding elements are base sequence regions for which no specific biological function has been detected. Specifically, for step S1, phage genome element samples containing various coding and non-coding elements are collected and processed to obtain complete raw sequence data. Subsequently, feature extraction is performed on this sequence data to uncover the core structural and functional features contained within the sequence. The extracted features are then standardized and normalized to eliminate differences in feature dimensions and representations between different element sequences, ultimately obtaining a globally consistent feature vector suitable for subsequent model use, providing a standardized feature input foundation for building the sequence generation model. For example, phage genome element samples targeting drug-resistant Acinetobacter baumannii are collected. Their sequence data covers four types of coding elements: head morphogenesis, DNA packaging, tail assembly, and host lysis, as well as corresponding non-coding base sequence regions. After feature extraction and standardization, a globally consistent feature vector is obtained.
[0032] It should be noted that the purpose of obtaining a global feature vector with a unified dimension in this embodiment is to unify and reduce the dimension. By reducing different high dimensions to the same low dimension, the DNA sequence of the element is represented as a low-dimensional representation vector with a unified dimension, thereby achieving the standardization and regularization of the sequence features of the bacteriophage genome element and providing a stable and unified feature input basis for subsequent sequence-related processing.
[0033] S2. Based on global feature vectors, construct and train a phage element sequence generation model to learn the natural distribution pattern and contextual dependencies of phage element sequences; Specifically, for step S2, a model framework adapted for generating phage genome element sequences is built based on the obtained unified-dimensional global feature vector as input. Phage natural element sequence data, including both coding and non-coding elements, are input into this model for training. During training, the model continuously learns the natural distribution patterns of natural phage element sequences, while accurately capturing the contextual relationships between different coding elements and between coding and non-coding elements. This gradually forms a complete understanding of the combination rules of phage element sequences, ultimately enabling the model to autonomously generate phage element sequences that conform to the characteristics of natural sequences. For example, by inputting the global feature vector into the constructed sequence generation model and training with a large number of samples, the model learns the combination rules of head morphogenesis coding elements and DNA packaging coding elements, as well as the contextual dependencies such as the arrangement logic of coding and non-coding elements.
[0034] S3. Construct a reward model based on biological function feedback, which is used to evaluate the biological quality of phage element sequences; Specifically, for step S3, a reward model specifically designed to assess sequence biological quality is built, guided by the biological function of phage genomic elements. This reward model uses functional indicators such as the functional integrity of phage coding elements and the overall biological activity of the sequence as core feedback criteria. It can objectively and accurately assess the biological quality of any phage element sequence containing both coding and non-coding elements, providing clear and reliable evaluation standards for optimizing the sequence generation model and ensuring that the evaluation results align with the functional requirements of actual phage applications. For example, a reward model based on the functional integrity of coding elements and phage infection activity can comprehensively score and evaluate the biological quality of phage sequences containing various functional coding and non-coding elements. It should be noted that in this embodiment, biological quality mainly refers to phage activity, i.e., whether the synthesized phage can survive.
[0035] S4. Using the evaluation results of the reward model as feedback signals, the trained phage element sequence generation model is optimized through reinforcement learning to generate phage element sequences that conform to the target biological function. Specifically, for step S4, the previously trained phage element sequence generation model is used as the base model to be optimized, and the sequence biological quality assessment result output by the reward model is used as the core feedback signal. Reinforcement learning is employed to iteratively adjust the generation model. Based on the feedback signal, the phage element sequence generation model continuously optimizes its sequence generation strategy and logic, constantly moving towards the preset target biological function, ultimately generating stable phage genome element sequences that simultaneously contain compliant coding and non-coding elements and fully conform to the target biological function. For example, with the goal of improving phage host lysis function, the generation model is continuously optimized through the evaluation feedback of the reward model, ultimately generating phage genome element sequences containing complete host lysis coding elements and meeting the biological function requirements.
[0036] This embodiment first acquires phage genome element sequence data covering both coding and non-coding elements, extracts global feature vectors of a unified dimension, and then trains a sequence generation model based on these features to grasp the natural distribution and context-dependent patterns of sequences. Next, a biological function-oriented reward model is constructed to provide objective evaluation criteria. Finally, the generation model is optimized through reinforcement learning using reward feedback. This approach can stably generate phage genome element sequences that conform to both natural sequence distribution patterns and target biological functions, providing an efficient and feasible path for the targeted modification of phage genomes.
[0037] Furthermore, in some embodiments, step S1, "acquiring sequence data of phage genomic element samples and extracting features from the sequence data to obtain a global feature vector of uniform dimension," may specifically include: S11. Input the obtained phage genome element sequences into a pre-trained deep learning sequence representation model to obtain the initial feature tensor corresponding to each element; further, in some embodiments, the pre-trained deep learning sequence representation model is the Evo2 model; the dimension of the initial feature tensor is represented as [element base sequence length, 4096], where the element base sequence length is a variable value and 4096 is the number of feature channels.
[0038] Specifically, in step S11, the previously collected phage genome element sequences are input into a pre-trained deep learning sequence representation model. The model comprehensively encodes and vectorizes the intrinsic biological characteristics of the element sequences, outputting an initial feature tensor that fully preserves the original information of the element sequences. The pre-trained deep learning sequence representation model used is the Evo2 model, and the generated initial feature tensor is a two-dimensional structure with dimensions [element base sequence length, 4096]. The element base sequence length varies with the actual sequence length of different elements, and 4096 is a fixed number of feature channels, which can comprehensively preserve the structural and functional features of the element sequences. For example, if the phage head morphogenetic encoding element sequence is input into the Evo2 model, and the actual base length of this element is 900, an initial feature tensor with dimensions [900, 4096] can be obtained, fully preserving all the sequence feature information of the encoded element.
[0039] S12. Divide the initial feature tensor according to the preset block length, and divide each element sequence into several local feature blocks of fixed length; Specifically, in step S12, the obtained initial feature tensor is standardized and segmented according to a pre-set fixed block length, dividing the originally inconsistent initial feature tensor into multiple local feature blocks of uniform length. This block-based processing unifies the feature processing units, solving the problem of non-standardized feature extraction and high processing difficulty caused by large differences in the lengths of different element sequences, and providing a standardized processing object for subsequent intra-block feature extraction. For example, if the preset block length is 500, and the initial feature tensor length of a certain phage DNA packaging coding element is 1300, it can be divided into two standard local feature blocks of length 500 and one local feature block of length 300, all converted into fixed-length feature processing units.
[0040] S13. Each local feature block is sequentially input into the convolutional neural network and the channel space attention mechanism module for intra-block feature extraction. The first feature output by the convolutional neural network and the second feature output by the channel space attention mechanism module are added and fused to obtain a block-level feature vector that fuses local multi-scale information and key channel space features. Specifically, in step S13, a single local feature block is first fed into a convolutional neural network to extract local multi-scale structural features of the sequence, obtaining the first feature. Then, the feature is fed into a channel spatial attention mechanism module to enhance the effective information of key channels and key spatial locations, obtaining the second feature. Subsequently, the first feature output by the convolutional neural network and the second feature output by the channel spatial attention mechanism module are fused element-wise to finally obtain a block-level feature vector that combines local multi-scale information and key channel spatial features. For example, when processing local feature blocks of phage tail assembly coding elements, the convolutional neural network first extracts local features under different receptive fields, and then the channel spatial attention mechanism enhances the core features related to tail assembly function. The fusion of the two yields the corresponding block-level feature vector.
[0041] S14. After adding position encoding to the block-level feature vectors corresponding to each local feature block, input them into the Transformer encoder to perform global context modeling and obtain the context feature sequence that captures long-range dependencies between blocks. Specifically, in step S14, a unique positional encoding is added to each block-level feature vector to mark the arrangement order of each local feature block in the original element sequence, avoiding the loss of positional association information after block segmentation. All block-level feature vectors with added positional encoding are input into the Transformer encoder. The encoder performs global context modeling on all block-level features, accurately capturing the long-range dependencies between different local feature blocks, and finally outputting a contextual feature sequence containing complete contextual association information. For example, after adding positional encoding to each block-level feature vector of the host fragmented coding element, inputting it into the Transformer encoder can effectively capture the long-range association features between different functional fragment blocks of the element, generating a complete contextual feature sequence.
[0042] S15. Input the context feature sequence into the attention pooling layer for weighted fusion to generate a global feature vector of uniform dimension; Specifically, in step S15, the obtained context feature sequence is fed into the attention pooling layer. The attention mechanism is used to weight and filter key information in the context feature sequence, integrating effective features and removing redundant information. The scattered context features are compressed and fused to finally generate a global feature vector with uniform dimensions that can be directly used for subsequent model processing. For example, a context feature sequence containing both coded and non-coded elements can be input into the attention pooling layer. After weighted fusion, a fixed-dimensional global feature vector is obtained, completing the standardization process for variable-length biological sequence features.
[0043] This embodiment efficiently transforms variable-length phage genome element sequences into global feature vectors with uniform dimensions through pre-trained model representation, fixed-length block segmentation, intra-block feature fusion, Transformer global context modeling, and attention pooling weighted fusion. It fully preserves the local key features of the sequence and the long-range dependencies between blocks, achieving standardized and regularized processing of phage genome element sequence features, and providing a stable and unified feature input basis for subsequent sequence-related processing.
[0044] Furthermore, in some embodiments, step S13, "inputting each local feature block sequentially into a convolutional neural network and a channel spatial attention mechanism module for intra-block feature extraction, and adding and fusing the first feature output by the convolutional neural network and the second feature output by the channel spatial attention mechanism module to obtain a block-level feature vector that fuses local multi-scale information and key channel spatial features," may specifically include: S131. Input each local feature block into a multi-layer convolutional neural network to perform multi-scale feature extraction and obtain a sequence of local feature maps under different receptive fields; Specifically, in step S131, the local feature blocks of the phage genome elements, after being processed into blocks, are fed into a multi-layer convolutional neural network for feature extraction. Through convolutional kernels with different receptive fields in the network, structural and functional features at different scales and granularities within the local feature blocks are captured, ultimately outputting a sequence of local feature maps containing multi-scale information while comprehensively preserving the basic sequence features within the local feature blocks. For example, a local feature block of the phage tail assembling coding elements is input into a multi-layer convolutional neural network, and short-range sequence features and long-range structural features within the feature block are extracted using convolutional kernels of different sizes, resulting in a sequence of local feature maps containing multi-scale information.
[0045] S132. Input the local feature map sequence into the channel attention module and the spatial attention module respectively to obtain the channel attention weights and spatial attention weights; Specifically, in step S132, the local feature map sequence obtained in the previous step is fed into the channel attention module and the spatial attention module for processing. The channel attention module focuses on the channel dimension of the feature map, selecting the feature channels that are more important for the functional characterization of phage elements and generating channel attention weights. The spatial attention module focuses on the spatial position dimension of the feature map, locating key spatial regions in the feature map and generating spatial attention weights. For example, the local feature map sequence of host lysis coding elements is input into the two types of attention modules respectively. The channel attention module locks the feature channel weights related to the lysis function, and the spatial attention module locates the spatial weights of the core functional regions in the feature map.
[0046] S133. The channel attention weights are weighted sequentially with the local feature map sequence to obtain channel-enhanced features; Specifically, in step S133, the channel attention weights output by the channel attention module are used to perform a channel-by-channel weighted operation on the local feature map sequence according to the channel dimension. This amplifies the feature values of high-importance channels in the feature map and weakens the feature values of low-importance channels, resulting in channel enhancement features that highlight key channel information. For example, by performing channel-by-channel weighting on the local feature map sequence of a DNA packaging coding element, the feature channels related to DNA packaging function are enhanced, resulting in the channel enhancement features of that element.
[0047] S134. The spatial attention weights are weighted with the local feature map sequence on a spatial location basis to obtain spatial enhancement features; Specifically, in step S134, the spatial attention weights output by the spatial attention module are used to perform position-by-position weighted operations on the local feature map sequence according to the spatial location dimension. This strengthens the feature information of key spatial regions in the feature map and weakens redundant information in non-key regions, resulting in spatially enhanced features that focus on the core spatial location. For example, by performing position-by-position weighted operations on the local feature map sequence of the head morphology encoding element, the core spatial features related to the head structure are strengthened, resulting in the spatially enhanced features of that element.
[0048] S135. The channel enhancement features and spatial enhancement features are added and fused element by element to obtain dual attention enhancement features; Specifically, in step S135, the channel enhancement features and spatial enhancement features are added and fused element by element, integrating the key features of the channel dimension with the core features of the spatial dimension to obtain a dual-attention enhancement feature that simultaneously takes into account both key channel information and key spatial information, thus achieving dual enhancement of the core information of local feature blocks. For example, the channel enhancement features and spatial enhancement features of phage coding elements are fused element by element to obtain a dual-attention enhancement feature that highlights both functional channels and focuses on the core spatial region.
[0049] S136. Perform residual connections between the dual attention enhancement features and the original local features output by the convolutional neural network to obtain the final block-level feature vector; Specifically, in step S136, the dual-attention enhanced features are residually concatenated with the original local features output by the multi-layer convolutional neural network. While preserving all the basic information of the original local features, the core feature information of the dual-attention enhanced features is superimposed, avoiding information loss or distortion during feature extraction, ultimately resulting in a stable, complete, and accurate block-level feature vector. For example, the dual-attention enhanced features of the non-coding elements of bacteriophages are residually concatenated with the original local features, ultimately yielding a block-level feature vector that combines basic information and core enhanced information.
[0050] This embodiment employs a multi-layer convolutional multi-scale feature extraction process, dual-channel and spatial attention weighting, dual-feature fusion, and residual connection to accurately extract and enhance key functional and structural information within local feature blocks of phage genome elements, while fully preserving the original local features. This effectively improves the representation accuracy and information integrity of block-level feature vectors, providing a high-quality local feature foundation for subsequent sequence feature processing.
[0051] Furthermore, in some embodiments, step S2, "constructing and training a phage element sequence generation model based on global feature vectors to learn the natural distribution patterns and contextual dependencies of phage element sequences," includes: S21. Construct an autoregressive neural network based on the Transformer architecture as the initial sequence generation model, and use the global feature vector as the input to the embedding layer of the initial sequence generation model; Specifically, in step S21, an autoregressive initial sequence generation model is built using the Transformer neural network architecture as the core framework. This model generates sequences segment by segment according to the order of elements, adapting to the structural characteristics of the ordered arrangement of phage genome elements. Simultaneously, the unified-dimensional global feature vector obtained from the previous processing is input into the embedding layer of this initial model as the model's basic input features. This allows the model to learn sequence patterns from standardized feature information, ensuring a high degree of matching between the input features and the biological and structural features of the phage elements. For example, for phage sequences containing four types of coding elements (head morphogenesis, DNA packaging, tail assembly, and host lysis) and non-coding elements, a Transformer autoregressive initial generation model is built, and the corresponding global feature vector is input into the model's embedding layer, completing the basic model construction and input configuration. The global feature vector refers to the low-dimensional representation vector of the obtained elements. This low-dimensional representation vector is used as the element's embedding layer, and this embedding layer is frozen throughout the subsequent phage element sequence generation process, meaning it does not participate in the model's parameter update process.
[0052] S22. Obtain the phage natural element sequence dataset, pre-train the initial sequence generation model using an autoregressive language modeling task, optimize the model's ability to predict the next element, and obtain the pre-trained model. Specifically, for step S22, various naturally occurring bacteriophage genomic element sequences are collected and organized into a natural element sequence dataset covering both coding and non-coding elements. With autoregressive language modeling as the core training objective, the initial sequence generation model is pre-trained. Based on the input preceding bacteriophage elements, the model successively predicts the next element that should appear. Through iterative training with a large number of natural samples, the accuracy and rationality of the predictions are continuously optimized, allowing the model to fully learn the arrangement rules, combination logic, and natural distribution patterns of natural bacteriophage elements, gradually acquiring the ability to fit the characteristics of natural sequences. After pre-training, a stable pre-trained model is obtained. For example, a dataset is constructed by collecting various natural bacteriophage element sequences targeting drug-resistant bacteria. During pre-training, the model accurately predicts the subsequent "DNA packaging coding elements" based on "head morphogenesis coding elements," continuously optimizing the element prediction ability to form a pre-trained model adapted to the patterns of natural sequences.
[0053] S23. Construct a sequence completion training task, divide the component sequence into a prompt part and a part to be completed according to a preset ratio, input the prompt part into the pre-trained model, optimize the probability distribution of the model generating the part to be completed under the given prompt conditions, and obtain the supervised fine-tuned sequence generation model. Specifically, for step S23, a dedicated training task for phage element sequence completion is established. The complete phage element sequence is split into a cue portion and a to-be-completed portion according to a preset ratio. The cue portion consists of known front-end element sequences, serving as the model's input; the to-be-completed portion consists of back-end element sequences that the model needs to generate autonomously. The cue portion is input into the pre-trained model, with the optimization goal of generating complete, naturally occurring to-be-completed sequences. Supervised fine-tuning is performed on the model, continuously adjusting the probability distribution of generating to-be-completed element sequences given the cue portion, making the model more adaptable to actual sequence completion application scenarios. The final result is a supervised fine-tuned sequence generation model. For example, the complete phage element sequence is split in a 1:1 ratio. The cue portion includes head morphogenesis and DNA packaging coding elements, while the to-be-completed portion includes tail assembly, host lysis coding elements, and non-coding elements. After inputting the cue portion, the model is fine-tuned to optimize the probability distribution of generating to-be-completed sequences, resulting in a fine-tuned model focused on the sequence completion task.
[0054] This embodiment builds an initial autoregressive Transformer model, performs autoregressive pre-training based on natural sequences, and conducts supervised fine-tuning based on sequence completion tasks. This enables the model to accurately grasp the natural distribution patterns and contextual dependencies of phage element sequences, improving the accuracy and rationality of element completion under given prompt sequences. This provides a stable and reliable basic model for the subsequent targeted generation and optimization of phage sequences.
[0055] Furthermore, in some embodiments, a class smoothing loss function is introduced during sequence completion training. The class smoothing loss function is as follows: cross-entropy loss is calculated based on the distribution of element functional category labels. For real elements, a preset probability weight is assigned to all elements within the functional category of the real element to enhance the model's generalization ability to elements of the same functional class. The preset probability weight is controlled by a class smoothing coefficient of 0.7. The element functional categories include at least one or more of the following: head morphogenesis coding elements, DNA packaging coding elements, tail assembly coding elements, and host cleavage coding elements.
[0056] In a specific embodiment, when training a model for phage genome element sequence completion, the traditional method of calculating cross-entropy loss for a single real element is abandoned. Instead, this embodiment introduces a class smoothing loss function as the core loss calculation basis for the model, thereby optimizing the loss feedback logic of the model training and solving the problem of insufficient generalization ability caused by single element loss calculation.
[0057] Phage genomic elements are pre-categorized according to their biological functions, with each functional category including at least head morphogenesis-coding elements, DNA packaging-coding elements, tail assembly-coding elements, and host lysis-coding elements. This functional category label distribution serves as the basis for calculating the category smoothing loss function, elevating loss calculation from the single-element level to the functional category level. For example, phage elements can be divided into four major functional categories: head morphogenesis, DNA packaging, tail assembly, and host lysis. All elements within each category are labeled with a unified functional category label, forming a functional category label distribution.
[0058] Then, a fixed category smoothing coefficient (with a value of 0.7) is set, and probability weights are allocated based on this coefficient: most of the weight is assigned to the real element, and the remaining weight is evenly distributed among all other elements within the same functional category as the real element. Elements outside the same functional category are not assigned weights, thereby weakening the absolute weight of a single element and strengthening the overall characteristics of the functional category. For example, in sequence completion training, if the real element is a DNA packaging-coding element, and this category contains 10 DNA packaging-coding elements with a category smoothing coefficient of 0.7, then the real element receives a base weight of 0.7, and the remaining weight of 0.3 is evenly distributed among the other 9 DNA packaging-coding elements in this category. Elements in other functional categories have a weight of 0.
[0059] Next, using the functional category label distribution as a framework and the pre-assigned probability weights as parameters, the cross-entropy loss formula is substituted into the calculation. This transforms the traditional cross-entropy loss of a single element into a category-smoothed cross-entropy loss based on functional categories, making the loss calculation more consistent with the functional classification rules of phage elements. For the sequence completion task of tail assembly coding elements, the overall loss of all elements under this functional category is calculated according to the above weight allocation rules, rather than calculating only the single loss of the target tail assembly element.
[0060] Finally, the calculated class smoothing loss is used as the basis for updating the model parameters. The network parameters of the model are adjusted in reverse so that the model no longer relies excessively on the sequence features of a single element during training, but learns the common features of all elements under the same functional category, thereby improving the model's ability to identify, generate and generalize similar functional elements.
[0061] This embodiment introduces a category smoothing loss function based on the distribution of element functional category labels during sequence completion training, and combines it with weight allocation using a fixed category smoothing coefficient. This extends the loss calculation from a single element to the functional category dimension, effectively reducing the risk of model overfitting, improving the model's generalization ability to phage elements of the same functional category, and making the sequence completion generation results more consistent with the functional classification rules and natural distribution characteristics of phage elements.
[0062] Furthermore, in some embodiments, step S3, "constructing a reward model based on biological function feedback, the reward model being used to evaluate the biological quality of phage element sequences," may specifically include: S31. Using the supervised fine-tuned sequence generation model, multiple candidate phage element completion sequences are generated for multiple different input prompts to construct a candidate sequence pool; Specifically, in step S31, the phage element sequence generation model that has undergone supervised fine-tuning is used as the main body for sequence generation. Multiple different phage element sequence fragments are selected as input prompts. For each input prompt, the model is controlled to perform multiple independent samplings, generating multiple phage element completion sequences with differences in structure and combination. The generated sequences corresponding to all input prompts are summarized and integrated to form a candidate sequence pool with sufficient sample quantity and good sequence diversity, providing a complete sample foundation for subsequent biological quality assessment. For example, three different front-end element sequences—head morphogenesis coding elements, DNA packaging coding elements, and tail assembly coding elements—are selected as input prompts. Each prompt generates 10 completion sequences, resulting in a candidate sequence pool containing 30 sequences.
[0063] S32. Use bioinformatics tools to perform biological quality assessment on each sequence in the candidate sequence pool to obtain activity assessment indicators and key functional element content for each sequence; further, in some embodiments, the key functional elements include at least one or more of tail protein-coding elements, head protein-coding elements, and lyase-coding elements. Specifically, for step S32, a standardized biological quality assessment is conducted on each phage element completion sequence in the candidate sequence pool using specialized bioinformatics tools. The core assessment results are twofold: first, the sequence's activity assessment indicators, used to quantify the phage sequence's biological activity, genome integrity, and structural rationality; and second, the inclusion of key functional elements. Key functional elements must include at least one or more of the following: tail protein-coding elements, head protein-coding elements, and lyase-coding elements. The presence, quantity, and proportion of these elements in the sequence are determined. For example, a dedicated activity assessment tool is used to score the candidate sequences, obtaining an activity score for each sequence. Simultaneously, each sequence is checked for the presence of head proteins, tail proteins, and lyase-coding elements, and the inclusion rate of key elements is calculated.
[0064] S33. Based on the activity assessment indicators and the inclusion of key functional elements, the sequences in the candidate sequence pool are compared pairwise to construct a preference dataset containing multiple preference relationship labels. The preference relationship labels are used to indicate that the biological quality of the first sequence is better than that of the second sequence. Furthermore, in some embodiments, when constructing the preference dataset, the activity evaluation index is given priority as the primary comparison criterion; when the activity evaluation index is the same, the key functional element inclusion rate is used as the secondary comparison criterion. Specifically, for step S33, following the comparison rule of prioritizing activity over key elements, sequences in the candidate sequence pool are paired for comparison: Activity assessment indicators are prioritized as the primary criterion, with sequences exhibiting higher activity indicators being considered superior; if two sequences have the same activity assessment indicator, the key functional element inclusion rate is used as a secondary criterion, with sequences exhibiting higher key element inclusion rates being considered superior. Each sequence pair is labeled with a preference relationship tag stating "the biological quality of the first sequence is superior to that of the second sequence," and all labeled sequence pairs are integrated to form a complete preference dataset. For example, when pairing sequence 1 with sequence 2, if sequence 1 has a higher activity score than sequence 2, it is labeled "sequence 1 is superior to sequence 2"; if sequence 3 and sequence 4 have the same activity score, but sequence 3 has a higher key functional element inclusion rate, it is labeled "sequence 3 is superior to sequence 4."
[0065] S34. Construct an initial reward model and train it using a preference dataset and a preference learning algorithm to obtain a trained reward model. The trained reward model is used to output the corresponding biological quality score for any input phage element sequence.
[0066] Specifically, for step S34, an initial reward model is built to evaluate the biological quality of phage element sequences. The constructed preference dataset is input into the model, and a preference learning algorithm is used for iterative training. During training, the model learns the sequence quality judgment rules in the preference relations, gradually mastering the correlation logic between phage sequence biological activity, key elements, and quality. After training, the reward model can accept any phage element sequence input and directly output a quantified biological quality score.
[0067] This embodiment generates a diverse pool of candidate sequences and then conducts standardized biological quality assessment. After constructing a sequence preference dataset, a reward model is trained based on preference learning. An objective sequence quality assessment system with phage bioactivity and key functional elements as the core is established, allowing the reward model to accurately output quantitative scores of sequence biological quality, providing a stable and reliable functional-oriented feedback basis for the subsequent optimization of the sequence generation model.
[0068] Furthermore, in some embodiments, after step S32 "invoking bioinformatics tools to perform biological quality assessment on each sequence in the candidate sequence pool", the method further includes: S321. Combine the sequences in the candidate sequence pool in pairs to obtain multiple sequence pairs; Specifically, in step S321, all candidate phage elements that have completed biological quality assessment are paired according to the rule of non-repetitive pairing. This process iterates through all possible combinations of candidate sequences, forming a complete set of sequence pairs that covers all sequence combinations to be evaluated for preference, providing a complete set of processing objects for subsequent differential screening. For example, if the candidate sequence pool contains 8 phage element completion sequences, after pairwise pairing, 28 independent sequence pairs can be obtained, all of which are included in the set of sequence pairs to be screened.
[0069] S322. For each sequence pair, calculate the difference in activity evaluation index between the two sequences to obtain the activity difference; calculate the difference in the coverage rate of key functional elements between the two sequences to obtain the element difference. Specifically, for step S322, for each sequence pair, two quantitative difference calculations are performed: first, the activity assessment index values of the two sequences are extracted, and the difference between them is calculated to obtain the activity difference; second, the critical functional element (CFU) coverage values of the two sequences are extracted, and the difference between them is calculated to obtain the element difference. By numerically calculating the difference, the magnitude of the difference between the two sequences in core biological quality indicators is directly reflected. For example, in a sequence pair, if the first sequence has an activity assessment score of 90 and a CFU coverage rate of 85%, and the second sequence has an activity assessment score of 87 and a CFU coverage rate of 83%, then the activity difference for this sequence pair is 3, and the element difference is 2%.
[0070] S323. When the absolute value of the activity difference is less than the preset activity difference threshold and the absolute value of the component difference is less than the preset component difference threshold, the sequence pair is determined to be a fuzzy preference pair and the sequence pair is removed from the preference dataset. Specifically, for step S323, pre-set activity difference thresholds and element difference thresholds are used to determine each sequence pair: if the absolute value of the activity difference between the two sequences is less than the preset activity difference threshold and the absolute value of the element difference is less than the preset element difference threshold, it indicates that the biological quality of the two sequences is highly similar and it is difficult to clearly distinguish between them, thus classifying the sequence pair as a fuzzy preference pair. The preset activity difference threshold is 5, and the element difference threshold is 3%. If a sequence pair has an activity difference of 2 and an element difference of 1%, both differences are below the corresponding thresholds, thus classifying it as a fuzzy preference pair. All sequence combinations classified as fuzzy preference pairs are completely removed from the initially constructed preference dataset to exclude invalid data with insignificant differences and ambiguous judgment boundaries, preventing such data from interfering with the subsequent learning process of the reward model and ensuring the effectiveness of the training data. For example, if the initial preference dataset contains 50 sequence pairs, after removing 12 fuzzy preference pairs, 38 valid sequence pairs remain.
[0071] S324. Retain sequence pairs with activity differences or element differences greater than the corresponding threshold as the final preference dataset for training the reward model; Specifically, in step S324, only sequence pairs with an activity difference exceeding a preset threshold or a key functional element inclusion rate difference exceeding a preset threshold are retained. The differences in quality between these sequence pairs are clear, and the judgment results are explicit. The selected effective sequence pairs are then integrated to form the final preference dataset used to train the reward model. For example, sequence pairs with an activity difference of 6 and an element difference of 4%, and sequence pairs with an activity difference of 7 and an element difference of 1%, are retained as the final data for training the reward model.
[0072] This embodiment identifies and eliminates fuzzy preference pairs by quantifying the difference in indicators after pairwise combination of sequences, accurately selects effective sequence pairs with significant differences in biological quality, constructs a pure and reliable preference dataset, effectively avoids interference from fuzzy and invalid data in model training, and improves the learning accuracy and judgment accuracy of the reward model on the biological quality of bacteriophage sequences.
[0073] Furthermore, in some embodiments, step S4, "using the evaluation results of the reward model as a feedback signal to perform reinforcement learning optimization on the trained phage element sequence generation model to generate phage element sequences that conform to the target biological function," may specifically include: S41. The supervised fine-tuned sequence generation model is used as the policy model to be optimized, and the parameters of the policy model to be optimized are frozen and copied to obtain the reference policy model. Specifically, for step S41, the phage element sequence generation model that has completed supervised fine-tuning is first identified as the policy model to be optimized in the reinforcement learning phase. Then, all parameters of this policy model are completely copied, and the copied parameters are permanently frozen and not included in subsequent iterations. This forms a reference policy model, serving as a benchmark for the optimization process and constraining the generation distribution of the policy model to not deviate from the natural sequence pattern. For example, the supervised fine-tuning model trained against drug-resistant Acinetobacter baumannii phage is used as the policy model; its parameters are completely copied and frozen to obtain a benchmark reference policy model, which is used for comparative constraints in subsequent optimizations. S42. For each input prompt in the current batch, perform multiple samplings using the current strategy model to generate a set of output sequences; Specifically, in step S42, for each training batch, for each phage element sequence input prompt, multiple independent sampling and generation operations are performed using the current strategy model. Each sampled sequence exhibits reasonable differences in element combination and arrangement, ultimately generating a fixed number of diverse output sequences for a single input prompt, fully reflecting the model's current generation capabilities. For example, if the input prompt is "head morphogenesis coding element + tail assembly coding element," the strategy model samples 8 times, generating 8 different phage element completion sequences, forming a set of output sequences.
[0074] S43. Input a set of output sequences into the trained reward model and calculate the reward value for each output sequence; Specifically, in step S43, each output sequence within the same group is fed into the trained reward model. The reward model outputs a quantified reward value for each sequence based on core indicators such as sequence biological activity and the integrity of key functional elements. The reward value directly corresponds to the biological quality of the sequence. Inputting the above eight sequences into the reward model yields reward values of 91, 86, 89, 84, 78, 82, 87, and 90, respectively, visually distinguishing the quality level of each sequence.
[0075] S44. Based on the reward values of all output sequences within the same group, calculate the mean and standard deviation of the reward values within the group, and standardize the reward value of each output sequence to obtain the relative advantage value of each output sequence; Specifically, for step S44, first, the average and standard deviation of the reward values of all sequences within the same group are calculated. Then, based on the statistical results within the group, the original reward value of each sequence is standardized, converting the absolute reward value into a relative advantage value. The relative advantage value reflects the quality ranking of the sequence within the group, eliminating the interference of differences in reward value distribution between different groups and batches. For example, the average reward value of the above 8 sequences is 85.875, and the standard deviation is approximately 4.2. After standardization, the highest score of 91 points corresponds to a relative advantage value of approximately 1.22, and the lowest score of 78 points corresponds to a relative advantage value of approximately -1.87.
[0076] S45. Construct a policy optimization objective function based on the relative advantage value to maximize the probability of generating a high relative advantage value sequence, and introduce a KL divergence constraint term to limit the difference between the current policy model and the reference policy model, and obtain the optimized loss function; Specifically, for step S45, the optimization objective function of the policy model is constructed with maximizing the generation probability of sequences with high relative advantage values as the core. Simultaneously, a KL (Kullback–Leibler) divergence constraint is introduced to calculate the difference in generation distribution between the current policy model and the reference policy model. This difference is incorporated as a penalty term into the objective function, ultimately forming a complete optimization loss function to prevent the model from over-optimizing and deviating from the natural sequence distribution. If the generation distribution of the policy model differs too much from the reference model, the KL divergence constraint will increase the loss value, forcing the model to adjust its parameters to ensure that the generated sequences conform to the natural phage arrangement pattern.
[0077] S46. Iteratively execute the sampling, reward calculation, advantage value calculation and parameter update process until the sequence generated by the current policy model reaches the preset convergence condition in the reward value distribution, and output the optimized target sequence generation model; Specifically, for step S46, the entire process of "input prompt sampling → calculating reward value → solving relative advantage value → updating model parameters" is executed iteratively, continuously monitoring the distribution of reward values in the generated sequences. When the mean and variance of the reward values remain stable over a long period without significant fluctuations, the model is deemed to have met the preset convergence condition, iteration is stopped, and the optimized target sequence generation model is output. For example, after multiple iterations, if the mean reward of the model-generated sequences stabilizes around 90 points and the variance is less than 2, meeting the convergence requirement, a usable target sequence generation model is finally output.
[0078] This embodiment uses a dual-framework approach with a strategy model and a reference model to iteratively execute training processes such as intragroup sampling generation, relative advantage value standardization, and KL divergence constraint optimization. This approach not only continuously improves the generation quality and biological functionality of phage element sequences but also strictly preserves the distribution patterns of natural sequences, effectively avoiding the pattern collapse problem during the optimization process, and ultimately obtaining a stable and reliable target sequence generation model.
[0079] Furthermore, in some embodiments, step S4, "using the evaluation results of the reward model as a feedback signal to perform reinforcement learning optimization on the trained phage element sequence generation model to generate phage element sequences that conform to the target biological function," further includes: S47. Calculate the mean and variance of the reward value for each output sequence in real time to obtain the reward distribution characteristics; Specifically, in step S47, during the reinforcement learning optimization of the phage element sequence generation model, for each set of output sequences corresponding to each input prompt, data statistics are immediately performed after the reward model scoring is completed. The arithmetic mean and variance of the reward values of all sequences in the set are accurately calculated, and the mean and variance are used as core indicators to form the reward distribution characteristics of the current set. This characteristic can intuitively reflect the overall quality level and quality dispersion of the generated sequences in this set, providing real-time and accurate data support for subsequent dynamic adjustments. For example, a set of phage output sequences optimized for host lysis function has a total of 8 sequences, with reward values of 93, 87, 91, 84, 79, 82, 88, and 90 respectively. Real-time statistics show that the mean reward is approximately 86.75 and the variance is approximately 18.2. This mean and variance are the reward distribution characteristics of this set.
[0080] S48. Dynamically adjust the sampling number based on the reward distribution characteristics. When the variance of the reward value is greater than the preset variance threshold, increase the sampling number of the current input prompt; when the variance of the reward value is less than the preset variance threshold, decrease the sampling number of the current input prompt. Specifically, for step S48, a reward value variance threshold is preset. The real-time statistical within-group reward variance is compared with the preset threshold. The sampling number is adaptively adjusted based on the comparison result. If the reward value variance is greater than the preset variance threshold, it indicates that the quality of the sequences in this group varies greatly and the generated results are unstable. It is necessary to increase the sampling number of the current input prompt to expand the sequence sample size and improve the screening probability of high-dominance sequences. If the reward value variance is less than the preset variance threshold, it indicates that the quality of the sequences in this group is concentrated and the generated results are stable. The sampling number of the current input prompt can be reduced to reduce computational overhead and accelerate the training iteration speed. For example, if the preset variance threshold is 12, and the variance of the above group is 18.2, which is higher than the threshold, the original sampling number of 8 times is increased to 12 times. If the reward variance of a certain group of sequences is 7, which is lower than the threshold, the sampling number is reduced from 8 times to 5 times.
[0081] S49. Dynamically adjust the weight coefficient of the KL divergence constraint term according to the reward distribution characteristics. When the KL divergence between the current strategy model and the reference strategy model exceeds the preset divergence threshold, increase the weight coefficient; when the KL divergence is lower than the preset divergence threshold, decrease the weight coefficient. Specifically, for step S49, a KL divergence threshold is preset, and the KL divergence value between the current strategy model and the reference strategy model is calculated in real time to measure the degree of deviation of their generated distributions. Based on this, the KL divergence constraint weights are dynamically adjusted. When the KL divergence exceeds the preset threshold, it indicates that the generated distribution of the strategy model has deviated significantly from the natural sequence distribution, and the weight coefficient of the KL divergence constraint term needs to be increased to strengthen the constraint and prevent model collapse. When the KL divergence is below the preset threshold, it indicates that the strategy model still conforms to the natural sequence distribution, and the weight coefficient of the KL divergence constraint term can be reduced to relax the optimization restrictions and improve the efficiency of sequence function-oriented optimization. For example, if the preset KL divergence threshold is 0.15, and the real-time calculated KL divergence is 0.23, exceeding the threshold, the constraint weight coefficient is increased from 0.1 to 0.18; if the KL divergence is 0.11, below the threshold, the weight coefficient is decreased from 0.1 to 0.06.
[0082] This embodiment monitors the sequence reward distribution characteristics in real time and adaptively and dynamically adjusts the number of samplings and the KL divergence constraint weights. This not only expands sampling to ensure optimization when sequence quality fluctuates, but also reduces sampling to improve training efficiency when sequences are stable. At the same time, it precisely controls the degree of distribution deviation of the strategy model. While ensuring that the generated sequences conform to the natural distribution law of phages, it improves the stability and efficiency of reinforcement learning optimization, making the sequence generation and optimization process more intelligent and more adapted to the actual training state.
[0083] Furthermore, in some embodiments, the method further includes: S51. Input the partial phage element sequence to be modified into the optimized target sequence generation model to generate a complete candidate target phage element sequence; Specifically, in step S51, a known sequence of a phage element to be targeted for modification is selected as the input template. This sequence may contain a core functional coding element fragment or a front-end sequence combining coding and non-coding elements. The sequence to be modified is input into a target sequence generation model optimized through reinforcement learning. Based on the learned natural distribution patterns, functional association logic, and targeted optimization objectives of phage elements, the model automatically completes sequence completion, structural optimization, and functional adaptation, outputting one or more structurally complete and functionally targeted candidate target phage element sequences, providing a foundation for subsequent validation and screening. For example, if a head morphogenesis coding element + DNA packaging coding element targeting multidrug-resistant Acinetobacter baumannii phage is selected as the fragment to be modified, and input into the optimized target generation model, the model automatically completes the tail assembly, host lysis coding elements, and non-coding regions, generating four complete candidate target phage element sequences.
[0084] S52. Use bioinformatics alignment tools to verify the biological rationality of candidate target phage element sequences and obtain the verification results; Specifically, for step S52, a professional bioinformatics sequence alignment tool is used to perform global and local alignments of each candidate target phage element sequence with a database of standard natural phage sequences. The focus is on verifying the element arrangement logic, base matching degree, and functional element homology of the candidate sequences. This determines whether the sequence conforms to the structural rules of the natural phage genome and whether there are issues such as disordered element arrangement, functional region conflicts, or unreasonable mutations. Ultimately, a biologically valid verification result is generated, including alignment similarity, element arrangement compliance, and homology matching results. For example, candidate phage element sequences are imported into a BLAST alignment tool and compared with a public phage sequence library to obtain results such as sequence homology similarity and element arrangement matching degree, confirming whether the sequence matches the structural characteristics of natural phages.
[0085] S53. Use activity assessment tools to evaluate the integrity of candidate target phage element sequences and obtain the evaluation results; Specifically, in step S53, a phage-specific sequence activity and integrity assessment tool is used to quantitatively evaluate each candidate sequence. The core assessment indicators include genome integrity, retention of key functional elements, and predicted viral bioactivity. This accurately determines whether the candidate sequence possesses a complete phage genome structure, retains all core functional elements, and meets the required activity standards for application. The final output is an integrity assessment result including an integrity score, activity prediction score, and information on missing functional elements. For example, using the CheckV activity assessment tool to test candidate sequences yields a genome integrity score and predicted infection activity value for each sequence, clarifying whether the sequence has defects such as missing functional elements or genome breaks.
[0086] S54. Based on the verification and evaluation results, select sequences that meet the preset biological activity threshold as the final generated engineered phage element sequences; Specifically, for step S54, biological rationality thresholds and biological activity thresholds are preset, and the alignment verification results and integrity assessment results of each candidate sequence are matched with the preset thresholds one by one. Candidate sequences that simultaneously meet the biological rationality verification criteria and the activity assessment score reaches the preset threshold are selected, while unqualified sequences with unreasonable arrangement, insufficient activity, or missing key elements are eliminated. The high-quality sequences that pass the screening are determined as the final engineered phage element sequences that can be used for subsequent experiments and applications. For example, if the preset sequence homology similarity threshold is 85% and the activity assessment threshold is 90 points, candidate sequences with 91% homology similarity and 93 points of activity score are selected as the final engineered phage element sequences.
[0087] This approach generates complete candidate sequences through a model, verifies biological rationality and assesses sequence integrity through bioinformatics comparison, and then uses preset thresholds for precise screening. This allows for the rapid identification of structurally compliant, functionally complete, and activity-compliant engineered phage element sequences, ensuring that the final output sequences possess reliable biological characteristics and providing high-quality sequence support for subsequent phage experimental verification and practical applications.
[0088] To facilitate understanding of the phage genome element sequence generation method provided in this embodiment, this embodiment also provides another implementation method for the phage genome element sequence generation method, the specific process of which is as follows: Step 1: Obtain phage element sample characterization and perform low-dimensional feature space mapping.
[0089] The phage genome data to be processed is obtained, and the original DNA base sequences are characterized using a large-scale biological model. Because the characterized sequences vary in length, they need to be uniformly processed to the same length. Feature extraction of the element sequences is performed using a pre-trained hierarchical block autoencoder. Specifically, this includes: (1) Block processing: Divide the variable-length element sequence into several local feature blocks of fixed length; (2) Intra-block feature extraction: Local multi-scale features of each block are extracted through an encoding module containing a convolutional neural network and a channel space attention mechanism; (3) Global Feature Fusion: Block-level features are modeled in context using a Transformer encoder, and a global feature vector of uniform dimension is generated through an attention pooling layer. This step aims to compress high-dimensional, variable-length biological sequences into low-dimensional, continuous latent space vectors, providing an initial embedding representation for subsequent sequence generation models.
[0090] Step 2: Construct and pre-train a phage sequence supervision model.
[0091] An autoregressive sequence completion model based on the Transformer architecture is constructed, using the global feature vector obtained in step 1 as the input to the model's embedding layer. Pre-training phase: A dataset of phage element sequences is obtained, and the model is trained using an autoregressive language modeling objective to learn the contextual dependencies and combination patterns of phage elements in their natural distribution. Supervised fine-tuning phase: The element sequence is divided into a cue part and a completion part. Given a cue sub-sequence, the probability distribution of the model completing the remaining sequence is optimized. The large number of elements during training leads to relatively sparse relationships between them, reducing the diversity and generalization ability of the completed sequences. Therefore, a class smoothing mechanism is introduced to prevent overfitting. This is achieved by modifying the cross-entropy loss of a single element to a cross-entropy loss based on the class label distribution, expanding the cross-entropy loss of a single token to the cross-entropy loss of all tokens of the same class. The loss weights for predicting the true tokens have class smoothing coefficients. Tokens with the same class label as the predicted token share the remaining class smoothing coefficient loss weights equally, while tokens with other class labels have zero loss weights. The cross-entropy loss is then calculated. The supervised model after training is obtained. During training, the pre-trained model used 200 training epochs, a batch size of 5, and a learning rate of 1e-5. Fine-tuning supervised and reinforcement learning training used 100 training epochs, a dataset of 850 sequences, a batch size of 8, and a learning rate of 1e-5. The warm-up learning rate was 50,000 time steps, the training set to validation set ratio was 20:830, the class smoothing coefficient was 0.7, and validation was performed every 1000 time steps. The optimal model was determined using validation set loss. The component sequences were divided according to 50% of the sequence length, and the ratio of prompts to completions was 1:1.
[0092] Step 3: Construct a biological reward model based on preference pairs.
[0093] To address the lack of an explicit objective function in phage design, a reward model based on feedback (referring to feedback from biological tools) is constructed. Specific steps include: (1) Sampling and evaluation: Multiple candidate completion sequences are generated for the same input prompt using a supervised model. Automated scripts are used to call bioinformatics tools to evaluate the viral activity and integrity of the candidate sequences and to detect whether the sequences contain key functional elements.
[0094] (2) Constructing preference pairs: Based on the above evaluation results, construct a preference pair dataset of "sequence A is better than sequence B". For example, if sequence A contains a key tail protein while sequence B is missing, then A>B is determined.
[0095] (3) Reward model training: The reward model is trained based on the Bradley-Terry model so that it can take a phage element sequence as input and output a scalar reward value that reflects the biological quality and functional quality of the sequence.
[0096] Step 4: Reinforcement learning training based on relative advantage strategy optimization.
[0097] The supervised model obtained in step 2 is used as the model to be optimized. The reward model trained in step 3 provides feedback signals, and a relative advantage strategy optimization algorithm is used for iterative training. The specific process is as follows: (1) Intragroup sampling: For each input prompt, the policy model samples and generates multiple output sequences.
[0098] (2) Reward calculation: Input each generated complete sequence into the reward model to obtain the corresponding reward value.
[0099] (4) Advantage estimation: Calculate the mean and standard deviation of the reward within the group, standardize the reward of each sequence, and obtain the relative advantage function, as shown in the following formula: Parameter update: Model parameters are updated based on the relative advantage function to maximize the probability of generating high-reward sequences. Simultaneously, a KL divergence constraint is introduced to limit the deviation between the current policy and the reference policy (SFT model), preventing mode collapse.
[0100] (5) Iterative loop: Repeat the above sampling-evaluation-update process until the sequence generated by the model tends to be stable in the reward distribution and meets the preset biological activity index.
[0101] Step 5: Generation and verification of the target phage sequence.
[0102] Using a trained phage sequence completion model, inputting partial element sequences of the phage to be modified, the model automatically completes and generates target phage sequences with specific functional tendencies (such as high activity, i.e., high survival rate of the synthesized phage). The biological rationality and completeness of the generated sequences are verified using BLAST alignment analysis and the CheckV tool. High-confidence engineered phage sequences are selected for subsequent wet experimental validation.
[0103] In a specific embodiment, the phage sequence is first divided into element sequences, including coding elements and non-coding elements. Coding elements are categorized based on their location and function within the phage's biological structure, such as head morphogenesis coding genes, DNA packaging genes, and host lysis genes. Non-coding elements are base sequences for which no specific function has been detected. Element sequences are identified using start codons, stop codons, and regulatory elements, and their functions are determined by comparing them with known sequences in a database. Different phage genomes may share the same elements. Tokenizing element sequences instead of base sequences significantly compresses the sequence length. First, the elements are represented using the Evo2_7b model, outputting a two-dimensional feature array [corresponding to the base sequence length of the element, 4096]. The Evo2 element representation is then processed through a hierarchical block encoder to obtain a compressed, uniformly sized element sequence representation, which serves as the embedding layer for subsequent phage sequence completion models. Reinforcement learning and preference pairs are used to guide and test sequences, generating phage sequences with specific properties.
[0104] like Figure 3 As shown, this embodiment also provides a flowchart of the dimensionality reduction model, including the feature dimensionality reduction and reconstruction process of phage genome element sequences. First, based on the element set, the initial sequence representation is completed through the evo2 model. The representation result is divided into multiple fixed-length local feature blocks. The block key feature extraction and preliminary dimensionality reduction are achieved through the combination of CNN and CBAM modules. Then, global context modeling is completed through multi-layer Transformer encoders and attention pooling layers to obtain a low-dimensional representation with a unified dimension. After positional encoding and inverse Transformer encoding, feature reconstruction and block splicing are achieved through the combination of TCNN and CBAM modules. Finally, the reconstructed sequence is output. At the same time, the consistency of feature extraction and reconstruction is constrained by the reconstruction loss, realizing the efficient conversion of variable-length phage element sequences to standardized global features.
[0105] like Figure 4As shown in the illustration, this embodiment also provides a flowchart of phage element sequence completion modification. First, pre-training is performed based on the element set and sequence set, and the natural distribution pattern of phage elements is learned using the LLAMA3 architecture to obtain a pre-trained model. Then, supervised fine-tuning is performed using prompt-label data to optimize the model's sequence completion ability and obtain a supervised model. Next, multiple candidate completion sequences are generated based on input prompts, and a preference dataset is constructed by evaluating biological activity and key proteins to train a reward model that can quantify the biological quality of the sequence. Finally, in the reinforcement learning stage, the GRPO optimization objective function is used to iteratively update the completion model by combining the functional feedback of the reward model and the distribution constraints of the supervised model, thereby achieving targeted phage element sequence completion modification that takes into account both the natural sequence pattern and the target biological function.
[0106] The following example illustrates the phage DNA sequence modification training algorithm based on GRPO.
[0107] Input: Phage DNA element sequence dataset S ={s1,s2,…,s m}; Initial Model model base Learning rate η Training rounds E ; Output: The final trained phage element modification model model f ; Phase 1: Initial Model Training and Supervised Fine-Tuning (Pretraining + SFT) for epoch ∈[1, E init do From the dataset S Medium-sampled sequence s; The model is trained using cross-entropy loss to learn the element distribution; Update initial model parameters θ init ; end Use the initial model parameters as the starting point for supervised fine-tuning of the model. θ SFT ← θ init ; for epoch ∈[1, E SFT do From the dataset S Mid-sampled DNA element sequence s; Training using a supervised loss function modelSFT ; renew θ SFT ; end Phase Two: Reward Model Training Initialize reward model parameters: and replace the output with a scalar header; for epoch ∈[1, E RM do Sample sequence s from the dataset; Generate candidate sequences using the SFT model ; Will Pass in the preference script to obtain the preference dataset; Preferences are used to calculate scores for the input reward model. ; Update reward model parameters ; end Phase 3: GRPO Reinforcement Learning Initialize the policy model: θ ← θ SFT Freeze reference model parameters: θ ref ← θ SFT ; for epoch ∈[1, E GRPO do DNA sequences s were sampled from the dataset; Masking s yields the input s prompt ; Generate sequences using a strategy model ; The reward model calculates the quality score. ; Based on rewards, reference model output, and the computational advantages of the current strategy. KL Penalty Items ; Calculate GRPO loss ; Update strategy parameters ; end Output model: Returns the final completed model. model f The sequence was completed using a completion model and then evaluated.
[0108] In summary, compared with existing technologies, the phage genome element sequence generation method provided in this embodiment utilizes element-based characterization to replace traditional bases, significantly shortening the sequence length and overcoming the bottleneck of ultra-long biological sequence modeling. Combined with a hierarchical block autoencoder, it achieves efficient compression of variable-length element sequences into unified low-dimensional global features, effectively preserving key local and global dependencies. Simultaneously, a reward model based on preference pairs is constructed, introducing bioactivity assessment and key functional element detection as feedback signals, solving the problem of lack of functional guidance in the design and improving the bioactivity and integrity of the generated sequences. Furthermore, the Relative Advantage Policy Optimization (GRPO) algorithm is used for reinforcement learning, effectively reducing training variance and improving model convergence stability through intra-group relative comparisons and KL divergence constraints. The generated sequences statistically closely fit natural patterns and possess directional modification capabilities, achieving efficient screening in the "dry experiment" stage and significantly reducing the trial-and-error costs and development cycle of subsequent "wet experiments."
[0109] To facilitate better implementation of the phage genome element sequence generation method of this application, this application also provides a phage genome element sequence generation apparatus based on the above-described phage genome element sequence generation method. The meanings of the terms used are the same as in the above-described phage genome element sequence generation method, and specific implementation details can be found in the descriptions in the method embodiments.
[0110] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of the phage genome element sequence generation device provided in the embodiments of this application. The phage genome element sequence generation device may specifically include a characterization learning module 201, a supervised training module 202, a reward model construction module 203, and a generation optimization module 204, as follows: The representation learning module 201 is used to acquire sequence data of phage genome element samples and extract features from the sequence data to obtain a global feature vector of uniform dimension. Specifically, the representation learning module 201 is primarily responsible for addressing the issues of large variations in phage element sequence lengths and high feature dimensionality, mapping variable-length biological sequences into low-dimensional global feature vectors of uniform dimension. This module first uses the pre-trained DNA large-scale model Evo2 to encode the raw features of the input element sequence, then employs a hierarchical block autoencoder architecture for processing: the sequence is first divided into fixed-length feature blocks, and local multi-scale features are extracted using intra-block feature learning units combining convolutional neural networks and channel spatial attention (CBAM); then, a Transformer encoder captures the global long-range dependencies between different blocks, and attention pooling layers are used to fuse them to generate the final compact latent space vector. This module provides a rich semantic and structurally unified input representation for subsequent sequence generation tasks. The model has 3 training epochs, a fixed block length of 500, 5 convolutional layers, a kernel size of 3, a stride of 2, and padding of 1. The CBAM uses the standard default module, and its output is added to and fused with the output of the convolutional network. The Transformer encoder used between different blocks has one layer with eight heads, a hidden layer size of 4096, a final global feature vector size of 512, an L1 loss function, and the optimal model is the minimum validation set loss.
[0111] The supervised training module 202 is used to build and train a phage element sequence generation model based on global feature vectors to learn the natural distribution pattern and contextual dependencies of phage element sequences. Specifically, for the supervised training module 202, this module learns the relationships and structural patterns of phage elements in their natural distribution using natural element sequence data, providing good parameter initialization for subsequent completion tasks. Then, a supervised fine-tuning stage further enhances the model's stability in conditional generation and sequence completion scenarios, enabling it to learn how to effectively complete sequences. Compared to directly modeling at the base level, the element sequence strategy can significantly shorten the effective sequence length, allowing the model to focus on semantic modeling at the element level, thereby improving training efficiency.
[0112] The reward model construction module 203 is used to construct a reward model based on biological function feedback, which is used to evaluate the biological quality of phage element sequences. Specifically, the reward model construction module 203 aims to address the lack of specific directional guidance and the difficulty in obtaining objective evaluation criteria in phage design. It is responsible for providing feedback signals reflecting the quality of biological functions for the phage element completion model. This module does not rely on hard-coded specific reward values but instead employs a preference-pair-based modeling approach. It uses automated scripts to call bioinformatics tools to evaluate the viral activity and integrity preferences of candidate sequences and detect whether the sequences contain key functional elements (such as tail proteins and critical proteins). Based on these evaluation results, a preference dataset of "sequence A is superior to sequence B" is constructed, and the reward model is trained using the Bradley-Terry method. This enables the module to predict the quality score of a given phage element sequence, thereby objectively guiding the generation direction. The automated scripts are used to evaluate activity preferences, comparing them sequentially using the CheckV core tool for activity assessment with the proportion of critical proteins. CheckV uses amino acid consistency and Hidden Markov Models (HMMs) to assess the integrity of generated phage sequences. Key protein scores are calculated by defining essential protein classes, such as head gene proteins, and then determining the percentage of essential protein classes in the element sequence. The scores are first compared against CheckV scores, and then preference pairs are derived based on key protein scores. The reward model is trained in 100 epochs with a batch size of 5. There are 2000 warm-up steps. Validation loss is calculated on the validation set every 1000 steps. The model with the lowest validation loss is selected as the optimal model. At the end of the reward model training, a higher reward value for the element sequence indicates higher sequence activity.
[0113] The generation optimization module 204 is used to optimize the trained phage element sequence generation model by using the evaluation results of the reward model as a feedback signal, and generate phage element sequences that conform to the target biological function. Specifically, for the generation optimization module 204, this module constructs an autoregressive sequence completion model based on the Transformer architecture and trains it using the relative advantage policy optimization algorithm. It achieves targeted modification of phage sequences through reward values provided by the reward model construction module. This module first learns the natural distribution pattern of phage elements through pre-training and supervised fine-tuning. During the reinforcement learning phase, this module samples multiple candidate sequences from the same input cue, calculates the reward value for each sequence using the reward model construction module, and updates the policy parameters through the intra-group relative advantage function. Simultaneously, this module introduces KL divergence constraints to prevent the policy from deviating from the pre-training distribution, ultimately guiding the model to generate high-quality phage sequences that conform to the natural distribution pattern and possess high biological activity and specific functional elements. The model parameters are set as follows: the number of candidate sequences sampled within a group is 8, the GRPO pruning range is 0.2, the KL penalty coefficient is fixed at 0.1, the hidden layer size of the Transformer autoregressive model is 512, the number of attention heads is 4, and the number of layers is 6. The convergence criterion for the reinforcement learning training model iterative training is that the distribution of the reward values of the evaluated elements in the reward model remains relatively stable over the long term.
[0114] Furthermore, in some embodiments, the representation learning module 201 is specifically used for: The obtained phage genome element sequences are input into a pre-trained deep learning sequence representation model to obtain the initial feature tensor corresponding to each element; The initial feature tensor is divided according to a preset block length, and each element sequence is divided into several local feature blocks of fixed length. Each local feature block is sequentially input into a convolutional neural network and a channel space attention mechanism module for intra-block feature extraction. The first feature output by the convolutional neural network and the second feature output by the channel space attention mechanism module are added and fused to obtain a block-level feature vector that integrates local multi-scale information and key channel space features. After adding positional encoding to the block-level feature vectors corresponding to each local feature block, the input is given to the Transformer encoder for global context modeling to obtain a context feature sequence that captures long-range dependencies between blocks. The context feature sequence is input into the attention pooling layer for weighted fusion to generate a global feature vector of uniform dimension.
[0115] Furthermore, in some embodiments, the representation learning module 201 is specifically used for: Each local feature block is input into a multi-layer convolutional neural network for multi-scale feature extraction to obtain a sequence of local feature maps under different receptive fields. The local feature map sequence is input into the channel attention module and the spatial attention module respectively to obtain the channel attention weights and the spatial attention weights; Channel-wise enhanced features are obtained by weighting the channel attention weights with the local feature map sequence channel by channel. Spatial attention weights are weighted with local feature map sequences on a spatial location basis to obtain spatially enhanced features; The channel enhancement features and spatial enhancement features are fused element-wise to obtain dual attention enhancement features; The dual-attention enhanced features are residually connected to the original local features output by the convolutional neural network to obtain the final block-level feature vector.
[0116] Furthermore, in some embodiments, the supervised training module 202 is specifically used for: An autoregressive neural network based on the Transformer architecture is constructed as the initial sequence generation model, and the global feature vector is used as the input to the embedding layer of the initial sequence generation model. We obtained a dataset of natural phage element sequences, pre-trained the initial sequence generation model using an autoregressive language modeling task, optimized the model's ability to predict the next element, and obtained a pre-trained model. A sequence completion training task is constructed. The component sequence is divided into a prompt part and a part to be completed according to a preset ratio. The prompt part is input into the pre-trained model. The probability distribution of the model generating the part to be completed under the given prompt conditions is optimized to obtain a supervised fine-tuned sequence generation model.
[0117] Furthermore, in some embodiments, a class smoothing loss function is introduced during sequence completion training. The class smoothing loss function is: cross-entropy loss is calculated based on the distribution of component functional category labels. For real components, a preset probability weight is assigned to all components within the functional category of the real component to enhance the model's generalization ability to components of the same type.
[0118] Furthermore, in some embodiments, the preset probability weights are controlled by a category smoothing coefficient of 0.7; the element functional categories include at least one or more of the following: head morphogenesis coding elements, DNA packaging coding elements, tail assembly coding elements, and host lysis coding elements.
[0119] Furthermore, in some embodiments, the reward model construction module 203 is specifically used for: Using a supervised fine-tuned sequence generation model, multiple candidate phage element completion sequences are generated for multiple different input prompts to construct a candidate sequence pool; Bioinformatics tools were used to assess the biological quality of each sequence in the candidate sequence pool, and activity assessment indicators and key functional element content of each sequence were obtained. Based on activity assessment metrics and the inclusion of key functional elements, pairs of sequences in the candidate sequence pool are compared to construct a preference dataset containing multiple preference relationship labels. The preference relationship labels are used to indicate that the biological quality of the first sequence is superior to that of the second sequence. An initial reward model is constructed and trained using a preference dataset and a preference learning algorithm to obtain a trained reward model. The trained reward model is used to output the corresponding biological quality score for any input phage element sequence.
[0120] Furthermore, in some embodiments, when constructing the preference dataset, the activity evaluation index is given priority as the primary comparison criterion; when the activity evaluation index is the same, the key functional element inclusion rate is used as the secondary comparison criterion.
[0121] Furthermore, in some embodiments, the key functional elements include at least one or more of the following: tail protein-coding elements, head protein-coding elements, and lyase-coding elements.
[0122] Furthermore, in some embodiments, the apparatus further includes a screening module, specifically used for: The sequences in the candidate sequence pool are combined in pairs to obtain multiple sequence pairs; For each sequence pair, calculate the difference in activity evaluation metrics between the two sequences to obtain the activity difference; calculate the difference in the inclusion rate of key functional elements between the two sequences to obtain the element difference. When the absolute value of the activity difference is less than the preset activity difference threshold and the absolute value of the component difference is less than the preset component difference threshold, the sequence pair is determined to be a fuzzy preference pair and the sequence pair is removed from the preference dataset. Sequence pairs with activity differences or element differences greater than the corresponding threshold are retained as the final preference dataset for training the reward model.
[0123] Furthermore, in some embodiments, the generation optimization module 204 is specifically used for: The supervised fine-tuned sequence generation model is used as the policy model to be optimized, and the parameters of the policy model to be optimized are frozen and copied to obtain the reference policy model. For each input prompt in the current batch, the current strategy model is used to perform multiple samplings to generate a set of output sequences; Input a set of output sequences into the trained reward model and calculate the reward value for each output sequence. Based on the reward values of all output sequences within the same group, the mean and standard deviation of the reward values within the group are calculated, and the reward value of each output sequence is standardized to obtain the relative advantage value of each output sequence. The objective function for policy optimization is constructed based on the relative advantage value to maximize the probability of generating a sequence with a high relative advantage value. A KL divergence constraint term is introduced to limit the difference between the current policy model and the reference policy model, thereby obtaining the optimized loss function. The sampling, reward calculation, advantage value calculation, and parameter update processes are iteratively executed until the sequence generated by the current policy model reaches the preset convergence condition in the reward value distribution, and the optimized target sequence generation model is output.
[0124] Furthermore, in some embodiments, the generation optimization module 204 is also used for: The mean and variance of the reward value for each output sequence are calculated in real time to obtain the reward distribution characteristics; The sampling frequency is dynamically adjusted based on the reward distribution characteristics. When the variance of the reward value is greater than the preset variance threshold, the sampling frequency of the current input prompt is increased; when the variance of the reward value is less than the preset variance threshold, the sampling frequency of the current input prompt is decreased. The weight coefficients of the KL divergence constraint terms are dynamically adjusted based on the reward distribution characteristics. When the KL divergence between the current strategy model and the reference strategy model exceeds the preset divergence threshold, the weight coefficients are increased; when the KL divergence is lower than the preset divergence threshold, the weight coefficients are decreased.
[0125] Furthermore, in some embodiments, the phage genome elements include coding elements and non-coding elements; the coding elements are divided based on different positions and biological functions of the phage biological structure, and include at least one or more of the following: head morphogenesis coding elements, DNA packaging coding elements, tail assembly coding elements, and host lysis coding elements; the non-coding elements are base sequence regions for which no specific biological function has been detected.
[0126] Furthermore, in some embodiments, the apparatus further includes a verification and evaluation module, specifically used for: Input the partial phage element sequence to be modified into the optimized target sequence generation model to generate a complete candidate target phage element sequence; Bioinformatics alignment tools were used to verify the biological rationality of candidate target bacteriophage element sequences, and the verification results were obtained. The integrity of candidate target phage element sequences was assessed using an activity assessment tool to obtain the assessment results; Based on the validation and evaluation results, sequences that meet the preset biological activity thresholds are selected as the final engineered phage element sequences.
[0127] For specific limitations regarding the phage genome element sequence generation device, please refer to the limitations on the phage genome element sequence generation method described above, which will not be repeated here. Each module in the aforementioned phage genome element sequence generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0128] The phage genome element sequence generation device provided in this embodiment extracts the unified global features of phage genome element sequences, trains the sequence generation model, and optimizes it based on a biological function reward model through reinforcement learning. This enables the generation of phage genome element sequences that both conform to the natural sequence patterns of phages and meet the target biological function requirements, thereby achieving targeted and efficient generation of phage genome element sequences and improving the effectiveness and functionality of sequence generation.
[0129] Furthermore, embodiments of this application also provide an electronic device, such as... Figure 6 As shown, it illustrates a structural schematic diagram of the electronic device involved in the embodiments of this application, specifically: The electronic device may include components such as a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, a power supply 303, and an input unit 304. Those skilled in the art will understand that... Figure 6 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 301 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines, and performs various functions and processes data by running or executing software programs and / or modules stored in the memory 302, and by calling data stored in the memory 302, thereby providing overall monitoring of the electronic device. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 301.
[0130] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and methods for generating phage genome elements by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 302 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.
[0131] The electronic device also includes a power supply 303 that supplies power to various components. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 303 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0132] The electronic device may also include an input unit 304, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0133] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 301 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 302 according to the following instructions, and the processor 301 runs the applications stored in the memory 302 to realize various functions, as follows: Sequence data of phage genomic elements were acquired, and features were extracted from the sequence data to obtain a global feature vector of uniform dimension. Based on the global feature vector, a phage element sequence generation model was constructed and trained to learn the natural distribution pattern and contextual dependencies of phage element sequences. A reward model based on biological function feedback was constructed to evaluate the biological quality of phage element sequences. The evaluation results of the reward model were used as feedback signals to optimize the trained phage element sequence generation model through reinforcement learning, generating phage element sequences that conform to the target biological function.
[0134] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0135] This application embodiment extracts unified global features from phage genome element sequences, trains a sequence generation model, and optimizes it using reinforcement learning based on a biological function reward model. This enables the generation of phage genome element sequences that both conform to the natural sequence patterns of phages and meet the target biological function requirements, thereby achieving targeted and efficient generation of phage genome element sequences and improving the effectiveness and functionality of sequence generation.
[0136] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0137] Therefore, embodiments of this application provide a storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the phage genome element sequence generation methods provided in embodiments of this application. For example, the instructions can execute the following steps: Sequence data of phage genomic elements were acquired, and features were extracted from the sequence data to obtain a global feature vector of uniform dimension. Based on the global feature vector, a phage element sequence generation model was constructed and trained to learn the natural distribution pattern and contextual dependencies of phage element sequences. A reward model based on biological function feedback was constructed to evaluate the biological quality of phage element sequences. The evaluation results of the reward model were used as feedback signals to optimize the trained phage element sequence generation model through reinforcement learning, generating phage element sequences that conform to the target biological function.
[0138] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0139] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0140] Since the instructions stored in the storage medium can execute the steps in any of the phage genome element sequence generation methods provided in the embodiments of this application, the beneficial effects that any of the phage genome element sequence generation methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0141] The foregoing has provided a detailed description of a method and apparatus for generating phage genome elements according to embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method of sequence generation of a bacteriophage genomic element, characterized by, include: Sequence data of phage genome element samples are obtained, and features are extracted from the sequence data to obtain a global feature vector of uniform dimension; Based on the global feature vector, a phage element sequence generation model is constructed and trained to learn the natural distribution pattern and contextual dependencies of phage element sequences. A reward model based on biological function feedback is constructed to evaluate the biological quality of phage element sequences; The evaluation results of the reward model are used as feedback signals to perform reinforcement learning optimization on the trained phage element sequence generation model, generating phage element sequences that conform to the target biological function.
2. The method of sequence generation of a phage genomic element according to claim 1, characterized in that, The process of acquiring sequence data of phage genome element samples and extracting features from the sequence data to obtain a global feature vector of uniform dimension includes: The obtained phage genome element sequences are input into a pre-trained deep learning sequence representation model to obtain the initial feature tensor corresponding to each element; The initial feature tensor is divided according to a preset block length, and each element sequence is divided into several local feature blocks of fixed length. Each local feature block is sequentially input into a convolutional neural network and a channel space attention mechanism module for intra-block feature extraction. The first feature output by the convolutional neural network and the second feature output by the channel space attention mechanism module are added and fused to obtain a block-level feature vector that fuses local multi-scale information and key channel space features. After adding positional encoding to the block-level feature vectors corresponding to each local feature block, the input is given to the Transformer encoder for global context modeling to obtain a context feature sequence that captures long-range dependencies between blocks. The context feature sequence is input into the attention pooling layer for weighted fusion to generate a global feature vector of uniform dimension.
3. The method of sequence generation of phage genomic elements according to claim 2, characterized in that, The process involves sequentially inputting each local feature block into a convolutional neural network and a channel spatial attention mechanism module for intra-block feature extraction. The first feature output by the convolutional neural network and the second feature output by the channel spatial attention mechanism module are then added and fused to obtain a block-level feature vector that integrates local multi-scale information and key channel spatial features. This includes: Each local feature block is input into a multi-layer convolutional neural network for multi-scale feature extraction to obtain a sequence of local feature maps under different receptive fields. The local feature map sequence is input into the channel attention module and the spatial attention module respectively to obtain the channel attention weights and the spatial attention weights; The channel attention weights are weighted sequentially with the local feature map sequence to obtain channel-enhanced features; The spatial attention weights are weighted spatially by the local feature map sequence to obtain spatially enhanced features; The channel enhancement features and the spatial enhancement features are fused element-wise to obtain dual attention enhancement features; The dual-attention enhancement features are residually concatenated with the original local features output by the convolutional neural network to obtain the final block-level feature vector.
4. The method of sequence generation of phage genomic elements according to claim 1, characterized in that, The step of constructing and training a phage element sequence generation model based on the global feature vector to learn the natural distribution patterns and contextual dependencies of phage element sequences includes: An autoregressive neural network based on the Transformer architecture is constructed as the initial sequence generation model, and the global feature vector is used as the input to the embedding layer of the initial sequence generation model. A dataset of natural phage element sequences was obtained, and the initial sequence generation model was pre-trained using an autoregressive language modeling task to optimize the model’s ability to predict the next element, thus obtaining a pre-trained model. A sequence completion training task is constructed by dividing the component sequence into a prompt part and a part to be completed according to a preset ratio. The prompt part is input into the pre-trained model, and the probability distribution of the model generating the part to be completed under the given prompt conditions is optimized to obtain a supervised fine-tuned sequence generation model.
5. The method of sequence generation of phage genomic elements according to claim 1, characterized in that, The construction of a reward model based on biological function feedback, which is used to evaluate the biological quality of phage element sequences, includes: Using a supervised fine-tuned sequence generation model, multiple candidate phage element completion sequences are generated for multiple different input prompts to construct a candidate sequence pool; Bioinformatics tools are used to assess the biological quality of each sequence in the candidate sequence pool, and activity assessment indicators and key functional element content of each sequence are obtained. Based on the activity evaluation index and the inclusion of the key functional elements, the sequences in the candidate sequence pool are compared pairwise to construct a preference dataset containing multiple preference relationship labels, which are used to indicate that the biological quality of the first sequence is better than that of the second sequence. An initial reward model is constructed, and the initial reward model is trained using the preference dataset and preference learning algorithm to obtain a trained reward model; the trained reward model is used to output the corresponding biological quality score for any input phage element sequence.
6. The method of sequence generation of phage genomic elements according to claim 5, characterized in that, After invoking bioinformatics tools to perform biological quality assessment on each sequence in the candidate sequence pool, the method further includes: The sequences in the candidate sequence pool are combined in pairs to obtain multiple sequence pairs; For each sequence pair, calculate the difference in activity evaluation metrics between the two sequences to obtain the activity difference; calculate the difference in the inclusion rate of key functional elements between the two sequences to obtain the element difference. When the absolute value of the activity difference is less than a preset activity difference threshold and the absolute value of the element difference is less than a preset element difference threshold, the sequence pair is determined to be a fuzzy preference pair and the sequence pair is removed from the preference dataset. Sequence pairs whose activity difference or element difference is greater than the corresponding threshold are retained as the final preference dataset for training the reward model.
7. The method of sequence generation of phage genomic elements according to claim 1, characterized in that, The step of using the evaluation results of the reward model as feedback signals to perform reinforcement learning optimization on the trained phage element sequence generation model, generating phage element sequences that conform to the target biological function, includes: The supervised fine-tuned sequence generation model is used as the policy model to be optimized, and the parameters of the policy model to be optimized are frozen and copied to obtain a reference policy model. For each input prompt in the current batch, the current strategy model is used to perform multiple samplings to generate a set of output sequences; The set of output sequences is input into the trained reward model, and the reward value corresponding to each output sequence is calculated. Based on the reward values of all output sequences within the same group, the mean and standard deviation of the reward values within the group are calculated, and the reward value of each output sequence is standardized to obtain the relative advantage value of each output sequence. Based on the relative advantage value, a policy optimization objective function is constructed to maximize the probability of generating a high relative advantage value sequence. A KL divergence constraint term is introduced to limit the difference between the current policy model and the reference policy model, thereby obtaining an optimized loss function. The sampling, reward calculation, advantage value calculation, and parameter update processes are iteratively executed until the sequence generated by the current policy model reaches the preset convergence condition in the reward value distribution, and the optimized target sequence generation model is output.
8. The method of sequence generation of phage genomic elements according to claim 7, characterized in that, The step of using the evaluation results of the reward model as a feedback signal to perform reinforcement learning optimization on the trained phage element sequence generation model to generate phage element sequences that conform to the target biological function also includes: The mean and variance of the reward value for each output sequence are calculated in real time to obtain the reward distribution characteristics; The sampling frequency is dynamically adjusted based on the reward distribution characteristics. When the variance of the reward value is greater than the preset variance threshold, the sampling frequency of the current input prompt is increased; when the variance of the reward value is less than the preset variance threshold, the sampling frequency of the current input prompt is decreased. The weight coefficient of the KL divergence constraint term is dynamically adjusted according to the reward distribution characteristics. When the KL divergence between the current strategy model and the reference strategy model exceeds a preset divergence threshold, the weight coefficient is increased; when the KL divergence is lower than the preset divergence threshold, the weight coefficient is decreased.
9. The method of sequence generation of phage genomic elements according to claim 1, characterized in that, The method further includes: Input the partial phage element sequence to be modified into the optimized target sequence generation model to generate a complete candidate target phage element sequence; The biological rationality of the candidate target bacteriophage element sequences was verified using bioinformatics comparison tools, and the verification results were obtained. The integrity of the candidate target phage element sequence was assessed using an activity assessment tool to obtain the assessment results; Based on the verification and evaluation results, sequences that meet the preset biological activity threshold are selected as the final engineered phage element sequences.
10. A sequence generating apparatus of a phage genomic element, characterized by, include: The representation learning module is used to acquire sequence data of phage genome element samples and extract features from the sequence data to obtain a global feature vector of uniform dimension. The supervised training module is used to construct and train a phage element sequence generation model based on the global feature vector, so as to learn the natural distribution pattern and contextual dependencies of phage element sequences; A reward model construction module is used to construct a reward model based on biological function feedback, which is used to evaluate the biological quality of phage element sequences; An optimization module is used to optimize the trained phage element sequence generation model by using the evaluation results of the reward model as a feedback signal, thereby generating phage element sequences that conform to the target biological function.
