A deep learning-based pathogen DNA detection optimization method

By constructing a deep learning network to fuse electrical signals and sequence features and dynamically adjust thresholds, the problems of information loss and fixed detection strategies in pathogen DNA detection using nanopore sequencing are solved, improving detection accuracy and efficiency and adapting to the needs of different application scenarios.

CN122135789APending Publication Date: 2026-06-02FUJIAN BAIMENG MEDICAL TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
FUJIAN BAIMENG MEDICAL TECH CO LTD
Filing Date
2026-05-07
Publication Date
2026-06-02

Smart Images

  • Figure CN122135789A_ABST
    Figure CN122135789A_ABST
Patent Text Reader

Abstract

This invention discloses an optimized method for pathogen DNA detection based on deep learning, belonging to the interdisciplinary field of bioinformatics and deep learning. The invention acquires first electrical signal data and first DNA sequence data from nanopore sequencing; outputs a first electrical signal feature vector through an electrical signal feature enhancement extraction network; outputs a first sequence feature vector through a sequence feature encoding network; obtains a first fused feature vector by element-wise weighted summation through a feature layer fusion network; outputs the probability value of the presence of a first pathogen through a first pathogen classification network and compares it with a first filtering threshold of 0.15 for rapid screening; obtains a second fused feature vector for the samples using a temporal context encoding network and a cross-attention fusion network; outputs the probability value of the presence of a second pathogen through a second pathogen classification network; and completes the detection by selecting a judgment threshold of 0.35, 0.50, or 0.65 according to the application scenario parameters. This invention achieves the synergistic utilization of electrical signals and sequence features and dynamic adjustment of the detection strategy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of bioinformatics and deep learning, and in particular to an optimized method for pathogen DNA detection based on deep learning. Background Technology

[0002] Pathogen DNA detection has crucial applications in clinical diagnosis, food safety monitoring, environmental microbiology detection, and biosafety early warning. With the rapid development of high-throughput sequencing technology and its continuous cost reduction, sequencing-based pathogen detection methods have become mainstream. Among them, nanopore sequencing technology, with its advantages of long reads, real-time sequencing, and portability, has shown significant application potential in rapid pathogen detection scenarios.

[0003] However, existing nanopore sequencing-based pathogen DNA detection methods face the following technical bottlenecks in practical applications: First, the raw data generated by nanopore sequencing is an electrical signal sequence representing the change of ion current over time, rather than a direct DNA base sequence. Current methods generally employ a two-stage cascaded processing approach: first, base recognition converts the electrical signal into a DNA sequence, and then pathogen identification is performed based on the sequence. This approach suffers from severe information loss: the base recognition process is essentially a lossy compression of the electrical signal into base symbols, irreversibly discarding a large amount of fine feature information contained within the electrical signal waveform. Studies have shown that the electrical signal waveform of nanopore sequencing encodes base modification information, sequence context-dependent kinetic features, and local structural features, which are of significant value in distinguishing closely related pathogens, but are discarded after traditional base recognition.

[0004] Second, pathogen DNA detection inherently faces a trade-off between sensitivity and specificity in clinical and public health settings. Fixed-threshold detection methods cannot adapt to the diverse performance requirements of different application scenarios. For example, in early infectious disease screening, the consequences of missed detections far outweigh those of false positives, thus requiring a high-sensitivity (low false negative rate) detection strategy. Conversely, in pathogen diagnosis, false positives can lead to misdiagnosis and inappropriate medication, necessitating a high-specificity (low false positive rate) detection strategy. Existing methods employ uniform, fixed thresholds, making it impossible to dynamically adjust detection strategies based on actual application needs, thus hindering the achievement of a controllable balance between sensitivity and specificity.

[0005] Third, host DNA contamination in complex background samples severely impacts detection accuracy. Clinical samples (such as blood, sputum, and tissue biopsy samples) and food samples typically contain large amounts of host or other non-target organism DNA, and pathogen DNA signals are often submerged in strong background noise. While existing deep learning methods can learn pathogen characteristics at the sequence level to some extent, their detection performance drops sharply when processing low-abundance pathogen samples due to a lack of utilization of fine features at the electrical signal level and effective suppression mechanisms for background noise.

[0006] Fourth, in existing technologies, the processing of electrical signals and DNA sequences in nanopore sequencing are treated as two independent steps, lacking an end-to-end joint optimization mechanism. Base recognition networks focus only on the accuracy of the electrical signal-to-base conversion, while pathogen classification networks focus only on sequence-level classification performance. The two networks are trained independently, failing to achieve cross-level gradient backpropagation and joint parameter optimization, resulting in overall detection performance being limited by the performance bottlenecks of these two independent steps.

[0007] In summary, existing technical solutions suffer from four major technical problems: insufficient utilization of fine features of electrical signals, inability to dynamically adjust detection thresholds, weak detection capability for low-abundance samples, and lack of joint optimization of electrical signal processing and sequence analysis. There is an urgent need for a pathogen DNA detection method that can fully exploit the feature information of electrical signals, achieve dynamic adjustment of detection strategies, suppress complex background interference, and complete end-to-end joint optimization. Summary of the Invention

[0008] To achieve the above objectives, this invention provides a deep learning-based optimized method for pathogen DNA detection, comprising the following steps: Step 1: Obtain the raw ion current time series data generated by the nanopore sequencing platform during real-time sequencing of the sample to be tested, denoted as the first electrical signal data. The sampling frequency of the first electrical signal data is 4000 to 5000 times per second, and the current value of each sampling point ranges from 0 picoamperes to 250 picoamperes. Obtain the first DNA sequence data output by the base recognizer built into the nanopore sequencing platform after base recognition of the first electrical signal data. The first DNA sequence data is a string sequence composed of four base characters: adenine A, thymine T, cytosine C, and guanine G. Step 2: Input the first electrical signal data obtained in Step 1 into the electrical signal feature enhancement and extraction network in the first-stage deep neural network, and output the first electrical signal feature vector, which has a dimension of 256. Step 3: Input the first DNA sequence data obtained in Step 1 into the sequence feature encoding network in the first-stage deep neural network, and output the first sequence feature vector, which has a dimension of 256. Step 4: Input the first electrical signal feature vector output in Step 2 and the first sequence feature vector output in Step 3 into the feature layer fusion network in the first stage deep neural network, and output the first fused feature vector, which has a dimension of 256. Step 5: Input the first fused feature vector output in Step 4 into the first pathogen classification network in the first stage deep neural network, and output the probability value of the existence of the first pathogen, which ranges from 0 to 1. Step 6: Compare the probability value of the first pathogen output in Step 5 with the preset first filtering threshold, which is 0.15; when the probability value of the first pathogen is greater than the first filtering threshold, proceed to Step 7; when the probability value of the first pathogen is less than or equal to the first filtering threshold, directly output the detection result as no target pathogen detected and terminate the detection process. Step 7: Input the first electrical signal feature vector output in Step 2 into the temporal context coding network in the second-stage deep neural network, and output the first electrical signal context feature vector. The first electrical signal context feature vector has a dimension of 128. Step 8: Input the first electrical signal context feature vector output in Step 7 and the first sequence feature vector output in Step 3 into the cross-attention fusion network in the second-stage deep neural network, and output the second fused feature vector, which has a dimension of 128. Step 9: Input the second fusion feature vector output in Step 8 into the second pathogen classification network in the second-stage deep neural network, and output the probability value of the existence of the second pathogen. The probability value of the existence of the second pathogen ranges from 0 to 1. Step 10: Obtain the user-specified application scenario parameters, which include any one of high-sensitivity mode identifier, standard mode identifier, and high-specificity mode identifier; determine the corresponding judgment threshold based on the application scenario parameters: when the application scenario parameter is a high-sensitivity mode identifier, the judgment threshold is 0.35; when the application scenario parameter is a standard mode identifier, the judgment threshold is 0.50; when the application scenario parameter is a high-specificity mode identifier, the judgment threshold is 0.65; compare the probability value of the second pathogen's presence output in Step 9 with the judgment threshold; when the probability value of the second pathogen's presence is greater than the judgment threshold, output the detection result as "target pathogen detected"; when the probability value of the second pathogen's presence is less than or equal to the judgment threshold, output the detection result as "target pathogen not detected".

[0009] Preferably, the specific structure of the electrical signal feature enhancement and extraction network in step 2 is as follows: The first layer is a one-dimensional convolutional layer with a kernel size of 7, a stride of 1, and 64 output channels. The second layer is a batch normalization layer; The third layer is a modified linear unit activation layer; The fourth layer is a one-dimensional convolutional layer with a kernel size of 5, a stride of 1, and 128 output channels. The fifth layer is a batch normalization layer; The sixth layer is a modified linear unit activation layer; The seventh layer is a one-dimensional convolutional layer with a kernel size of 3, a stride of 1, and 256 output channels. The eighth layer is a max pooling layer with a pooling kernel size of 2 and a pooling step size of 2; The ninth layer is the first residual connection module. The first residual connection module contains two one-dimensional convolutional layers with a kernel size of 3, a stride of 1, and 256 output channels, and one identity skip connection. The input feature map of the first residual connection module is added element-wise with the output feature map of the second one-dimensional convolutional layer in the first residual connection module. The tenth layer is the second residual connection module. The second residual connection module contains two one-dimensional convolutional layers with a kernel size of 3, a stride of 1, and 256 output channels, and one identity skip connection. The input feature map of the second residual connection module is added element-wise with the output feature map of the second one-dimensional convolutional layer in the second residual connection module. The eleventh layer is a global average pooling layer, which calculates the feature average of the input feature map at all time steps in each channel dimension; The twelfth layer is a fully connected layer with 256 input and 256 output dimensions.

[0010] Preferably, the specific process of the sequence feature encoding network in step 3 encoding the first DNA sequence data is as follows: The first DNA sequence data was used to extract k-mer fragments using a sliding window method with a step size of 1. K-mer fragments of length 3, 4, 5, 6 and 7 were extracted respectively. For k-mer fragments of length 3, the frequency of each 3-mer combination in the first DNA sequence data is counted, a 3-mer frequency vector is constructed, and the 3-mer frequency vector is summed and normalized to obtain a 3-mer normalized frequency vector. For each 4-mer fragment of length 4, the frequency of each 4-mer combination in the first DNA sequence data is counted, a 4-mer frequency vector is constructed, and the 4-mer frequency vector is summed and normalized to obtain a 4-mer normalized frequency vector. For k-mer fragments of length 5, the frequency of each 5-mer combination in the first DNA sequence data is counted, a 5-mer frequency vector is constructed, and the 5-mer frequency vector is summed and normalized to obtain a 5-mer normalized frequency vector. For k-mer fragments of length 6, the frequency of each 6-mer combination in the first DNA sequence data is counted, a 6-mer frequency vector is constructed, and the 6-mer frequency vector is summed and normalized to obtain a 6-mer normalized frequency vector. For k-mer fragments of length 7, the frequency of each 7-mer combination in the first DNA sequence data is counted, a 7-mer frequency vector is constructed, and the 7-mer frequency vector is summed and normalized to obtain a 7-mer normalized frequency vector. The 3-mer normalized frequency vector, 4-mer normalized frequency vector, 5-mer normalized frequency vector, 6-mer normalized frequency vector, and 7-mer normalized frequency vector are concatenated in the order of 3-mer, 4-mer, 5-mer, 6-mer, and 7-mer to obtain the concatenated k-mer frequency vector. The concatenated k-mer frequency vector is input into a fully connected layer for linear transformation. The output dimension of the fully connected layer is 256, and the first sequence feature vector is output.

[0011] Preferably, in step 4, the feature layer fusion network performs an element-wise weighted summation operation on the first electrical signal feature vector and the first sequence feature vector. The element-wise weighted summation operation is performed according to the following formula: ; in: This is the first fused feature vector; The first electrical signal feature vector; The first sequence feature vector; This represents element-wise multiplication. This is a learnable attention weight vector; The learnable attention weight vector is generated as follows: the first electrical signal feature vector and the first sequence feature vector are concatenated in the feature dimension to obtain a concatenated feature vector with a dimension of 512. The concatenated feature vector is then input into a fully connected layer for linear transformation. The fully connected layer has an input dimension of 512 and an output dimension of 256. The output vector of the fully connected layer is then input into a Sigmoid activation function for nonlinear transformation to obtain the learnable attention weight vector. The learnable attention weight vector is automatically updated during the first stage of deep neural network training using the gradient backpropagation algorithm.

[0012] Preferably, the specific structure of the temporal context coding network in step 7 is as follows: The first layer is a bidirectional gated recurrent unit layer. The input feature dimension of the bidirectional gated recurrent unit layer is 256-dimensional. The forward hidden state dimension of the bidirectional gated recurrent unit layer is 64-dimensional, and the backward hidden state dimension is 64-dimensional. The bidirectional gated recurrent unit layer concatenates the forward hidden state and the backward hidden state in the feature dimension, and outputs a temporal feature sequence with a dimension of 128-dimensional. The second layer is a self-attention layer with a query projection dimension of 128, a key projection dimension of 128, a value projection dimension of 128, and 4 self-attention heads. The self-attention layer calculates a multi-head self-attention weighted representation of the temporal feature sequence output by the bidirectional gated recurrent unit layer. The third layer is a global average pooling layer. The global average pooling layer calculates the feature average of all time steps in the multi-head self-attention weighted representation output by the self-attention layer in the time step dimension, and outputs the first electrical signal context feature vector, which has a dimension of 128.

[0013] Preferably, the cross-attention fusion network in step 8 adopts a multi-head cross-attention mechanism, and the specific calculation process of the cross-attention fusion network is as follows: The first electrical signal context feature vector is mapped to a query matrix through the first linear layer. The first linear layer has an input dimension of 128 and an output dimension of 128. The first sequence feature vector is mapped to a key matrix through the second linear layer. The second linear layer has an input dimension of 256 and an output dimension of 128. The first sequence feature vector is mapped to a value matrix through the third linear layer. The input dimension of the third linear layer is 256 dimensions, and the output dimension is 128 dimensions. The query matrix, key matrix, and value matrix are each divided along the dimension of 4 attention heads, resulting in 4 sets of query submatrices, 4 sets of key matrices, and 4 sets of value submatrices. Calculate the scaled dot product attention score for each query submatrix, key submatrix, and value submatrix. The formula for calculating the scaled dot product attention score is as follows: ; in: For the i-th query submatrix, Let i be the key matrix of the i-th group. Let i be the value submatrix of the i-th group. Let be the dimension of the key matrix; The four sets of scaled dot product attention calculation results are concatenated along the feature dimension to obtain a multi-head attention concatenation vector, which has a dimension of 128. The multi-head attention concatenation vector is input into the fourth linear layer for linear transformation. The fourth linear layer has an input dimension of 128 and an output dimension of 128, outputting the second fused feature vector.

[0014] Preferably, the specific structure of the first pathogen classification network in step 5 is as follows: The first layer is a fully connected layer with an input dimension of 256 and an output dimension of 64. The second layer is a modified linear unit activation layer; The third layer is a random drop layer with a drop rate of 0.3. The fourth layer is a fully connected layer with an input dimension of 64 and an output dimension of 32. The fifth layer is a modified linear unit activation layer; The sixth layer is a Softmax classification layer, which outputs two category probability values: the first category probability value is the probability value of the presence of the target pathogen, and the second category probability value is the probability value of the absence of the target pathogen. The probability value of the presence of the first pathogen output in step 5 is the probability value of the first category.

[0015] Preferably, the specific structure of the second pathogen classification network in step 9 is as follows: The first layer is a fully connected layer with an input dimension of 128 and an output dimension of 64. The second layer is a modified linear unit activation layer; The third layer is a fully connected layer with an input dimension of 64 and an output dimension of 32. The fourth layer is a modified linear unit activation layer; The fifth layer is a random drop layer with a drop rate of 0.2. The sixth layer is a fully connected layer with an input dimension of 32 and an output dimension of 16. The seventh layer is a modified linear unit activation layer; The eighth layer is a single Sigmoid classification layer, which outputs a single probability value. The probability value of the second pathogen output in step 9 is the probability value output by the Sigmoid classification layer.

[0016] Preferably, the method for acquiring the first electrical signal data in step 1 is as follows: read the real-time ion current signal generated by each nanopore channel in the sequencing chip from the data acquisition interface of the nanopore sequencing platform. The sampling time interval of each current signal is 200 microseconds to 250 microseconds. Arrange the continuously sampled current values ​​in the order of sampling time to form the first electrical signal data. The method for obtaining the first DNA sequence data in step 1 is as follows: the base recognizer built into the nanopore sequencing platform is called to process the first electrical signal data in real time. The base recognizer uses a hidden Markov model to segment the current signal fragment and decode the base state, outputting base characters with a quality score greater than or equal to 7, which are arranged in the order of base calls to form the first DNA sequence data.

[0017] Preferably, the electrical signal feature enhancement extraction network, the sequence feature encoding network, the feature layer fusion network, and the first pathogen classification network together constitute a first-stage deep neural network. The first-stage deep neural network is pre-trained using a labeled pathogen DNA sequencing dataset before deployment and use, and the training loss function is the classification cross-entropy loss function. The temporal context encoding network, the cross-attention fusion network, and the second pathogen classification network together constitute the second-stage deep neural network. The second-stage deep neural network is trained using the same dataset as the first-stage deep neural network before deployment and use. The training processes of the first-stage deep neural network and the second-stage deep neural network are carried out independently. Each sample in the labeled pathogen DNA sequencing dataset includes: the original ion current time series data of the sample, the DNA sequence data corresponding to the sample, and a binary label indicating whether the sample contains the target pathogen; the ratio of the number of positive samples containing the target pathogen to the number of negative samples not containing the target pathogen in the labeled pathogen DNA sequencing dataset is 1 to 1.

[0018] The beneficial effects of this invention are: 1. This invention constructs a dual-parallel architecture of an electrical signal feature enhancement extraction network and a sequence feature encoding network in the first-stage deep neural network, and performs element-wise weighted summation of the electrical signal feature vector and the DNA sequence feature vector in the feature layer fusion network with learnable attention weights. This adaptively fuses the base modification information and dynamic features contained in the original electrical signal waveform of nanopore sequencing with the sequence features in a unified feature space, overcoming the technical defect of irreversible loss of fine electrical signal features in the traditional two-stage serial process of base identification followed by sequence analysis.

[0019] 2. This invention adopts a two-stage cascaded detection architecture. In the first stage, a lightweight network and a low filtering threshold are used to quickly screen samples and filter out obviously negative samples. In the second stage, a temporal context coding network and a cross-attention fusion network are used to perform fine analysis on the filtered samples. The electrical signal context features are used as queries to guide the attention weighting of sequence features. While ensuring detection accuracy, the overall computational overhead is effectively reduced, and an optimized balance between detection efficiency and detection accuracy is achieved.

[0020] 3. This invention introduces user-specifiable application scenario parameters, with judgment thresholds of 0.35, 0.50, and 0.65 corresponding to high-sensitivity mode, standard mode, and high-specificity mode, respectively. This allows the same deep neural network model to dynamically adjust the detection and judgment strategy without changing the network structure or retraining, meeting the differentiated sensitivity and specificity requirements of different application scenarios such as early screening of infectious diseases, routine testing, and pathogen diagnosis. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in this invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.

[0022] Figure 1 This is a flowchart of the steps of the method of the present invention. Detailed Implementation

[0023] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. It should also be noted that, to make the embodiments more comprehensive, the following embodiments are the best and preferred embodiments, and those skilled in the art can use other alternative methods to implement some well-known technologies; moreover, the accompanying drawings are only for more specific description of the embodiments and are not intended to specifically limit the present invention.

[0024] Please see Figure 1This invention provides a deep learning-based optimization method for pathogen DNA detection. The overall process of this method comprises ten steps, divided into a data acquisition stage, a first-stage rapid screening stage, a second-stage fine analysis stage, and a dynamic threshold determination stage. Each step is executed sequentially, with the output of the previous step serving as the input for the subsequent steps, forming an end-to-end detection process.

[0025] Step 1: Obtain raw electrical signal data and DNA sequence data from nanopore sequencing This step involves data acquisition. The raw ion current signal generated during real-time sequencing of the sample is read from the data acquisition interface of the nanopore sequencing platform. In the nanopore sequencing platform, single-stranded DNA passes through nanopore proteins embedded in a lipid bilayer under the drive of an electric field. The base sequence on the DNA strand affects the amount of ion current passing through the nanopore, generating a current fluctuation signal related to the base sequence. The data acquisition interface continuously reads the real-time current value of each nanopore channel in the sequencing chip, with a sampling interval of 200 to 250 microseconds, corresponding to a sampling frequency of 4000 to 5000 times per second. One current value is recorded for each sampling point, with the current value ranging from 0 picoamperes to 250 picoamperes. The continuously sampled current values ​​are arranged in chronological order to form the first electrical signal data.

[0026] Simultaneously, the base recognizer built into the nanopore sequencing platform is invoked to perform real-time base recognition processing on the first electrical signal data. The base recognizer uses a Hidden Markov Model (HMM) to segment the current signal for identification. Specifically, the continuous current signal is divided into event segments, each corresponding to a current characteristic pattern generated when a specific base passes through the nanopore. The most probable base sequence is determined using the Viterbi decoding algorithm of the HMM. The base recognizer outputs base characters with a quality score greater than or equal to 7, represented by the Phred quality score. A quality score of 7 corresponds to a base recognition error probability of approximately 20%. Base characters meeting the quality requirements are arranged in the order of base retrieval to form the first DNA sequence data. The first DNA sequence data consists of four base characters: adenine (A), thymine (T), cytosine (C), and guanine (G).

[0027] The first electrical signal data and the first DNA sequence data together constitute the raw input for subsequent deep neural network processing. The first electrical signal data retains complete current waveform morphology information during nanopore sequencing, including fine information such as base modification features, sequence context-dependent kinetic features, and local structural features. The first DNA sequence data provides a discrete sequence representation at the base level, facilitating sequence-level feature encoding.

[0028] Step 2: Electrical signal feature enhancement and extraction The first electrical signal data obtained in step 1 is input into the electrical signal feature enhancement and extraction network in the first-stage deep neural network. The function of this network is to extract discriminative deep electrical signal feature representations from the original ion current time series.

[0029] The electrical signal feature enhancement and extraction network adopts a hierarchical convolutional structure design, specifically comprising the following sequentially connected network layers: The first layer is a one-dimensional convolutional layer with a kernel size of 7, a stride of 1, and 64 output channels. This convolutional layer performs a convolution operation on the input first electrical signal data along the time dimension. Each convolution kernel covers 7 consecutive sampling points to calculate a local weighted sum, and 64 different local pattern features of the current waveform are extracted through 64 different convolution kernels.

[0030] The second layer is a batch normalization layer. The batch normalization layer calculates the mean and variance along the time dimension for each channel feature map output from the first layer, performing a standardization transformation so that the transformed feature values ​​follow a distribution with a mean of 0 and a variance of 1. The purpose of the batch normalization layer is to accelerate the network training convergence speed and stabilize the gradient propagation process.

[0031] The third layer is a modified linear unit activation layer. The modified linear unit activation function is expressed as f(x)=max(0,x), which performs non-linear activation on each element of the input and outputs the larger value between the input value and 0.

[0032] The fourth layer is a one-dimensional convolutional layer with a kernel size of 5, a stride of 1, and 128 output channels. This layer receives 64 feature maps from the third layer and further extracts higher-level waveform features through 128 convolutional kernels.

[0033] The fifth layer is a batch normalization layer that standardizes the feature maps output from the fourth layer.

[0034] The sixth layer is a modified linear unit activation layer that performs nonlinear activation on the output of the fifth layer.

[0035] The seventh layer is a one-dimensional convolutional layer with a kernel size of 3, a stride of 1, and 256 output channels. This layer expands the number of feature map channels to 256, further enriching the feature representation.

[0036] The eighth layer is a max pooling layer with a kernel size of 2 and a stride of 2. The max pooling layer takes the maximum value of every two adjacent sampling points in the time dimension for each feature map, compressing the time length of the feature map to half of its original length while retaining the strongest response feature.

[0037] The ninth layer is the first residual connection module. The residual connection module is used to solve the vanishing gradient problem in deep neural network training. Internally, the first residual connection module contains two one-dimensional convolutional layers with a kernel size of 3, a stride of 1, and 256 output channels, and one identity skip connection. The feature map input to the first residual connection module passes through two parallel paths: the main path sequentially passes through the first convolutional layer, a batch normalization layer, a modified linear unit activation layer, the second convolutional layer, and the batch normalization layer; the skip connection path directly passes the input feature map as is. The output feature maps from both paths are element-wise summed before being output through the modified linear unit activation layer.

[0038] The tenth layer is the second residual connection module. The structure of the second residual connection module is exactly the same as the first, consisting of two one-dimensional convolutional layers with a kernel size of 3, a stride of 1, and 256 output channels, and one identity skip connection. The second residual connection module further refines the features of the output of the first residual connection module.

[0039] The eleventh layer is a global average pooling layer. The global average pooling layer calculates the average value of the feature map of each channel output by the tenth layer across all time positions in the time dimension, compressing the two-dimensional feature map of each channel into a single scalar value, and finally outputting a 256-dimensional feature vector.

[0040] The twelfth layer is a fully connected layer with 256-dimensional input and output. The fully connected layer performs a linear combination transformation on the 256-dimensional feature vector output from the global average pooling layer, outputting the first electrical signal feature vector.

[0041] The aforementioned electrical signal feature enhancement and extraction network achieves multi-scale feature extraction through a progressively smaller convolutional kernel design (7, 5, 3): larger convolutional kernels capture the overall pattern of the current waveform over a wider time range, while smaller convolutional kernels capture local, fine waveform details. The introduction of residual connection modules makes the training of deep convolutional networks more stable and effectively extracts high-level abstract features from electrical signals.

[0042] Step 3: DNA sequence feature encoding The first DNA sequence data obtained in step 1 is input into the sequence feature encoding network in the first-stage deep neural network. The function of this network is to convert the variable-length base string sequence into a fixed-dimensional numerical feature vector, which facilitates its fusion with the electrical signal feature vector.

[0043] The sequence feature coding network uses the k-mer frequency feature extraction method, and the specific process is as follows: K-mer fragments were extracted from the first DNA sequence data using a sliding window approach with a sliding window step size of 1. Starting from the first base position of the first DNA sequence data, K-mer fragments of length 3, 4, 5, 6, and 7 were extracted sequentially. The sliding window moved one base position forward each time, continuing to extract the next set of K-mer fragments until the sliding window covered the end of the sequence.

[0044] Frequency statistics were performed on each extracted k-mer fragment of different lengths: For a 3-mer fragment of length 3, there are 4 types of bases, resulting in 4^3 (64) possible combinations. The frequency of each 3-mer combination in the first DNA sequence data is counted, constructing a 64-bit 3-mer frequency vector. The 3-mer frequency vector is then summed and normalized by dividing each element by the sum of all elements in the vector to obtain the normalized 3-mer frequency vector.

[0045] For a k-mer segment of length 4, the total number of possible combinations is 4 to the power of 4, or 256. The frequency of each 4-mer combination is counted, a 4-mer frequency vector of length 256 is constructed, and then summed and normalized to obtain the normalized 4-mer frequency vector.

[0046] For a k-mer segment of length 5, the total number of possible combinations is 4 to the power of 5, or 1024. The frequency of each 5-mer combination is counted, a 5-mer frequency vector of length 1024 is constructed, and then summed and normalized to obtain the 5-mer normalized frequency vector.

[0047] For a k-mer segment of length 6, the total number of possible combinations is 4 to the power of 6, or 4096. The frequency of each 6-mer combination is counted, a 6-mer frequency vector of length 4096 is constructed, and then summed and normalized to obtain the 6-mer normalized frequency vector.

[0048] For a k-mer segment of length 7, the total number of possible combinations is 4 to the power of 7, or 16384. The frequency of each 7-mer combination is counted, a 7-mer frequency vector of length 16384 is constructed, and then summed and normalized to obtain the normalized 7-mer frequency vector.

[0049] The 3-mer, 4-mer, 5-mer, 6-mer, and 7-mer normalized frequency vectors are concatenated in the order 3-mer, 4-mer, 5-mer, 6-mer, and 7-mer, respectively. The total dimension of the concatenated vector is 64 + 256 + 1024 + 4096 + 16384, which equals 21824 dimensions.

[0050] The concatenated 21824-dimensional frequency vector is input into a fully connected layer for linear transformation. The fully connected layer has an input dimension of 21824 and an output dimension of 256. The fully connected layer uses the learned weight matrix to reduce the dimensionality and reorganize the features of the high-dimensional sparse k-mer frequency vector, outputting the first sequence feature vector.

[0051] The advantages of the k-mer frequency feature encoding method are: it does not rely on sequence alignment and has high computational efficiency; multi-length k-mer combinations cover sequence pattern information of different granularities, with short k-mers reflecting local base composition preferences and long k-mers reflecting sequence fragment specificity; and normalization processing eliminates the influence of sequence length differences on frequency statistics.

[0052] Step 4: Feature Layer Fusion The first electrical signal feature vector output from step 2 and the first sequence feature vector output from step 3 are input into the feature layer fusion network in the first-stage deep neural network. The function of the feature layer fusion network is to organically fuse the two heterogeneous features from the electrical signal mode and the sequence mode to form a unified feature representation.

[0053] The feature layer fusion network adopts an element-wise weighted summation fusion strategy based on learnable attention weights. The fusion process includes two sub-steps: attention weight generation and weighted fusion.

[0054] The attention weight generation sub-step involves concatenating the first electrical signal feature vector with the first sequence feature vector along their respective feature dimensions. Both the first electrical signal feature vector and the first sequence feature vector have a dimension of 256, resulting in a 512-dimensional concatenated feature vector. This concatenated feature vector is then input into a fully connected layer for linear transformation. The fully connected layer has an input dimension of 512 and an output dimension of 256. Finally, the output vector of the fully connected layer is input into a Sigmoid activation function for non-linear transformation. The mathematical expression for the Sigmoid activation function is: ; The Sigmoid activation function maps each element of the input to a value between 0 and 1, outputting a learnable attention weight vector. This learnable attention weight vector has 256 dimensions, with each element ranging from 0 to 1. This attention weight vector is automatically optimized and updated during the first stage of training the deep neural network using the gradient backpropagation algorithm.

[0055] The sub-step of weighted fusion is as follows: Perform an element-wise weighted summation operation on the first electrical signal feature vector and the first sequence feature vector according to the following formula: ; In the formula: This is the first fused feature vector output after fusion; The first electrical signal feature vector; The first sequence feature vector; This represents element-wise multiplication, which is the multiplication of corresponding elements of two vectors. This is a learnable attention weight vector.

[0056] The physical meaning of this fusion method is as follows: for each dimension of the feature vector, the corresponding element value in the attention weight vector determines whether electrical signal features or sequence features dominate in that dimension. An attention weight value close to 1 indicates that the dimension adopts more information from electrical signal features, while an attention weight value close to 0 indicates that the dimension adopts more information from sequence features. This adaptive weighting mechanism enables the fusion network to dynamically adjust the contribution ratio of the two modalities based on the characteristics of different input samples.

[0057] Step 5: First-stage pathogen classification The first fused feature vector output from step 4 is input into the first pathogen classification network in the first-stage deep neural network. The function of the first pathogen classification network is to perform preliminary classification on whether a sample contains the target pathogen based on the fused features.

[0058] The specific structure of the first pathogen classification network is as follows: The first layer is a fully connected layer with an input dimension of 256 and an output dimension of 64. The fully connected layer linearly maps the 256-dimensional first fused feature vector to the 64-dimensional feature space.

[0059] The second layer is a modified linear unit activation layer, which performs non-linear activation on the 64-dimensional feature vector output from the first layer.

[0060] The third layer is a random dropout layer with a dropout rate of 0.3. During training, the random dropout layer randomly sets some elements of the second layer's output feature vector to 0 with a probability of 0.3, and retains the original values ​​with a probability of 0.7, multiplying them by 1 and dividing by 0.7 for scaling. During inference and deployment, the random dropout layer does not perform the dropout operation and directly outputs the input features as is. The purpose of the random dropout layer is to prevent the network from overfitting the training data and improve its generalization ability.

[0061] The fourth layer is a fully connected layer with a 64-dimensional input and a 32-dimensional output. The fully connected layer further maps the 64-dimensional features to a 32-dimensional feature space.

[0062] The fifth layer is a modified linear unit activation layer that performs nonlinear activation on the 32-dimensional feature vector output from the fourth layer.

[0063] The sixth layer is a Softmax classification layer. The Softmax classification layer contains a fully connected operation that maps the 32-dimensional features into a 2-dimensional vector, and then applies the Softmax function to this 2-dimensional vector for probability normalization. The mathematical expression for the Softmax function is: ; The Softmax classification layer outputs two probability values: the 0th probability value represents the probability of the target pathogen being present, and the 1st probability value represents the probability of the target pathogen not being present. The probability value of the first pathogen being present is taken from the 0th probability value, and its range is from 0 to 1.

[0064] Step 6: First-stage rapid screening The probability value of the presence of the first pathogen output in step 5 is compared with the preset first filtering threshold. The first filtering threshold is set to 0.15.

[0065] When the probability value of the first pathogen is greater than 0.15, it indicates that the sample is suspected of containing the target pathogen and needs to proceed to the next step for more detailed analysis. The detection process continues to step 7.

[0066] When the probability value of the first pathogen is less than or equal to 0.15, it indicates that the sample is highly likely not to contain the target pathogen. The detection process directly outputs the detection result as "no target pathogen detected" and terminates the detection, without executing steps 7 to 10.

[0067] The initial filtering threshold of 0.15 was determined through statistical analysis of a large number of samples, enabling rapid filtering of most negative samples while maintaining an extremely low false negative rate. The first-stage deep neural network is designed as a lightweight network with low computational overhead, suitable for rapid initial screening of all input samples. The second-stage deep neural network has a more complex structure and higher computational overhead, performing detailed analysis only on suspected positive samples that have passed the initial screening. This two-stage cascaded architecture achieves an optimized balance between detection speed and detection accuracy.

[0068] Step 7: Electrical signal timing context coding The first electrical signal feature vector output from step 2 is input into the temporal context encoding network in the second-stage deep neural network. The function of the temporal context encoding network is to further capture long-range dependencies and contextual information in the time dimension based on the first electrical signal feature vector.

[0069] The specific structure of the temporal context coding network is as follows: The first layer consists of a single bidirectional gated recurrent unit (NRU) layer. A NRU is a variant of a recurrent neural network that controls information flow through two gating mechanisms: an update gate and a reset gate. The update gate controls the proportion of hidden state information from the previous time step retained in the current time step, while the reset gate controls the degree of influence of the hidden state from the previous time step on the current candidate state. The bidirectional gated NRU layer contains one forward-gated NRU and one backward-gated NRU. The forward-gated NRU processes the first electrical signal feature sequence sequentially from front to back, outputting a 64-dimensional forward hidden state at each time step. The backward-gated NRU processes the first electrical signal feature sequence in reverse chronological order from back to front, outputting a 64-dimensional backward hidden state at each time step. For each time step, the forward and backward hidden states are concatenated along the feature dimensions to obtain a 128-dimensional concatenated hidden state. The bidirectional gated NRU layer ultimately outputs a temporal feature sequence with a length equal to the number of time steps in the input sequence, and each time step has a 128-dimensional feature dimension.

[0070] The second layer consists of one self-attention layer. The query projection dimension, key projection dimension, and value projection dimension of the self-attention layer are all 128-dimensional, with 4 self-attention heads. The self-attention layer maps the features at each time step of the temporal feature sequence to query vectors, key vectors, and value vectors using three independent linear projection matrices. Based on the 4 attention heads, the query vector, key vector, and value vector are divided into four groups along the feature dimensions, each group having 32 dimensions. A scaled dot product attention score is calculated for each group using the following formula: ; In the formula: This is the i-th query submatrix; Let i be the key matrix of the i-th group; Let i be the value submatrix of the i-th group; Let be the transpose of the i-th key matrix; The scaling factor √32 is used to prevent the dot product value from becoming too large, which would cause the Softmax function to enter the gradient saturation region.

[0071] The four sets of attention calculation results are concatenated along the feature dimension to restore a 128-dimensional multi-head attention output sequence. The self-attention layer can effectively capture the temporal dependencies that span long distances in the feature sequence of electrical signals by calculating the attention weights between any two time steps in the sequence.

[0072] The third layer is a global average pooling layer. The global average pooling layer calculates the feature average of the multi-head attention output sequence from the self-attention layer across all time steps. The feature dimension of the self-attention layer output sequence is 128-dimensional. After global average pooling, each feature dimension outputs a scalar value, resulting in a 128-dimensional feature vector, which is the first electrical signal context feature vector.

[0073] The temporal context coding network captures local temporal dependencies through a bidirectional gated recurrent unit layer and captures global long-range dependencies through a self-attention layer. The combination of the two enables the output first electrical signal context feature vector to simultaneously contain local dynamic information and global context information.

[0074] Step 8: Cross-attention fusion The first electrical signal context feature vector output from step 7 and the first sequence feature vector output from step 3 are input into the cross-attention fusion network in the second-stage deep neural network. The function of the cross-attention fusion network is to use the electrical signal context features as a guide to perform attention-weighted recombination of the sequence features, thereby achieving deep fusion of the two modal features.

[0075] The cross-attention fusion network employs a multi-head cross-attention mechanism, and the specific calculation process is as follows: The first step is to map the first electrical signal context feature vector into a query matrix through the first linear layer. The first linear layer has an input dimension of 128 and an output dimension of 128.

[0076] The second step involves mapping the feature vectors of the first sequence to a key matrix through a second linear layer. The second linear layer has an input dimension of 256 and an output dimension of 128.

[0077] The third step involves mapping the first sequence feature vector into a value matrix through a third linear layer. The input dimension of the third linear layer is 256, and the output dimension is 128.

[0078] The fourth step is to partition the query matrix, key matrix, and value matrix according to the number of attention heads (4). The query matrix is ​​divided into 4 groups of query submatrices, each with a dimension of 32; the key matrix is ​​divided into 4 groups of key submatrices, each with a dimension of 32; and the value matrix is ​​divided into 4 groups of value submatrices, each with a dimension of 32.

[0079] Step 5: Calculate the scaled dot product attention score for each group of query submatrix, key submatrix, and value submatrix. For the i-th group, the calculation formula is: ; In the formula: This is the i-th query submatrix; Let i be the key matrix of the i-th group; Let i be the value submatrix of the i-th group; Let be the transpose of the i-th key matrix.

[0080] The sixth step is to concatenate the four attention calculation results along the feature dimension to obtain a 128-dimensional multi-head attention concatenation vector.

[0081] The seventh step involves inputting the multi-head attention concatenation vector into the fourth linear layer for linear transformation. The fourth linear layer has an input dimension of 128 and an output dimension of 128, outputting the second fused feature vector.

[0082] The core design idea of ​​the cross-attention fusion network is to use the contextual features of the electrical signal as the query vector and the sequence features as the key and value vectors. An attention mechanism is used to calculate the correlation weights between the contextual features and the sequence features, and then the sequence features are weighted and aggregated based on these weights. This mechanism allows the physical contextual information contained in the electrical signal to actively guide the selection and enhancement of the sequence features, ensuring that the fused features simultaneously contain the physical measurement characteristics of the electrical signal and the biological semantic characteristics of the sequence.

[0083] Step 9: Second-stage pathogen classification The second fused feature vector output from step 8 is input into the second pathogen classification network in the second-stage deep neural network. The function of the second pathogen classification network is to perform fine classification of samples based on the deep fused features.

[0084] The specific structure of the second pathogen classification network is as follows: The first layer is a fully connected layer with an input dimension of 128 and an output dimension of 64. The fully connected layer performs a linear transformation on the second fused feature vector.

[0085] The second layer is a modified linear unit activation layer, which performs non-linear activation on the 64-dimensional feature vector output from the first layer.

[0086] The third layer is a fully connected layer with a 64-dimensional input and a 32-dimensional output. The fully connected layer further compresses and reorganizes the features.

[0087] The fourth layer is a modified linear unit activation layer that performs nonlinear activation on the 32-dimensional feature vector output from the third layer.

[0088] The fifth layer is a single random dropout layer with a dropout rate of 0.2. Feature elements are randomly dropped with a probability of 0.2 during the training phase; no dropout operation is performed during the inference and deployment phase.

[0089] The sixth layer is a fully connected layer with a 32-dimensional input and a 16-dimensional output. The fully connected layer further compresses the features.

[0090] The seventh layer is a modified linear unit activation layer that performs nonlinear activation on the 16-dimensional feature vector output from the sixth layer.

[0091] The eighth layer is a Sigmoid classification layer. The Sigmoid classification layer contains a fully connected operation that maps the 16-dimensional features to a single scalar value, and then applies the Sigmoid function to this scalar value for probability transformation. The mathematical expression for the Sigmoid function is: ;

[0092] The Sigmoid classification layer outputs a probability value, which is the probability of the presence of the second pathogen, and the value ranges from 0 to 1.

[0093] Step 10: Dynamic Threshold Determination and Result Output Obtain the user-specified application scenario parameters. These parameters include any one of the following: high-sensitivity mode identifier, standard mode identifier, and high-specificity mode identifier. The user selects the appropriate application scenario mode based on their actual detection needs.

[0094] Determine the corresponding judgment threshold based on the application scenario parameters: When the application scenario parameter is set to the high-sensitivity mode, the decision threshold is set to 0.35. This mode is suitable for scenarios with low tolerance for missed detection, such as early screening for infectious diseases. Lowering the decision threshold can improve detection sensitivity and reduce false negative results.

[0095] When the application scenario parameters are set to the standard mode identifier, the decision threshold is 0.50. This mode is suitable for routine clinical testing scenarios, achieving a balance between sensitivity and specificity.

[0096] When the application scenario parameter is a high-specificity mode identifier, the decision threshold is set to 0.65. This mode is suitable for scenarios with low tolerance for false detection, such as pathogen diagnosis. Increasing the decision threshold can improve detection specificity and reduce false positive results.

[0097] Compare the probability value of the second pathogen's presence output in step 9 with the determined judgment threshold: When the probability value of the second pathogen is greater than the judgment threshold, the output detection result is that the target pathogen has been detected.

[0098] When the probability value of the second pathogen is less than or equal to the judgment threshold, the output detection result is "no target pathogen detected".

[0099] The aforementioned dynamic threshold determination mechanism enables the same deep neural network model to flexibly adapt to the differentiated detection requirements of different application scenarios, without the need to retrain the model or adjust the network structure for each scenario. Users only need to specify the application scenario parameters before detection begins, and the system automatically selects the corresponding determination threshold to complete the detection.

[0100] In this invention, the first-stage deep neural network comprises an electrical signal feature enhancement and extraction network, a sequence feature encoding network, a feature layer fusion network, and a first pathogen classification network. Before deployment, the first-stage deep neural network is pre-trained using a labeled pathogen DNA sequencing dataset. Each sample in the training dataset contains its original ion current time series data, its corresponding DNA sequence data, and a binary label indicating whether the sample contains the target pathogen. The ratio of positive samples containing the target pathogen to negative samples not containing the target pathogen in the training dataset is 1:1. The training loss function for the first-stage deep neural network is the classification cross-entropy loss function, and the Adam optimizer is used for training.

[0101] The second-stage deep neural network consists of a temporal context encoding network, a cross-attention fusion network, and a second pathogen classification network. Before deployment, the second-stage deep neural network is trained using the same dataset as the first-stage deep neural network. The training processes of the first and second-stage deep neural networks are performed independently, each optimizing its own network parameters. Example 1:

[0102] I. Sample preparation and sequencing data acquisition One 2.0 mL sputum sample was collected from a clinically suspected pulmonary tuberculosis patient. A standard sputum liquefaction procedure was followed: an equal volume of 2.0 mL of Putasol sputum digestion solution was added to the sputum sample, vortexed for 30 seconds, and then incubated at 200 rpm for 15 minutes at 37°C in a shaker to ensure complete liquefaction. The liquefied sample was centrifuged at 8000 g for 10 minutes, the supernatant was discarded, and the precipitate was retained. The precipitate was resuspended and washed with 1.0 mL of phosphate buffer, and centrifuged again at 8000 g for 5 minutes, and the supernatant was discarded. Total DNA was extracted from the precipitate using a commercially available pathogen DNA extraction kit, strictly following the kit's instructions. A final DNA extract volume of 50 μL was obtained. The concentration of the DNA extract was determined using a Qubit fluorometer, and the DNA concentration was found to be 18.5 ng / μL. Add 10 μL of DNA extract to sequencing library construction reagents to prepare the library. After the library is prepared, load the library into a nanopore sequencing chip.

[0103] The nanopore sequencing platform was started to begin real-time sequencing. Real-time ion current signals generated by each nanopore channel in the sequencing chip were read from the platform's data acquisition interface. The sampling time interval for each current signal was 250 microseconds, corresponding to a sampling frequency of 4000 times per second. The continuously sampled current values ​​were arranged in chronological order to form the first electrical signal data. In this embodiment, sequencing ran continuously for 30 minutes, collecting a total of 1.2 × 10⁻⁶ ions / μL. 7 There are 185 sampling points, with the current value at each sampling point ranging from 35 picoamperes to 185 picoamperes. Simultaneously, the base recognizer built into the nanopore sequencing platform is used to process the first electrical signal data in real time. The base recognizer uses a hidden Markov model to segment the current signal fragments and decode the base states, outputting base characters with a quality score greater than or equal to 7. These bases are arranged in the order of their call to form the first DNA sequence data. In this embodiment, the first DNA sequence data is 185,432 base characters long, composed of four base characters: adenine (A), thymine (T), cytosine (C), and guanine (G).

[0104] II. Enhanced Extraction of Electrical Signal Features from Deep Neural Networks in the First Stage The acquired first electrical signal data is input into the electrical signal feature enhancement and extraction network in the first-stage deep neural network. The first electrical signal data is divided into processing windows with a length of 4000 sampling points, with an overlap of 200 sampling points between adjacent windows, resulting in several input segments. Each input segment is then processed by the electrical signal feature enhancement and extraction network.

[0105] The specific structure of the electrical signal feature enhancement and extraction network is connected layer by layer in the following order: The first layer is a one-dimensional convolutional layer with a kernel size of 7, a stride of 1, and 64 output channels. This layer performs a one-dimensional convolution operation on the first input electrical signal data segment. The convolution kernel slides in the time dimension with a stride of 1, extracting the current waveform features within the local receptive field at each slide. The output channel of the convolution operation is 64 feature maps, and the length of each feature map is the same as the length of the input segment.

[0106] The second layer is a batch normalization layer. The batch normalization layer calculates the mean and variance for each of the 64 feature maps output from the first layer, and performs a standardization transformation on the feature values. The transformed feature values ​​have a mean of 0 and a variance of 1.

[0107] The third layer is a modified linear unit activation layer. The modified linear unit activation function performs an element-wise nonlinear transformation on each feature value of the second layer's output. When the input value is greater than 0, the output is the input value itself; when the input value is less than or equal to 0, the output is 0.

[0108] The fourth layer is a one-dimensional convolutional layer with a kernel size of 5, a stride of 1, and 128 output channels. This layer receives 64 feature maps from the output of the third layer, performs a one-dimensional convolution operation on the input feature maps using a kernel of size 5, and outputs 128 feature maps.

[0109] The fifth layer is a batch normalization layer. The batch normalization layer normalizes the 128 feature maps output from the fourth layer.

[0110] The sixth layer is a modified linear unit activation layer. The modified linear unit activation function performs nonlinear activation on the normalized eigenvalues ​​of the output of the fifth layer.

[0111] The seventh layer is a one-dimensional convolutional layer with a kernel size of 3, a stride of 1, and 256 output channels. This layer receives 128 feature maps from the output of the sixth layer, performs a one-dimensional convolution operation using a kernel with a kernel size of 3, and outputs 256 feature maps.

[0112] The eighth layer is a max pooling layer with a kernel size of 2 and a pooling stride of 2. The max pooling layer downsamples the 256 feature maps output from the seventh layer, retaining the maximum value among every two adjacent feature values ​​in the time dimension, thus reducing the length of the feature map to half of its original length.

[0113] The ninth layer is the first residual connection module. This module consists of two one-dimensional convolutional layers with a kernel size of 3, a stride of 1, and 256 output channels, and one identity skip connection. Specifically, the feature map input to the ninth layer first undergoes a one-dimensional convolution operation in the first convolutional layer, then passes through a batch normalization layer and a modified linear unit activation layer, followed by another one-dimensional convolution operation in the second convolutional layer. Finally, after passing through the batch normalization layer, it is element-wise added to the input feature map directly passed through the identity skip connection. The result is then output through the modified linear unit activation layer. The identity skip connection does not perform any parameter transformations; it directly adds the input feature map to the output of the convolutional path, effectively mitigating the gradient vanishing problem during deep network training.

[0114] The tenth layer is the second residual connection module. The structure of the second residual connection module is exactly the same as the first, consisting of two one-dimensional convolutional layers with a kernel size of 3, a stride of 1, and 256 output channels, and one identity skip connection. The second residual connection module receives the output feature map from the ninth layer as input, and after passing through the internal convolutional path and the identity skip connection path, outputs 256 feature maps.

[0115] The eleventh layer is a global average pooling layer. The global average pooling layer calculates the feature average across all time steps for each channel dimension of the 256 feature maps output by the tenth layer, outputting a scalar value for each channel. Since the tenth layer outputs feature maps with 256 channels, the global average pooling layer outputs a single 256-dimensional feature vector.

[0116] The twelfth layer is a fully connected layer. The fully connected layer contains 256 input neurons and 256 output neurons. Each output neuron is fully connected to all input neurons through learnable weight parameters. The fully connected layer receives the 256-dimensional feature vector output from the global average pooling layer, performs a linear transformation, and outputs a first electrical signal feature vector, which has a dimension of 256.

[0117] III. Sequence Feature Encoding in the First Stage of Deep Neural Networks The first DNA sequence data is input into the sequence feature encoding network in the first-stage deep neural network for feature encoding. The length of the first DNA sequence data is 185,432 base characters.

[0118] The specific process by which the sequence feature coding network encodes features of the first DNA sequence data is as follows: First, k-mer fragments are extracted from the first DNA sequence data using a sliding window method with a step size of 1. Specifically, starting from the first base position of the first DNA sequence data, three consecutive bases are extracted sequentially as the first 3-mer fragment, four consecutive bases as the first 4-mer fragment, five consecutive bases as the first 5-mer fragment, six consecutive bases as the first 6-mer fragment, and seven consecutive bases as the first 7-mer fragment. Then, the sliding window moves one base position forward, and the second set of k-mer fragments is extracted starting from the second base position, and so on, until the sliding window covers the end of the first DNA sequence data.

[0119] Secondly, all extracted k-mer fragments were classified and statistically analyzed: For each 3-mer fragment of length 3, the frequency of each 3-mer combination in the first DNA sequence data is counted. Since there are 4 types of bases, there are 4³ = 64 possible combinations for each 3-mer. All 3-mer fragments extracted from the first DNA sequence data are iterated through, and the occurrence frequency of each 3-mer combination is accumulated, constructing a 64-bit 3-mer frequency vector. Each element in the vector corresponds to the frequency of one 3-mer combination. The 3-mer frequency vector is then summed and normalized by dividing each element of the frequency vector by the sum of all elements in the vector, resulting in a normalized 3-mer frequency vector with a sum of 1.

[0120] The frequency of each 4-mer combination in the first DNA sequence data was counted for 4-mer fragments of length. There are 4 k-mers of length. 4 =256 possible combinations. Construct a 4-mer frequency vector of length 256 and perform sum-normalization to obtain a 4-mer normalized frequency vector.

[0121] The frequency of each 5-mer combination in the first DNA sequence data was counted for 5-mer fragments. There are 4 k-mers of 5 length. 5 =1024 possible combinations. Construct a 5-mer frequency vector of length 1024 and perform sum-normalization to obtain a 5-mer normalized frequency vector.

[0122] The frequency of each 6-mer combination in the first DNA sequence data was counted for 6-mer fragments. There are 4 k-mers of length. 6 =4096 possible combinations. Construct a 6-mer frequency vector of length 4096 and perform sum-normalization to obtain a 6-mer normalized frequency vector.

[0123] The frequency of each 7-mer combination in the first DNA sequence data was counted for 7-mer fragments of length. There are 4 k-mers of length. 7 =16384 possible combinations. Construct a 7-mer frequency vector of length 16384 and perform sum-normalization to obtain a 7-mer normalized frequency vector.

[0124] Then, the 3-mer normalized frequency vectors, 4-mer normalized frequency vectors, 5-mer normalized frequency vectors, 6-mer normalized frequency vectors, and 7-mer normalized frequency vectors are concatenated sequentially along the vector dimensions in the order of 3-mer, 4-mer, 5-mer, 6-mer, and 7-mer. The total dimension of the concatenated k-mer frequency vector is 64 + 256 + 1024 + 4096 + 16384 = 21824 dimensions.

[0125] Finally, the concatenated k-mer frequency vector is input into a fully connected layer for linear transformation. The fully connected layer has an input dimension of 21824 and an output dimension of 256. The fully connected layer contains 21824 input neurons and 256 output neurons, with each output neuron fully connected to all input neurons via learnable weight parameters. After the linear transformation by the fully connected layer, the concatenated k-mer frequency vector outputs a first sequence feature vector, which has a dimension of 256.

[0126] IV. Feature Layer Fusion in the First Stage of Deep Neural Networks The first electrical signal feature vector and the first sequence feature vector are input into the feature layer fusion network of the first-stage deep neural network. The first electrical signal feature vector is denoted as... The first sequence feature vector is denoted as .

[0127] The feature layer fusion network uses element-wise weighted summation to perform feature fusion. The fusion process is divided into two sub-steps: attention weight generation and weighted fusion.

[0128] The sub-step for generating attention weights is as follows: The first electrical signal feature vector and the first sequence feature vector are concatenated along their feature dimensions to obtain a 512-dimensional concatenated feature vector. This concatenated feature vector is then input into a fully connected layer for linear transformation. The fully connected layer has an input dimension of 512 and an output dimension of 256, containing 512 input neurons and 256 output neurons. Finally, the 256-dimensional vector output from the fully connected layer is input into a Sigmoid activation function for non-linear transformation. The mathematical expression for the Sigmoid activation function is: ; This function compresses the input values ​​to the range of 0 to 1. The output of the Sigmoid activation function is the learnable attention weight vector. ; The learnable attention weight vector is automatically updated through gradient backpropagation during the first stage of deep neural network training, without the need for manual setting of fixed weight values.

[0129] The sub-step of weighted fusion is as follows: The first electrical signal feature vector and the first sequence feature vector are summed element-wise with weights according to the following formula: ; in This represents element-wise multiplication, which is the multiplication of corresponding elements of two vectors with the same dimension.

[0130] This is the first fused feature vector output after the fusion operation.

[0131] The physical meaning of this fusion mechanism is as follows: for each dimension of the feature vector, the corresponding element in the attention weight vector determines whether more electrical signal features or more sequence features are retained at that dimension. The closer the attention weight is to 1, the more the fusion result at that dimension leans towards electrical signal features; the closer the attention weight is to 0, the more the fusion result at that dimension leans towards sequence features. This adaptive weighting mechanism enables the network to dynamically adjust the contribution ratio of the two feature modalities according to the characteristics of the input data.

[0132] V. First-stage deep neural network for primary pathogen classification and rapid screening The first fused feature vector is input into the first pathogen classification network in the first-stage deep neural network. The specific structure of the first pathogen classification network is as follows: The first layer is a fully connected layer with an input dimension of 256 and an output dimension of 64, containing 256 input neurons and 64 output neurons. The fully connected layer performs a linear transformation on the first fused feature vector of the input, compressing the 256-dimensional features into a 64-dimensional feature space.

[0133] The second layer is a modified linear unit activation layer. The modified linear unit activation function performs non-linear activation on each feature value of the first layer's output.

[0134] The third layer is a random dropout layer with a dropout rate of 0.3. During training, the random dropout layer randomly sets the output feature value of the second layer to 0 with a probability of 0.3, and retains the original feature value with a probability of 0.7, multiplying it by a coefficient of 1 / 0.7 for scaling. During inference and deployment, the random dropout layer does not perform the dropout operation and directly outputs the input feature value as is. The random dropout layer is used to prevent overfitting during network training.

[0135] The fourth layer is a fully connected layer with an input dimension of 64 and an output dimension of 32, containing 64 input neurons and 32 output neurons.

[0136] The fifth layer is a modified linear unit activation layer. The modified linear unit activation function performs nonlinear activation on the feature values ​​output from the fourth layer.

[0137] The sixth layer is a Softmax classification layer. The Softmax classification layer receives the 32-dimensional feature vector output from the fifth layer, and maps it to a 2-dimensional feature vector through a fully connected operation. Let the 2-dimensional feature vector be... ; Then, the Softmax function is applied to the 2D feature vectors for probability normalization. The mathematical expression of the Softmax function is: ; The Softmax classification layer outputs two category probability values: the 0th category probability value is the probability of the target pathogen being present, and the 1st category probability value is the probability of the target pathogen not being present. The probability of the first pathogen being present is the 0th category probability value, which ranges from 0 to 1.

[0138] In this embodiment, the probability value of the first pathogen output by the first pathogen classification network after processing the current input segment is 0.237.

[0139] The probability value of the presence of the first pathogen is compared with a preset first filtering threshold, which is set to 0.15. Since 0.237 is greater than 0.15, the input segment passes through the first stage of rapid screening and enters the second stage of deep neural network for fine analysis. It should be noted that if the probability value of the presence of the first pathogen is less than or equal to 0.15, the detection process will directly output the detection result as "target pathogen not detected" and terminate the detection, without proceeding to the second stage of processing, thereby saving computational resources and achieving rapid filtering of a large number of negative samples.

[0140] VI. Temporal Context Encoding of the Second-Stage Deep Neural Network The first electrical signal feature vector corresponding to the input segment selected in the first stage is input into the temporal context encoding network in the second-stage deep neural network. The first electrical signal feature vector is a 256-dimensional feature vector output by the electrical signal feature enhancement and extraction network.

[0141] The specific structure of the temporal context coding network is as follows: The first layer consists of a single bidirectional gated recurrent unit (BRN) layer. The input feature dimension of the BRN layer is 256. The BRN layer contains one forward-gated recurrent unit (FRU) and one backward-gated recurrent unit (BRN). The forward-gated recurrent unit processes the input feature sequence sequentially from front to back along the time steps, updating one forward hidden state at each time step. The forward hidden state has a dimension of 64. The backward-gated recurrent unit processes the input feature sequence sequentially from back to front along the time steps, updating one backward hidden state at each time step. The backward hidden state also has a dimension of 64. For each time step, the forward and backward hidden states are concatenated along the feature dimensions to obtain the concatenated hidden state for that time step, with a dimension of 64 + 64 = 128. Therefore, the BRN layer outputs a 128-dimensional temporal feature sequence, with a sequence length equal to the number of time steps in the input feature sequence. The gated recurrent unit incorporates two gating mechanisms: an update gate and a reset gate. The update gate controls the extent to which historical state information is retained in the current state, while the reset gate controls the degree to which historical state information influences the current candidate state. This bidirectional gated recurrent unit can simultaneously capture both forward and backward temporal dependencies in the current signal, effectively modeling the bidirectional contextual information present in the nanopore sequencing electrical signals.

[0142] The second layer consists of one self-attention layer. The self-attention layer has a 128-dimensional query projection dimension, a 128-dimensional key projection dimension, a 128-dimensional value projection dimension, and four self-attention heads. The self-attention layer receives the temporal feature sequence output from the bidirectional gated recurrent unit layer and calculates the query vector, key vector, and value vector for each time step feature in the temporal feature sequence. Specifically, the self-attention layer projects the 128-dimensional feature vector at each time step into a 128-dimensional query vector, a 128-dimensional key vector, and a 128-dimensional value vector using three independent linear projection matrices. Then, based on the four attention heads, the query vector, key vector, and value vector are divided into four groups, each with a 32-dimensional dimension. A scaled dot product attention score is calculated for each group using the following formula: ; in Let i be the query submatrix of the i-th group. Let i be the key matrix of the i-th group. Let i be the value submatrix of the i-th group. express The transpose of . Scaling factor To prevent the gradient of the Softmax function from vanishing due to excessively large dot product values, the four sets of attention calculation results are concatenated along the feature dimension to restore a 128-dimensional multi-head attention output sequence. The self-attention layer, by calculating the attention weights between features at any two time steps, can capture long-range dependencies in the electrical signal feature sequence, supplementing the shortcomings of the bidirectional gated recurrent unit layer in modeling local temporal dependencies.

[0143] The third layer is a global average pooling layer. The global average pooling layer calculates the average feature value across all time steps of the multi-head attention output sequence from the self-attention layer, outputting a scalar value for each feature dimension. Since the self-attention layer outputs a 128-dimensional feature vector, the global average pooling layer outputs a 128-dimensional feature vector, which is the first electrical signal context feature vector.

[0144] VII. Cross-attention fusion in the second stage of deep neural networks The first electrical signal context feature vector and the first sequence feature vector are input into the cross-attention fusion network in the second-stage deep neural network. The first electrical signal context feature vector has a dimension of 128, and the first sequence feature vector has a dimension of 256.

[0145] The cross-attention fusion network employs a multi-head cross-attention mechanism, and the specific calculation process is as follows: The first step is to map the context feature vector of the first electrical signal into a query matrix through the first linear layer. The first linear layer has an input dimension of 128 and an output dimension of 128, containing 128 input neurons and 128 output neurons. The mapped query matrix has a dimension of 128.

[0146] The second step involves mapping the first sequence feature vector into a key matrix through a second linear layer. The second linear layer has an input dimension of 256 and an output dimension of 128, containing 256 input neurons and 128 output neurons. The mapped key matrix has a dimension of 128.

[0147] The third step involves mapping the first sequence feature vector into a value matrix through a third linear layer. The third linear layer has an input dimension of 256 and an output dimension of 128, containing 256 input neurons and 128 output neurons. The mapped value matrix has a dimension of 128.

[0148] The fourth step involves partitioning the query matrix, key matrix, and value matrix according to the number of attention heads (4). The 128-dimensional query matrix is ​​divided into four sub-matrices, each with a 32-dimensional dimension; the 128-dimensional key matrix is ​​divided into four sub-key matrices, each with a 32-dimensional dimension; and the 128-dimensional value matrix is ​​divided into four sub-value matrices, each with a 32-dimensional dimension. This results in four sub-matrices. 4 sets of key matrices 4 sets of value submatrices .

[0149] Step 5: Calculate the scaled dot product attention score for each group of query submatrix, key submatrix, and value submatrix. For the i-th group, the formula for calculating the scaled dot product attention score is: ; The Softmax function normalizes each row of the attention score matrix so that the sum of the weights in each row is 1. The result is the attention output vector for the i-th group, which has 32 dimensions.

[0150] The sixth step involves concatenating the four sets of scaled dot product attention calculation results along the feature dimension to obtain a multi-head attention concatenated vector. The concatenation order is as follows: the attention output vectors of the first, second, third, and fourth groups are concatenated sequentially. The resulting multi-head attention concatenated vector has a dimension of 4 × 32 = 128.

[0151] Step 7: Input the multi-head attention concatenation vector into the 4th linear layer for linear transformation. The input dimension of the 4th linear layer is 128-dimensional, and the output dimension is 128-dimensional. After linear transformation, the second fused feature vector is output, which has a dimension of 128.

[0152] The core design idea of ​​the cross-attention fusion network is to use the contextual features of the electrical signal as the query and the sequence features as the key and value. Through an attention mechanism, the electrical signal features actively retrieve the sequence patterns most relevant to the electrical signal context from the sequence features. This design utilizes the physical context information contained in the electrical signals of nanopore sequencing to guide the weighted aggregation of sequence features, so that the fused features can simultaneously reflect the physical measurement characteristics of the electrical signal and the biological semantic characteristics of the sequence.

[0153] VIII. Second-stage deep neural network for second pathogen classification and dynamic threshold determination The second fused feature vector is input into the second pathogen classification network in the second-stage deep neural network. The specific structure of the second pathogen classification network is as follows: The first layer is a fully connected layer with an input dimension of 128 and an output dimension of 64, containing 128 input neurons and 64 output neurons.

[0154] The second layer is a modified linear unit activation layer. The modified linear unit activation function performs nonlinear activation on the feature values ​​output from the first layer.

[0155] The third layer is a fully connected layer with an input dimension of 64 and an output dimension of 32, containing 64 input neurons and 32 output neurons.

[0156] The fourth layer is a modified linear unit activation layer. The modified linear unit activation function performs nonlinear activation on the feature values ​​output from the third layer.

[0157] The fifth layer is a single random dropout layer with a dropout rate of 0.2. During the training phase, the output feature value of the fourth layer is randomly set to 0 with a probability of 0.2; no dropout operation is performed during the inference and deployment phase.

[0158] The sixth layer is a fully connected layer with an input dimension of 32 and an output dimension of 16, containing 32 input neurons and 16 output neurons.

[0159] The seventh layer is a modified linear unit activation layer. The modified linear unit activation function performs nonlinear activation on the feature values ​​output from the sixth layer.

[0160] The eighth layer is a Sigmoid classification layer. The Sigmoid classification layer contains a fully connected operation that maps the 16-dimensional features to 1-dimensional scalar values, and then applies the Sigmoid function to these scalar values ​​for probability transformation. The mathematical expression for the Sigmoid function is: ; The Sigmoid classification layer outputs a single probability value, which represents the probability of the second pathogen's presence, ranging from 0 to 1. In this embodiment, the probability of the second pathogen's presence output by the second pathogen classification network is 0.627.

[0161] Obtain the application scenario parameters specified by the user. In this embodiment, the detection scenario is the detection of sputum samples from clinically suspected pulmonary tuberculosis patients, which belongs to the early screening scenario for infectious diseases. The tolerance for false negatives is low. Therefore, the application scenario parameter specified by the user is the high-sensitivity mode identifier.

[0162] The corresponding judgment threshold is determined based on the application scenario parameters: when the application scenario parameter is a high-sensitivity mode identifier, the judgment threshold is 0.35; when the application scenario parameter is a standard mode identifier, the judgment threshold is 0.50; and when the application scenario parameter is a high-specificity mode identifier, the judgment threshold is 0.65. In this embodiment, since the application scenario parameter is a high-sensitivity mode identifier, the judgment threshold is 0.35.

[0163] The probability value of the presence of the second pathogen is compared with the judgment threshold. The probability value of the presence of the second pathogen is 0.627, and the judgment threshold is 0.35. Since 0.627 is greater than 0.35, the output detection result is "target pathogen detected". In this embodiment, the detection result is positive for Mycobacterium tuberculosis, which is consistent with the subsequent clinical bacterial culture verification results.

[0164] IX. Training Process of the First-Stage Deep Neural Network and the Second-Stage Deep Neural Network The first-stage deep neural network consists of an electrical signal feature enhancement and extraction network, a sequence feature encoding network, a feature layer fusion network, and a first pathogen classification network. Before deployment, the first-stage deep neural network is pre-trained using a labeled pathogen DNA sequencing dataset.

[0165] The second-stage deep neural network consists of a temporal context encoding network, a cross-attention fusion network, and a second pathogen classification network. Before deployment, the second-stage deep neural network is trained using the same dataset as the first-stage deep neural network.

[0166] The training process of the first-stage deep neural network and the training process of the second-stage deep neural network are carried out independently. That is, the training of the first-stage deep neural network is completed first, and the trained network parameters are saved; then, the parameters of the first-stage deep neural network are kept unchanged, and the second-stage deep neural network is trained.

[0167] The labeled pathogen DNA sequencing dataset was constructed as follows: 150 clinical sputum samples known to be positive for Mycobacterium tuberculosis and 150 clinical sputum samples known to be negative for Mycobacterium tuberculosis were collected. The same sequencing process as described above was used to obtain the raw ion current time-series data and corresponding DNA sequence data for each sample. For each sample, a fragment of 4000 sampling points was extracted from the raw ion current time-series data using a sliding window method, with each fragment corresponding to one training sample. The final training dataset contained 12000 positive sample fragments and 12000 negative sample fragments, with a 1:1 ratio of positive to negative samples. Each training sample included: the raw ion current time-series data of the sample fragment, the corresponding DNA sequence data of the sample fragment, and a binary label indicating whether the sample fragment contained the target pathogen (1 for positive and 0 for negative).

[0168] The training loss function for the first stage of the deep neural network is the classification cross-entropy loss function. The mathematical expression for the classification cross-entropy loss function is: ; in: N is the number of training samples. For the true label of the nth sample, This represents the probability value of the first pathogen's existence output by the first-stage deep neural network. The Adam optimizer was used for training, with an initial learning rate of 0.001, 50 training epochs, and 64 training samples per batch.

[0169] The training loss function for the second-stage deep neural network also adopts the classification cross-entropy loss function, the mathematical expression of which is: ; in: M is the number of training samples. Let m be the true label of the m-th sample. This represents the probability value of the second pathogen's existence output by the second-stage deep neural network. The Adam optimizer was used for training, with an initial learning rate of 0.0005, 40 training epochs, and 64 training samples per batch.

[0170] 10. Comparison of proportions and effects To verify the beneficial effects of the technical solution in this embodiment, the following three comparative examples are set up for performance comparison.

[0171] Comparative Example 1: Traditional sequence classification method after base recognition. This method uses only the first DNA sequence data output by the base recognizer built into the nanopore sequencing platform for Mycobacterium tuberculosis detection. After extracting the normalized frequency vectors of 3-mer to 7-mer from the first DNA sequence data, it is input into a shallow neural network consisting of two fully connected layers and one Softmax classification layer for classification, outputting the probability value of pathogen presence, with a fixed judgment threshold of 0.50.

[0172] Comparative Example 2: A deep learning method using only electrical signal features. This method only inputs the first electrical signal data into a convolutional neural network consisting of three one-dimensional convolutional layers, one max-pooling layer, and two fully connected layers for classification. It does not use DNA sequence features, nor does it use a two-stage cascaded architecture, and the decision threshold is fixed at 0.50.

[0173] Comparative Example 3: The technical solution of this embodiment uses a fixed threshold of 0.50. This method uses the exact same two-stage deep neural network architecture and fusion mechanism as this embodiment. The only difference is that in step 10, the judgment threshold is fixed at 0.50, and the threshold is not dynamically adjusted using application scenario parameters.

[0174] The test dataset was constructed using clinical sputum samples independent of the training dataset, containing 50 positive samples and 50 negative samples. Evaluation metrics included sensitivity, specificity, accuracy, and F1 score. The performance comparison results of each method on the test dataset are shown in Table 1.

[0175] Table 1 Comparison of the detection performance of different methods for Mycobacterium tuberculosis

[0176] The comparison results in Table 1 show that: In high-sensitivity mode, the technical solution of this embodiment achieves a sensitivity of 96.0%, significantly higher than Comparative Example 1 (78.0%), Comparative Example 2 (84.0%), and Comparative Example 3 (90.0%). This improved sensitivity is attributed to a multi-level fusion mechanism of electrical signal features and sequence features: the first stage preserves fine electrical signal features through element-wise weighted fusion; the second stage enhances the guidance of sequence features by the electrical signal context through cross-attention fusion, enabling the model to detect low-abundance pathogen signals. The specificity of this embodiment is 84.0%, slightly lower than Comparative Example 3's 88.0%, but this is the expected result achieved by lowering the judgment threshold from 0.50 to 0.35 to achieve high sensitivity, aligning with the design goals of high-sensitivity application scenarios. Comparative Example 2, using only electrical signal features, has a specificity of only 76.0%, indicating that using electrical signal features alone is easily affected by background noise, leading to an increased false positive rate. Comparative Example 1, using only sequence features, has a sensitivity of only 78.0%, indicating that information loss during base recognition severely restricts detection sensitivity.

[0177] This embodiment achieves a balance between computational efficiency and detection accuracy through a two-stage cascaded architecture: the first stage uses a low filtering threshold of 0.15 to quickly screen suspected positive samples and filter out a large number of obviously negative samples. In this embodiment's test, approximately 65% ​​of the samples were determined to be negative in the first stage, terminating the detection process and effectively reducing the computational overhead of the second stage's detailed analysis. The second stage performs temporal context modeling and cross-attention fusion on the screened samples to achieve high-precision classification.

[0178] This embodiment of the technical solution introduces application scenario parameters and a dynamic judgment threshold mechanism, enabling the same deep neural network model to flexibly adjust the detection strategy according to actual application needs: a high-sensitivity mode is suitable for early screening of infectious diseases, with the judgment threshold lowered to 0.35 to prioritize sensitivity; a high-specificity mode is suitable for pathogen diagnosis scenarios, with the judgment threshold raised to 0.65 to prioritize specificity; and a standard mode is suitable for routine detection scenarios, with the judgment threshold set to 0.50 to balance sensitivity and specificity. This dynamic adaptive mechanism significantly improves the flexibility and applicability of the detection method in practical applications.

[0179] XI. Explanation of the values ​​and ranges of key parameters in this embodiment The first filtering threshold of 0.15 is set based on the following: Statistical analysis of the probability distribution of the first pathogen presence in positive and negative samples in the training dataset revealed that over 98% of the negative samples had a probability of the first pathogen presence below 0.15, while over 95% of the positive samples had a probability of the first pathogen presence above 0.15. Setting the first filtering threshold to 0.15 allows for effective filtering of most negative samples while maintaining an extremely low false negative rate.

[0180] The threshold values ​​for the high-sensitivity mode (0.35), standard mode (0.50), and high-specificity mode (0.65) are determined based on the following: analysis of the receiver operating characteristic (ROC) curves of the validation dataset shows that 0.35 corresponds to approximately 96% sensitivity and 84% specificity; 0.50 corresponds to approximately 90% sensitivity and 88% specificity; and 0.65 corresponds to approximately 82% sensitivity and 94% specificity. These three thresholds correspond to three different detection strategies: sensitivity-first, balanced, and specificity-first.

[0181] The design rationale for setting the convolutional kernel sizes of 7, 5, and 3 in the electrical signal feature enhancement extraction network is as follows: larger convolutional kernels can capture a wider receptive field of current waveforms in shallower networks, extracting current fluctuation patterns spanning 5 to 7 bases in nanopore sequencing; smaller convolutional kernels can capture finer local waveform details in deeper networks. This design of convolutional kernels from large to small follows the principle of multi-scale feature extraction from coarse-grained to fine-grained.

[0182] The rationale for setting the k-mer length range of 3 to 7 in sequence feature encoding networks is as follows: when the k-mer length is less than 3, it is impossible to effectively distinguish the sequence features of different pathogens; when the k-mer length is greater than 7, the dimension of the frequency vector increases sharply, leading to excessive computational overhead and serious sparsity problems. The k-mer length range of 3 to 7 strikes a balance between feature resolution and computational feasibility.

[0183] The sampling frequency of the first electrical signal data is 4,000 to 5,000 times per second, and the sampling time interval is 200 to 250 microseconds. The basis for this is that the DNA strand in the nanopore sequencing platform passes through the nanopore at a speed of about 450 bases per second. The sampling frequency of 4,000 to 5,000 times per second can ensure that about 9 to 11 current sampling points are generated when each base crosses the nanopore. This sampling density is sufficient to capture the details of current changes during base crossing, while not generating excessive data redundancy.

[0184] This invention encompasses any substitutions, modifications, equivalent methods, and solutions made within the spirit and scope of this invention. To provide the public with a thorough understanding of this invention, specific details are described in detail in the following preferred embodiments; however, those skilled in the art will fully understand the invention even without these details. Furthermore, to avoid unnecessary misunderstanding of the essence of this invention, well-known methods, processes, procedures, components, and circuits are not described in detail.

[0185] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for optimizing pathogen DNA detection based on deep learning, characterized in that, Includes the following steps: Step 1: Obtain the raw ion current time series data generated by the nanopore sequencing platform during real-time sequencing of the sample to be tested, denoted as the first electrical signal data. The sampling frequency of the first electrical signal data is 4000 to 5000 times per second, and the current value of each sampling point ranges from 0 picoamperes to 250 picoamperes. Obtain the first DNA sequence data output by the base recognizer built into the nanopore sequencing platform after base recognition of the first electrical signal data. The first DNA sequence data is a string sequence composed of four base characters: adenine A, thymine T, cytosine C, and guanine G. Step 2: Input the first electrical signal data obtained in Step 1 into the electrical signal feature enhancement and extraction network in the first-stage deep neural network, and output the first electrical signal feature vector, which has a dimension of 256. Step 3: Input the first DNA sequence data obtained in Step 1 into the sequence feature encoding network in the first-stage deep neural network, and output the first sequence feature vector, which has a dimension of 256. Step 4: Input the first electrical signal feature vector output in Step 2 and the first sequence feature vector output in Step 3 into the feature layer fusion network in the first stage deep neural network, and output the first fused feature vector, which has a dimension of 256. Step 5: Input the first fused feature vector output in Step 4 into the first pathogen classification network in the first stage deep neural network, and output the probability value of the existence of the first pathogen, which ranges from 0 to 1. Step 6: Compare the probability value of the first pathogen output in Step 5 with a preset first filtering threshold, which is 0.15; when the probability value of the first pathogen is greater than the first filtering threshold, proceed to Step 7. When the probability value of the first pathogen is less than or equal to the first filtering threshold, the detection result is directly output as no target pathogen was detected and the detection process is terminated. Step 7: Input the first electrical signal feature vector output in Step 2 into the temporal context coding network in the second-stage deep neural network, and output the first electrical signal context feature vector. The first electrical signal context feature vector has a dimension of 128. Step 8: Input the first electrical signal context feature vector output in Step 7 and the first sequence feature vector output in Step 3 into the cross-attention fusion network in the second-stage deep neural network, and output the second fused feature vector, which has a dimension of 128. Step 9: Input the second fused feature vector output in Step 8 into the second pathogen classification network in the second-stage deep neural network, and output the probability value of the existence of the second pathogen. The probability value of the existence of the second pathogen ranges from 0 to 1. Step 10: Obtain the user-specified application scenario parameters, which include any one of high-sensitivity mode identifier, standard mode identifier, and high-specificity mode identifier; determine the corresponding judgment threshold based on the application scenario parameters: when the application scenario parameter is a high-sensitivity mode identifier, the judgment threshold is 0.35; when the application scenario parameter is a standard mode identifier, the judgment threshold is 0.50; when the application scenario parameter is a high-specificity mode identifier, the judgment threshold is 0.65; compare the probability value of the second pathogen's presence output in Step 9 with the judgment threshold; when the probability value of the second pathogen's presence is greater than the judgment threshold, output the detection result as "target pathogen detected"; When the probability value of the second pathogen is less than or equal to the determination threshold, the output detection result is "no target pathogen detected".

2. The method for optimizing pathogen DNA detection based on deep learning according to claim 1, characterized in that, The specific structure of the electrical signal feature enhancement and extraction network described in step 2 is as follows: The first layer is a one-dimensional convolutional layer with a kernel size of 7, a stride of 1, and 64 output channels. The second layer is a batch normalization layer; The third layer is a modified linear unit activation layer; The fourth layer is a one-dimensional convolutional layer with a kernel size of 5, a stride of 1, and 128 output channels. The fifth layer is a batch normalization layer; The sixth layer is a modified linear unit activation layer; The seventh layer is a one-dimensional convolutional layer with a kernel size of 3, a stride of 1, and 256 output channels. The eighth layer is a max pooling layer with a pooling kernel size of 2 and a pooling step size of 2; The ninth layer is the first residual connection module. The first residual connection module contains two one-dimensional convolutional layers with a kernel size of 3, a stride of 1, and 256 output channels, and one identity skip connection. The input feature map of the first residual connection module is added element-wise with the output feature map of the second one-dimensional convolutional layer in the first residual connection module. The tenth layer is the second residual connection module. The second residual connection module contains two one-dimensional convolutional layers with a kernel size of 3, a stride of 1, and 256 output channels, and one identity skip connection. The input feature map of the second residual connection module is added element-wise with the output feature map of the second one-dimensional convolutional layer in the second residual connection module. The eleventh layer is a global average pooling layer, which calculates the feature average of the input feature map at all time steps in each channel dimension; The twelfth layer is a fully connected layer with 256 input and 256 output dimensions.

3. The method for optimizing pathogen DNA detection based on deep learning according to claim 1, characterized in that, The specific process by which the sequence feature encoding network in step 3 encodes the features of the first DNA sequence data is as follows: The first DNA sequence data was used to extract k-mer fragments using a sliding window method with a step size of 1. K-mer fragments of length 3, 4, 5, 6 and 7 were extracted respectively. For k-mer fragments of length 3, the frequency of each 3-mer combination in the first DNA sequence data is counted, a 3-mer frequency vector is constructed, and the 3-mer frequency vector is summed and normalized to obtain a 3-mer normalized frequency vector. For each 4-mer fragment of length 4, the frequency of each 4-mer combination in the first DNA sequence data is counted, a 4-mer frequency vector is constructed, and the 4-mer frequency vector is summed and normalized to obtain a 4-mer normalized frequency vector. For k-mer fragments of length 5, the frequency of each 5-mer combination in the first DNA sequence data is counted, a 5-mer frequency vector is constructed, and the 5-mer frequency vector is summed and normalized to obtain a 5-mer normalized frequency vector. For k-mer fragments of length 6, the frequency of each 6-mer combination in the first DNA sequence data is counted, a 6-mer frequency vector is constructed, and the 6-mer frequency vector is summed and normalized to obtain a 6-mer normalized frequency vector. For k-mer fragments of length 7, the frequency of each 7-mer combination in the first DNA sequence data is counted, a 7-mer frequency vector is constructed, and the 7-mer frequency vector is summed and normalized to obtain a 7-mer normalized frequency vector. The 3-mer normalized frequency vector, 4-mer normalized frequency vector, 5-mer normalized frequency vector, 6-mer normalized frequency vector, and 7-mer normalized frequency vector are concatenated in the order of 3-mer, 4-mer, 5-mer, 6-mer, and 7-mer to obtain the concatenated k-mer frequency vector. The concatenated k-mer frequency vector is input into a fully connected layer for linear transformation. The output dimension of the fully connected layer is 256, and the first sequence feature vector is output.

4. The method for optimizing pathogen DNA detection based on deep learning according to claim 1, characterized in that, In step 4, the feature layer fusion network performs an element-wise weighted summation operation on the first electrical signal feature vector and the first sequence feature vector. The element-wise weighted summation operation is performed according to the following formula: ; in: This is the first fused feature vector; The first electrical signal feature vector; The first sequence feature vector; This represents element-wise multiplication. This is a learnable attention weight vector; The learnable attention weight vector is generated as follows: the first electrical signal feature vector and the first sequence feature vector are concatenated in the feature dimension to obtain a concatenated feature vector with a dimension of 512. The concatenated feature vector is then input into a fully connected layer for linear transformation. The fully connected layer has an input dimension of 512 and an output dimension of 256. The output vector of the fully connected layer is then input into a Sigmoid activation function for nonlinear transformation to obtain the learnable attention weight vector. The learnable attention weight vector is automatically updated during the first stage of deep neural network training using the gradient backpropagation algorithm.

5. The deep learning-based pathogen DNA detection optimization method according to claim 1, characterized in that, The specific structure of the temporal context coding network mentioned in step 7 is as follows: The first layer is a bidirectional gated recurrent unit layer. The input feature dimension of the bidirectional gated recurrent unit layer is 256-dimensional. The forward hidden state dimension of the bidirectional gated recurrent unit layer is 64-dimensional, and the backward hidden state dimension is 64-dimensional. The bidirectional gated recurrent unit layer concatenates the forward hidden state and the backward hidden state in the feature dimension, and outputs a temporal feature sequence with a dimension of 128-dimensional. The second layer is a self-attention layer with a query projection dimension of 128, a key projection dimension of 128, a value projection dimension of 128, and 4 self-attention heads. The self-attention layer calculates a multi-head self-attention weighted representation of the temporal feature sequence output by the bidirectional gated recurrent unit layer. The third layer is a global average pooling layer. The global average pooling layer calculates the feature average of all time steps in the multi-head self-attention weighted representation output by the self-attention layer in the time step dimension, and outputs the first electrical signal context feature vector, which has a dimension of 128.

6. The method for optimizing pathogen DNA detection based on deep learning according to claim 1, characterized in that, The cross-attention fusion network described in step 8 employs a multi-head cross-attention mechanism. The specific calculation process of the cross-attention fusion network is as follows: The first electrical signal context feature vector is mapped to a query matrix through the first linear layer. The first linear layer has an input dimension of 128 and an output dimension of 128. The first sequence feature vector is mapped to a key matrix through the second linear layer. The second linear layer has an input dimension of 256 and an output dimension of 128. The first sequence feature vector is mapped to a value matrix through the third linear layer. The input dimension of the third linear layer is 256 dimensions, and the output dimension is 128 dimensions. The query matrix, key matrix, and value matrix are each divided along the dimension of 4 attention heads, resulting in 4 sets of query submatrices, 4 sets of key matrices, and 4 sets of value submatrices. Calculate the scaled dot product attention score for each query submatrix, key submatrix, and value submatrix. The formula for calculating the scaled dot product attention score is as follows: ; in: For the i-th query submatrix, Let i be the key matrix of the i-th group. Let i be the value submatrix of the i-th group. Let be the dimension of the key matrix; The four sets of scaled dot product attention calculation results are concatenated along the feature dimension to obtain a multi-head attention concatenation vector, which has a dimension of 128. The multi-head attention concatenation vector is input into the fourth linear layer for linear transformation. The fourth linear layer has an input dimension of 128 and an output dimension of 128, outputting the second fused feature vector.

7. The method for optimizing pathogen DNA detection based on deep learning according to claim 1, characterized in that, The specific structure of the first pathogen classification network in step 5 is as follows: The first layer is a fully connected layer with an input dimension of 256 and an output dimension of 64. The second layer is a modified linear unit activation layer; The third layer is a random drop layer with a drop rate of 0.

3. The fourth layer is a fully connected layer with an input dimension of 64 and an output dimension of 32. The fifth layer is a modified linear unit activation layer; The sixth layer is a Softmax classification layer, which outputs two category probability values: the first category probability value is the probability value of the presence of the target pathogen, and the second category probability value is the probability value of the absence of the target pathogen. The probability value of the presence of the first pathogen output in step 5 is the probability value of the first category.

8. The method for optimizing pathogen DNA detection based on deep learning according to claim 1, characterized in that, The specific structure of the second pathogen classification network in step 9 is as follows: The first layer is a fully connected layer with an input dimension of 128 and an output dimension of 64. The second layer is a modified linear unit activation layer; The third layer is a fully connected layer with an input dimension of 64 and an output dimension of 32. The fourth layer is a modified linear unit activation layer; The fifth layer is a random drop layer with a drop rate of 0.

2. The sixth layer is a fully connected layer with an input dimension of 32 and an output dimension of 16. The seventh layer is a modified linear unit activation layer; The eighth layer is a single Sigmoid classification layer, which outputs a single probability value. The probability value of the second pathogen output in step 9 is the probability value output by the Sigmoid classification layer.

9. The method for optimizing pathogen DNA detection based on deep learning according to claim 1, characterized in that, The method for acquiring the first electrical signal data in step 1 is as follows: read the real-time ion current signal generated by each nanopore channel in the sequencing chip from the data acquisition interface of the nanopore sequencing platform. The sampling time interval of each current signal is 200 microseconds to 250 microseconds. Arrange the continuously sampled current values ​​in the order of sampling time to form the first electrical signal data. The method for obtaining the first DNA sequence data in step 1 is as follows: the base recognizer built into the nanopore sequencing platform is called to process the first electrical signal data in real time. The base recognizer uses a hidden Markov model to segment the current signal fragment and decode the base state, outputting base characters with a quality score greater than or equal to 7, which are arranged in the order of base calls to form the first DNA sequence data.

10. The method for optimizing pathogen DNA detection based on deep learning according to claim 1, characterized in that, The electrical signal feature enhancement extraction network, the sequence feature encoding network, the feature layer fusion network, and the first pathogen classification network together constitute the first-stage deep neural network. Before deployment and use, the first-stage deep neural network is pre-trained using a labeled pathogen DNA sequencing dataset, and the training loss function is the classification cross-entropy loss function. The temporal context encoding network, the cross-attention fusion network, and the second pathogen classification network together constitute the second-stage deep neural network. The second-stage deep neural network is trained using the same dataset as the first-stage deep neural network before deployment and use. The training processes of the first-stage deep neural network and the second-stage deep neural network are carried out independently. Each sample in the labeled pathogen DNA sequencing dataset includes: the original ion current time series data of the sample, the DNA sequence data corresponding to the sample, and a binary label indicating whether the sample contains the target pathogen; the ratio of the number of positive samples containing the target pathogen to the number of negative samples not containing the target pathogen in the labeled pathogen DNA sequencing dataset is 1 to 1.