Nanopore base calling method based on libtorch and c++

By migrating and optimizing the nanopore base recognition model from Python to C++, and combining it with Libtorch and CTC decoding algorithms, the problems of high noise and high speed in current signal conversion and base modification recognition in nanopore sequencing were solved, achieving efficient base recognition and modification detection, and improving system performance and real-time processing capabilities.

CN122157801APending Publication Date: 2026-06-05ZHONGSHAN OPHTHALMIC CENT SUN YAT SEN UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHONGSHAN OPHTHALMIC CENT SUN YAT SEN UNIV
Filing Date
2026-01-09
Publication Date
2026-06-05

Smart Images

  • Figure CN122157801A_ABST
    Figure CN122157801A_ABST
Patent Text Reader

Abstract

The application discloses a nanopore base recognition method based on Libtorch and C++, which comprises the following steps: obtaining nanopore sequencing data of a target sample and preprocessing the data, wherein the preprocessing comprises normalization and overlapping segmentation; delivering the preprocessed data to a model inference module based on a convolutional neural network and a bidirectional long short-term memory network in an asynchronous mode, performing GPU inference on each time step, and outputting base sequence weights of each time step; decoding the base sequence weights of each time step output by the model inference module through a CTC decoding module based on a greedy search and a prefix beam search; reassembling the decoded result; and outputting the result. The model inference module is optimized, efficient data loading and multi-GPU inference are realized, the inference time is significantly shortened, the memory occupation is effectively reduced, the memory consumption is reduced while the high accuracy is maintained, and the running speed and throughput of base recognition are accelerated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of nanopore DNA base sequencing, specifically relating to a nanopore base recognition method based on Libtorch and C++. Background Technology

[0002] With the continuous development of high-throughput sequencing technology, nanopore sequencing has gradually played an increasingly important role in genomics research, disease diagnosis, and environmental monitoring due to its considerable read lengths, strong real-time sequencing capabilities, and ability to simultaneously detect base modifications (such as methylation). Compared with traditional second-generation sequencing methods, nanopore sequencing utilizes protein channels to recognize the current signals generated when single DNA or RNA molecules pass through, enabling the detection of epigenetic modification information while obtaining the base sequence, significantly expanding the value of sequencing data. However, due to the high noise of the current signal and the high sequencing rate, how to efficiently and accurately convert the current signal into a base sequence and identify base modifications has always been a major challenge in the development of nanopore sequencing technology.

[0003] Currently, most mainstream nanopore sequencing platforms and their accompanying analysis software are developed by a few international companies that hold core patents. For example, Oxford Nanopore Technologies (ONT) pioneered multi-generation sequencing chips (such as the R9, R9.4, and R10 series) and developed proprietary base recognition algorithms and software (such as MinKNOW, Guppy, Bonito, and Dorado) based on them. These software programs often employ deep learning models (such as convolutional neural networks, bidirectional LSTM, and Transformer) to process high-noise current signals, thereby improving sequencing accuracy and supporting the detection of epigenetic modifications such as methylation. However, their core algorithms and supporting implementations are mostly semi-open source, and their core signal decoding methods are not publicly disclosed, making it difficult for researchers or companies to customize and further develop them.

[0004] Meanwhile, accelerating the deep learning inference and training process has become a pressing issue to support higher data throughput and faster sequencing speeds. Most existing open-source software, such as some implementations based on Python and PyTorch, while offering advantages in ease of use, often suffers from shortcomings in performance and resource utilization efficiency, making it difficult to meet the demands of large-scale data analysis and real-time processing. This is especially true for applications requiring simultaneous base identification and modification detection, where model complexity and computational load increase further, placing higher demands on hardware and algorithm optimization. Summary of the Invention

[0005] The main objective of this invention is to overcome the shortcomings and deficiencies of the prior art and provide a nanopore base recognition method based on Libtorch and C++. By migrating the base recognition model that originally ran in the Python environment to C++ and optimizing the core algorithm process, it is possible to achieve efficient data loading and multi-GPU inference, significantly shortening the inference time and effectively reducing memory usage.

[0006] To achieve the above objectives, the present invention adopts the following technical solution:

[0007] One aspect of the present invention provides a nanopore base recognition method based on Libtorch and C++, comprising the following steps:

[0008] Nanopore sequencing data of the target sample are acquired and preprocessed, including regularization and overlapping segmentation.

[0009] The preprocessed data is asynchronously passed to the model inference module based on convolutional neural networks and inverse long short-term memory networks, and GPU inference is performed for each time step to output the base sequence weights of each time step.

[0010] The CTC decoding module, based on greedy search and parallel optimization of prefix bundle search, decodes the base sequence weights of each time step output by the model inference module.

[0011] The decoding results are reassembled, and the result fragments of the same reading segment are spliced ​​back into the same reading segment;

[0012] Output results.

[0013] As a preferred technical solution, the preprocessing specifically includes:

[0014] The target sample was sequenced using a nanopore sequencer to obtain the original nanopore sequencing data of the target sample;

[0015] The method combines thread pools, multiprocessing, and shared memory to asynchronously and parallelly read nanopore sequencing data files. Specifically, each thread processes one file. Within a thread, a separate process is started to read the data into memory and write it into shared memory using serialization technology. When the process finishes execution, the data in the shared memory is read in the current thread, deserialized, and the read data is obtained.

[0016] The read data is regularized using the MAD method and then segmented into segments of length 6000 and overlap region 500.

[0017] As a preferred technical solution, the model inference module constructs a convolutional neural network, an inverse long short-term memory network, and a linear layer sequentially using Libtorch, and loads pre-prepared model parameters at runtime, specifically:

[0018] The convolutional neural network is used to capture local features of a signal and includes 5 convolutional layers with kernel sizes of 3, 5, 15, 5, and 5, and channel numbers of 1, 16, 64, 512, and 512, respectively.

[0019] The reverse long short-term memory network is used to learn the characteristics of time-series signals, including:

[0020] The input layer is used to receive local signal features extracted by the convolutional neural network.

[0021] Network execution layer: Based on the set Boolean variable, if it is true, the input timing signal is first reversed before being input into the subsequent layer for calculation. After the calculation is completed, the output is reversed again. If it is false, the input timing signal data is directly passed to the subsequent layer for calculation.

[0022] Forgetting Gate: Filtering the retention rate of historical memories;

[0023] Input gate: merges the current input with candidate memories;

[0024] Output gate: controls the effect of the current state on the prediction;

[0025] The linear layer is used to output the base sequence weights for each time step.

[0026] As a preferred technical solution, the CTC decoding module based on greedy search and parallel optimized prefix bundle search can select either a greedy search decoding algorithm or a parallel optimized prefix bundle search decoding algorithm for CTC decoding as needed, and finally asynchronously transmit the result to the sequence splicing module.

[0027] The greedy search decoding algorithm in the CTC framework generates a sequence by selecting the label with the highest probability at each time step. Specifically, at each time step, the output with the highest probability is selected independently, and then consecutive repeated characters are merged and whitespace characters are removed to form the final sequence.

[0028] The parallel optimized prefix bundle search decoding algorithm is as follows: the global sequence probability is optimized by dynamically maintaining candidate paths with a width of B in the Top-B bundles. At each step, all possible paths are expanded and the B paths with the highest cumulative probability are retained. The same prefixes are merged to avoid redundant calculations. At the same time, different data in the same batch are decoded in parallel during the decoding process.

[0029] As a preferred technical solution, the sequence splicing module specifically comprises:

[0030] Based on the sequence output by the CTC decoding module and the corresponding position information, the sequences that have been segmented for the same read segment are divided into half of each overlapping region.

[0031] As a preferred technical solution, the output result is specifically as follows:

[0032] Receive the output of the sequence splicing module and output the result of each read segment in Fastq format.

[0033] As a preferred technical solution, the alignment information between the base sequence and the original signal is output along with the output result.

[0034] As a preferred technical solution, the format of the file for asynchronously and parallelly reading nanopore sequencing data is HDF5 file.

[0035] Another aspect of the present invention provides a nanopore base recognition system based on Libtorch and C++, applied to the above-mentioned nanopore base recognition method based on Libtorch and C++, including a preprocessing module, a model inference module, a decoding module, a sequence splicing module, and a result writing module;

[0036] The preprocessing module is used to acquire nanopore sequencing data of the target sample and perform preprocessing, and then asynchronously transmits the preprocessed data to the model inference module based on convolutional neural network and inverse long short-term memory network; the preprocessing includes regularization and overlapping segmentation;

[0037] The model inference module constructs a convolutional neural network, an inverse long short-term memory network, and a linear layer in sequence using Libtorch. At runtime, it loads pre-prepared model parameters, performs GPU inference on the preprocessed data at each time step, and outputs the base sequence weights at each time step.

[0038] The decoding module is used to decode the base sequence weights of each time step output by the model inference module according to the greedy search decoding algorithm and the parallel optimized prefix bundle search decoding algorithm.

[0039] The splicing module is used to splice the output results of the decoding module, splicing the result segments of the same reading segment back into the same reading segment to obtain the result of each reading segment;

[0040] The result output module receives the output from the sequence splicing module and outputs the result of each read segment in Fastq format.

[0041] In another aspect, the present invention also provides a storage medium storing a program that, when executed by a processor, implements the above-described nanopore base recognition method based on Libtorch and C++.

[0042] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0043] (1) This invention proposes a nanopore base recognition method based on Libtorch and C++. By migrating the base recognition model that originally ran in the Python environment to C++ and optimizing the core algorithm process, it can achieve efficient data loading and multi-GPU inference, significantly shorten the inference time and effectively reduce memory usage. While maintaining high accuracy, it reduces memory consumption and speeds up the running speed and throughput of base recognition.

[0044] (2) This invention can be applied to real-time data stream processing and back-end batch analysis scenarios of various nanopore sequencing platforms. At the same time, by maintaining compatibility with the PyTorch training framework, it can achieve smooth connection between model updates and parameter tuning.

[0045] (3) Compared with the traditional Python implementation, this invention can further improve the system performance while ensuring sequencing accuracy and methylation detection sensitivity, providing a technical foundation for the development and industrial application of independently controllable nanopore sequencing algorithms;

[0046] (4) Compared with similar methods, this invention runs in a multi-GPU environment and can be generalized to accelerate general nanopore sequencing recognition. Attached Figure Description

[0047] Figure 1 This is a schematic flowchart of a nanopore base recognition method based on Libtorch and C++ according to an embodiment of the present invention.

[0048] Figure 2 This is a schematic diagram of the architecture of the model inference module in an embodiment of the present invention;

[0049] Figure 3 This is a statistical diagram of the sequencing results in an embodiment of the present invention;

[0050] Figure 4 This is a schematic diagram of the sequencing results of an embodiment of the present invention. Detailed Implementation

[0051] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.

[0052] Example:

[0053] like Figure 1 As shown, this embodiment provides a nanopore base recognition method based on Libtorch and C++, including the following steps:

[0054] Step 1: Obtain nanopore sequencing data of the target sample and perform preprocessing, including regularization and overlapping segmentation.

[0055] Step 1.1: Sequencing the target sample using a nanopore sequencer to obtain the original nanopore sequencing data of the target sample.

[0056] In one or more preferred embodiments, the target sample includes Arabidopsis thaliana, rice, or fruit fly.

[0057] In one or more preferred embodiments, the obtained nanopore sequencing data includes multiple reads and multiple HDF5 files.

[0058] Step 1.2: Using a combination of thread pools, multi-processing, and shared memory technologies, the nanopore sequencing data files are read asynchronously and in parallel. Specifically, each thread processes one file. Within a thread, a separate process is started to read the data into memory and write the data into shared memory through serialization (Protocol Buffers). When the process finishes execution, the data in the shared memory is read in the current thread, deserialized, and the read data is obtained.

[0059] In one or more preferred embodiments, the thread pool comprises 12 threads, each thread launching an independent process to process a single HDF5 file.

[0060] In one or more preferred embodiments, the shared memory allocation is approximately 500 MB.

[0061] In one or more preferred embodiments, the deserialization process is in unordered_map format, where the key is the UUID string of the corresponding read segment and the value is a signal tensor.

[0062] Step 1.3: Regularize the read data using the MAD (median absolute divination) method.

[0063] Step 1.4: In each thread, the read data is divided into segments with a length of 6000 and an overlap of 500 to ensure the integrity of the end-to-end splicing.

[0064] The above steps enable concurrent data reading even when the HDF5 read interface limits multi-threaded reading, significantly improving the speed of data reading and processing.

[0065] Step 2: Asynchronously pass the preprocessed data to the model inference module based on convolutional neural network and inverse long short-term memory network, perform GPU inference for each time step, and output the base sequence weights for each time step.

[0066] The model inference module constructs a convolutional neural network (CNN), a reverse long short-term memory network (ReverseLSTM), and a linear layer sequentially using Libtorch, and loads pre-prepared model parameters at runtime, such as... Figure 2 As shown, specifically:

[0067] The convolutional neural network is used to capture local features of a signal and includes 5 convolutional layers.

[0068] In one or more preferred embodiments, the kernel size of the convolutional layer of the convolutional neural network is 3 / 5 / 15 / 5 / 5, and the number of channels is 1 / 16 / 64 / 512 / 512.

[0069] The reverse long short-term memory network is used to learn the characteristics of time-series signals, including:

[0070] The input layer is used to receive local signal features extracted by the convolutional neural network.

[0071] Network Execution Layer: Based on the set Boolean variable, if it is true, the input timing signal is first reversed before being input into the subsequent layer for computation. After the computation is completed, the output is reversed again. If it is false, the input timing signal data is directly passed to the subsequent layer for computation. Through this layer, the direction of timing signal transmission can be adjusted in the model according to the set Boolean variable.

[0072] Forgetting Gate: Filtering the retention rate of historical memories;

[0073] Input gate: merges the current input with candidate memories;

[0074] Output gate: controls the effect of the current state on the prediction;

[0075] The linear layer is used to output the base sequence weights for each time step.

[0076] The model inference module is built on the libtorch API, directly injecting parameters from the pre-trained model in Python. It enables multi-GPU inference technology.

[0077] Step 3: The CTC decoding module based on greedy search and parallel optimization of prefix bundle search decodes the base sequence weights of each time step output by the model inference module to handle the problem of mismatch between the length of the input signal and the output base sequence.

[0078] Step 3.1: Select either a greedy search decoding algorithm or a parallel optimized prefix bundle search decoding algorithm for CTC decoding as needed, where:

[0079] Greedy search decoding algorithms have extremely low memory footprint and are suitable for real-time processing scenarios (such as rapid base identification in nanopore sequencing). However, they rely only on local optimal decisions and cannot correct early misjudgments caused by signal noise (such as current fluctuations caused by methylation modification), which may lead to missed detection of key sites (such as SNPs) in long reads.

[0080] Parallel-optimized prefix beam search decoding algorithms have high computational complexity. While they can improve accuracy compared to greedy decoding to some extent in nanopore sequencing, they take 3-5 times longer. They are suitable for clinical diagnostic scenarios with high accuracy requirements, but at the cost of higher computational resource consumption.

[0081] Step 3.2: The greedy search decoding algorithm in the CTC framework generates a sequence by selecting the label with the highest probability at each time step, specifically as follows:

[0082] At each time step, the output with the highest probability (such as a base or a whitespace character) is selected independently. Then, consecutive repeating characters are merged and whitespace characters are removed to form the final sequence. For example, if the model outputs "A", "A" and "-" in three consecutive time steps, they are merged into "A". The computational complexity of this method is O(T) (where T is the number of time steps).

[0083] Step 3.3, the parallel optimized prefix beam search decoding algorithm is specifically as follows:

[0084] The global sequence probability is optimized by dynamically maintaining the Top-B candidate paths (bundle width B). At each step, all possible paths are expanded, and the B paths with the highest cumulative probability are retained. Identical prefixes are merged to avoid redundant computation. Simultaneously, different data within the same batch are decoded in parallel during the decoding process. For example, when the bundle width B=5, at a certain time step, paths "AT" and "GC" might be retained, with subsequent high-probability signals covering the preceding errors. Its computational complexity is O(B×T×K) (where K is the character set size).

[0085] Step 4: Reassemble the decoded results, splicing the result fragments of the same segment back into the same segment.

[0086] Because CNN-like models apply padding to the edges of sequence blocks, the information at the beginning and end of the segmented sequence is attenuated after passing through multiple CNN layers, thus affecting the accuracy of the beginning and end of the segmented sequence. Here, this invention, based on the sequence output by the CTC decoding module in step 3 and the corresponding position information, avoids the information attenuation problem by taking half of the overlapping region from each segmented sequence of the same read segment.

[0087] Step 5: Output the results.

[0088] In one or more preferred embodiments, the output of the sequence splicing module is received, and the result of each read segment is output in Fastq format.

[0089] Fastq files are the standard format for storing sequencing bundles and their quality information in bioinformatics, and are widely used in nanopore sequencing. Each record contains four lines:

[0090] 1) Sequence identifier line: begins with "@", followed by a unique identifier and an optional descriptor;

[0091] 2) Sequence line: Directly stores nucleotide sequences (A / T / G / C), etc.

[0092] 3) Line separator: Starts with "+", may use repeated identifiers or leave blank;

[0093] 4) Quality score line: Each character corresponds to the quality value of the bases in the sequence, and the ASCII characters are converted into numerical values ​​through Phred encoding.

[0094] In one or more preferred embodiments, the alignment information between the base sequence and the original signal is output along with the result.

[0095] Step 6: Evaluate the output results.

[0096] This embodiment uses Arabidopsis thaliana, rice (O. sativa), CpG-methylated Drosophila sample (YF6418), and demethylated Drosophila sample (YF6419) as research objects. The statistical analysis of sequencing results is as follows: Figure 3 As shown, the horizontal axis represents the four species mentioned above, the vertical axis of the left bar chart represents the proportion of all reads with an average base quality value greater than or equal to 10, and the vertical axis of the right bar chart represents the proportion of the number of bases in the reads that passed the filter with an average base quality of 10 as the threshold to the total number of bases in the output. Figure 3 The two bar charts reflect the overall performance of the nanopore sequencing data in this embodiment. Figure 4These are the sequencing results of an embodiment of the present invention, wherein the vertical axis is the distribution density of the error rates of the above four species (compared with the reference genome of the corresponding species, using minimap2 as the tool), and the horizontal axis is the error rate value; Figure 4 This reflects the error distribution when comparing the nanopore sequencing data of this embodiment with the true base sequence of the species.

[0097] In another embodiment of this application, a nanopore base recognition system based on Libtorch and C++ is provided. The system includes a preprocessing module, a model inference module, a decoding module, a sequence splicing module, and a result writing module.

[0098] The preprocessing module is used to acquire nanopore sequencing data of the target sample and perform preprocessing, and then asynchronously transmits the preprocessed data to the model inference module based on convolutional neural network and inverse long short-term memory network; the preprocessing includes regularization and overlapping segmentation;

[0099] The model inference module constructs a convolutional neural network, an inverse long short-term memory network, and a linear layer in sequence using Libtorch. At runtime, it loads pre-prepared model parameters, performs GPU inference on the preprocessed data at each time step, and outputs the base sequence weights at each time step.

[0100] The decoding module is used to decode the base sequence weights of each time step output by the model inference module according to the greedy search decoding algorithm and the parallel optimized prefix bundle search decoding algorithm.

[0101] The splicing module is used to splice the output results of the decoding module, splicing the result segments of the same reading segment back into the same reading segment to obtain the result of each reading segment;

[0102] The result output module receives the output from the sequence splicing module and outputs the result of each read segment in Fastq format.

[0103] It should be noted that the system provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure can be divided into different functional modules to complete all or part of the functions described above. This system is the nanopore base recognition method based on Libtorch and C++ applied to the above embodiments.

[0104] In another embodiment of this application, a storage medium is also provided, storing a program that, when executed by a processor, implements the Libtorch and C++-based nanopore base recognition method of the above embodiments, specifically as follows:

[0105] Nanopore sequencing data of the target sample are acquired and preprocessed, including regularization and overlapping segmentation.

[0106] The preprocessed data is asynchronously passed to the model inference module based on convolutional neural networks and inverse long short-term memory networks, and GPU inference is performed for each time step to output the base sequence weights of each time step.

[0107] The CTC decoding module, based on greedy search and parallel optimization of prefix bundle search, decodes the base sequence weights of each time step output by the model inference module.

[0108] The decoding results are reassembled, and the result fragments of the same reading segment are spliced ​​back into the same reading segment;

[0109] Output results.

[0110] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0111] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A nanoporous base recognition method based on Libtorch and C++, characterized in that, Includes the following steps: Nanopore sequencing data of the target sample are acquired and preprocessed, including regularization and overlapping segmentation. The preprocessed data is asynchronously passed to the model inference module based on convolutional neural networks and inverse long short-term memory networks, and GPU inference is performed for each time step to output the base sequence weights of each time step. The CTC decoding module, based on greedy search and parallel optimization of prefix bundle search, decodes the base sequence weights of each time step output by the model inference module. The decoding results are reassembled, and the result fragments of the same reading segment are spliced ​​back into the same reading segment; Output results.

2. The nanoporous base recognition method based on Libtorch and C++ according to claim 1, characterized in that, The preprocessing specifically includes: The target sample was sequenced using a nanopore sequencer to obtain the original nanopore sequencing data of the target sample; The method combines thread pools, multiprocessing, and shared memory to asynchronously and parallelly read nanopore sequencing data files. Specifically, each thread processes one file. Within a thread, a separate process is started to read the data into memory and write it into shared memory using serialization technology. When the process finishes execution, the data in the shared memory is read in the current thread, deserialized, and the read data is obtained. The read data is regularized using the MAD method and then segmented into segments of length 6000 and overlap region 500.

3. The nanoporous base recognition method based on Libtorch and C++ according to claim 1, characterized in that, The model inference module constructs a convolutional neural network, an inverse long short-term memory network, and a linear layer sequentially using Libtorch, and loads pre-prepared model parameters at runtime, specifically: The convolutional neural network is used to capture local features of a signal and includes 5 convolutional layers with kernel sizes of 3, 5, 15, 5, and 5, and channel numbers of 1, 16, 64, 512, and 512, respectively. The reverse long short-term memory network is used to learn the characteristics of time-series signals, including: The input layer is used to receive local signal features extracted by the convolutional neural network. Network execution layer: Based on the set Boolean variable, if it is true, the input timing signal is first reversed before being input into the subsequent layer for calculation. After the calculation is completed, the output is reversed again. If it is false, the input timing signal data is directly passed to the subsequent layer for calculation. Forgetting Gate: Filtering the retention rate of historical memories; Input gate: merges the current input with candidate memories; Output gate: controls the effect of the current state on the prediction; The linear layer is used to output the base sequence weights for each time step.

4. The nanoporous base recognition method based on Libtorch and C++ according to claim 1, characterized in that, The CTC decoding module based on greedy search and parallel optimized prefix bundle search selects either the greedy search decoding algorithm or the parallel optimized prefix bundle search decoding algorithm for CTC decoding as needed, and finally asynchronously transmits the result to the sequence splicing module. The greedy search decoding algorithm in the CTC framework generates a sequence by selecting the label with the highest probability at each time step. Specifically, at each time step, the output with the highest probability is selected independently, and then consecutive repeated characters are merged and whitespace characters are removed to form the final sequence. The parallel optimized prefix bundle search decoding algorithm is as follows: the global sequence probability is optimized by dynamically maintaining candidate paths with a width of B in the Top-B bundles. At each step, all possible paths are expanded and the B paths with the highest cumulative probability are retained. The same prefixes are merged to avoid redundant calculations. At the same time, different data in the same batch are decoded in parallel during the decoding process.

5. The nanoporous base recognition method based on Libtorch and C++ according to claim 1, characterized in that, The sequence splicing module is specifically: Based on the sequence output by the CTC decoding module and the corresponding position information, the sequences that have been segmented for the same read segment are divided into half of each overlapping region.

6. The nanoporous base recognition method based on Libtorch and C++ according to claim 1, characterized in that, The output result is as follows: Receive the output of the sequence splicing module and output the result of each read segment in Fastq format.

7. The nanoporous base recognition method based on Libtorch and C++ according to claim 1, characterized in that, Along with the output result, the alignment information between the base sequence and the original signal is also output.

8. The nanoporous base recognition method based on Libtorch and C++ according to claim 2, characterized in that, The asynchronous parallel reading of nanopore sequencing data is in HDF5 format.

9. A nanoporous base recognition system based on Libtorch and C++, characterized in that, The nanopore base recognition method based on Libtorch and C++ applied to any one of claims 1-8 includes a preprocessing module, a model inference module, a decoding module, a sequence splicing module, and a result writing module; The preprocessing module is used to acquire nanopore sequencing data of the target sample and perform preprocessing, and then asynchronously transmits the preprocessed data to the model inference module based on convolutional neural network and inverse long short-term memory network; the preprocessing includes regularization and overlapping segmentation; The model inference module constructs a convolutional neural network, an inverse long short-term memory network, and a linear layer in sequence using Libtorch. At runtime, it loads pre-prepared model parameters, performs GPU inference on the preprocessed data at each time step, and outputs the base sequence weights at each time step. The decoding module is used to decode the base sequence weights of each time step output by the model inference module according to the greedy search decoding algorithm and the parallel optimized prefix bundle search decoding algorithm. The splicing module is used to splice the output results of the decoding module, splicing the result segments of the same reading segment back into the same reading segment to obtain the result of each reading segment; The result output module receives the output from the sequence splicing module and outputs the result of each read segment in Fastq format.

10. A storage medium storing a program, characterized in that: When the program is executed by the processor, it implements the nanopore base recognition method based on Libtorch and C++ as described in any one of claims 1-8.