Sequence to graph comparison method, system, device, and storage medium based on graph compression

Through graph compression and base substitution penalty mode, the problem of difficult to take into account the speed and accuracy of sequence-to-graph alignment in the prior art is solved, and efficient and accurate genomic sequence alignment is achieved.

CN118824369BActive Publication Date: 2024-12-27YANTAI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411312519.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2024-12-27
Estimated Expiration
2044-09-20

AI Technical Summary

Technical Problem

The existing sequence-to-graph alignment methods are difficult to take into account accuracy and calculation speed when dealing with pan-genome sequence alignment, especially in the problem of massive sequence alignment.

Method used

Using a sequence-to-graph alignment method based on graph compression, the genomic graph and sequencing sequence are obtained, graph compression, encoding, topological sorting and backtracking matrix construction are carried out, base permutation penalty points are introduced, and linear, affine and double affine are calculated. Comparison scores in penalty mode to determine the best comparison path.

Benefits of technology

It effectively reduces the amount of calculation, improves the speed and accuracy of comparison, reduces memory space consumption, and realizes efficient sequence-to-graph comparison.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118824369B_ABST
    Figure CN118824369B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of gene sequencing, and in particular to a sequence-to-graph comparison method, system, device, and storage medium based on graph compression, which obtain a genome graph and a sequencing sequence, merge mergeable nodes in the genome graph to generate a merged node, update the genome graph to obtain a compressed graph, perform base encoding on the compressed graph and the sequencing sequence based on a four-bit binary mark, introduce a base substitution penalty and perform sequence-to-graph comparison to obtain comparison scores under different penalty modes, and simultaneously determine a backtracking starting point based on the position of the best comparison score, and select the source direction of the comparison score in the adjacent positions of the backtracking starting point in turn as the backtracking direction to perform backtracking to obtain the best comparison path, thereby reducing the scale of graph data and improving comparison efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of gene sequencing technology, and in particular to a sequence-to-graph comparison method, system, device, and storage medium based on graph compression. Background Art

[0002] Genome sequencing technology is of great significance in gene function identification, disease diagnosis and treatment, evolution and phylogeny research, etc. With the explosive growth of sequenced genome data, pan-genome-based sequence alignment methods have been applied. Among them, sequence-to-graph alignment, as an important step in pan-genome alignment, restricts the efficiency and accuracy of pan-genome alignment.

[0003] Currently, there are methods that convert the sequence-to-graph alignment problem into a shortest path problem and then perform heuristic search to find the optimal alignment result. Although this can increase the calculation speed, it cannot guarantee that the optimal alignment result will be found. There are also methods that use partial order alignment methods to perform sequence-to-graph alignment, but this method alone cannot effectively handle the massive sequence alignment problem in pan-genome sequence alignment research.

[0004] Therefore, a sequence-to-graph alignment method that takes both accuracy and computational speed into consideration is needed. Summary of the invention

[0005] The present invention provides a sequence-to-graph comparison method based on graph compression.

[0006] The technical solution of the present invention is as follows:

[0007] A sequence-to-graph comparison method based on graph compression comprises the following steps:

[0008] S1. Obtain genome map and sequencing sequence;

[0009] S2. Compression of genome graph: traverse all nodes in the genome graph, obtain nodes with only one predecessor node and one successor node as nodes to be merged, if there are several nodes to be merged that have a common predecessor node and successor node, then several nodes to be merged are mergeable nodes, merge the mergeable nodes in the genome graph to generate a merged node, and update the genome graph to obtain a compressed graph;

[0010] S3, encoding: encoding the bases in the merged nodes and the non-merged nodes in the compressed graph based on the four-bit binary mark bit to obtain the encoded compressed graph;

[0011] Encoding each base in the sequencing sequence based on four binary marker bits to obtain an encoded sequencing sequence;

[0012] S4. Sequence-to-graph alignment: The encoded compressed graph is topologically sorted and partially aligned with the encoded sequencing sequence. A base substitution penalty is introduced based on the alignment result, the pre-set match penalty and mismatch penalty. Based on the introduced base substitution penalty, the alignment scores in the linear penalty, affine penalty and double affine penalty modes are obtained respectively.

[0013] Based on the alignment score, the alignment score between the terminal node after topological sorting of the encoded compressed graph and the terminal base in the encoded sequencing sequence is determined as the best alignment score;

[0014] S5. Construct a two-dimensional backtracking matrix based on the alignment score, determine the backtracking starting point based on the best alignment score position, select the alignment score source direction in the adjacent positions of the backtracking starting point in turn as the backtracking direction to perform backtracking, obtain the best alignment path, and perform sequence-to-graph alignment based on the best alignment path.

[0015] Specifically, the base substitution penalty introduced in S4 is calculated as follows:

[0016] ,

[0017] in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of is the matching penalty entered by the user, is the mismatch penalty entered by the user, is the bitwise AND function.

[0018] Furthermore, the alignment score in the linear penalty mode is obtained based on the introduced base substitution penalty in S4, specifically:

[0019] ,

[0020] in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, For Node All predecessor nodes and the j-1th base in the encoded sequence The comparison score, For Node All predecessor nodes and the jth base in the sequence The comparison score, For Node and the j-1th base in the sequence The comparison score, is the missing penalty, For insertion penalty, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of Nodes are nodes The predecessor node of For Node The set of predecessor nodes of max To get the maximum value.

[0021] Furthermore, the alignment score under the affine penalty mode is obtained based on the introduced base substitution penalty in S4, specifically:

[0022] ,

[0023] Among them, M is the state without penalty, X is the state with missing penalty, and Y is the state with insertion penalty. The node in the topological sorting and the jth base in the encoded sequence The score of the M state, For Node All predecessor nodes and the j-1th base in the encoded sequence M The comparison score under the state, For Node All predecessor nodes and the j-1th base in the encoded sequence X The comparison score under the state, For Node All predecessor nodes and the j-1th base in the encoded sequence Y The comparison score under the state, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of Nodes are nodes The predecessor node of For Node The set of predecessor nodes; The node in topological sorting and the jth base in the encoded sequence of X The comparison score under the state, and Node All predecessor nodes and the jth base in the sequence of M Status and X Status score, is the missing penalty for the first vacancy, Penalty points for extended missing; The node in the topological sorting and the jth base in the encoded sequence Y The comparison score under the state, and Node and the j-1th base in the sequence The comparison scores between the M state and the Y state, is the insertion penalty for the first vacancy, Penalty for extension insertion, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, max To get the maximum value.

[0024] Specifically, in S5, based on the backtracking starting point, the direction of the source of the comparison score is selected in its adjacent positions in turn as the backtracking direction for backtracking, specifically:

[0025] In linear penalty:

[0026] if ,So ,

[0027] if ,So ,

[0028] if ,So ,

[0029] In the affine penalty:

[0030] if ,So ,

[0031] if ,So ,

[0032] if ,So ,

[0033] In the biaffine penalty:

[0034] if ,So ,

[0035] if ,So ,

[0036] if ,So ,

[0037] if ,So ,

[0038] if ,So ,

[0039] in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, For Node All predecessor nodes and the j-1th base in the encoded sequence The comparison score, For Node All predecessor nodes and the jth base in the sequence The comparison score, For Node and the j-1th base in the sequence The comparison score, is the missing penalty, For insertion penalty, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of is the i-th node after topological sorting of the encoded compressed graph and the jth base in the encoded sequence The backtracking direction of the corresponding score matrix unit, Forward node The order of The node in the topological sorting and the jth base in the encoded sequence The score of the M state, , , are the nodes in the topological sorting order i and the jth base in the encoded sequence of X , X 1 , X 2 The comparison score under the state, , , are the nodes in the topological sorting order i and the jth base in the encoded sequence Y, Y 1 、Y 2 The comparison score under the state.

[0040] Specifically, after obtaining a node with only one predecessor node and one successor node as a node to be merged in S2, it also includes: using a group of predecessor nodes and successor nodes of the node to be merged as keys of a hash table, and storing the ID of the node to be merged as a value in the hash table, traversing the hash table, and if the length of the value list corresponding to the key is greater than 1, it is determined that the corresponding several nodes to be merged have a common predecessor node and successor node, and are mergeable nodes.

[0041] Specifically, in S3, base encoding is performed on the merged nodes and non-merged nodes of the compressed graph based on a four-bit binary mark bit, as follows: if the mark bit is 1, it indicates that the base exists in the merged node and the non-merged node before the merge; if the mark bit is 0, it indicates that the base does not exist in the merged node and the non-merged node before the merge.

[0042] The present invention also provides a sequence-to-graph comparison system based on graph compression, comprising:

[0043] Data acquisition module: used to obtain genome maps and sequencing sequences;

[0044] Graph compression module: used to traverse all nodes in the genome graph, obtain nodes with only one predecessor node and one successor node as nodes to be merged, if there are several nodes to be merged that have a common predecessor node and successor node, then several nodes to be merged are mergeable nodes, merge the mergeable nodes in the genome graph to generate a merged node, and obtain a compressed graph after updating the genome graph;

[0045] Encoding module: used to encode the bases in the merged nodes and the non-merged nodes in the compression graph based on the four-bit binary mark bit to obtain the encoded compression graph; encode each base in the sequencing sequence based on the four-bit binary mark bit to obtain the encoded sequencing sequence;

[0046] Sequence-to-graph alignment module: used to topologically sort the encoded compressed graph, perform partial order alignment with the encoded sequencing sequence, introduce base substitution penalty based on the alignment result, pre-set matching penalty and mismatch penalty, obtain alignment scores in linear penalty, affine penalty and double affine penalty modes based on the introduced base substitution penalty, and obtain the alignment score of the last node after topological sorting of the encoded compressed graph and the last base in the encoded sequencing sequence as the best alignment score based on the alignment score;

[0047] Backtracking module: construct a two-dimensional backtracking matrix based on the alignment score, determine the backtracking starting point based on the best alignment score position, select the alignment score source direction in the adjacent positions of the backtracking starting point in turn as the backtracking direction to obtain the best alignment path, and perform sequence-to-graph alignment based on the best alignment path.

[0048] In addition, the present invention provides a sequence-to-graph comparison device based on graph compression, comprising a processor and a memory, wherein the processor implements the sequence-to-graph comparison method based on graph compression as described above when executing a computer program stored in the memory.

[0049] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps of the sequence-to-graph comparison method based on graph compression as described above.

[0050] The beneficial effects of the present invention are:

[0051] 1. By compressing the genome graph node data, the sequence-to-graph comparison problem is converted into a sequence-to-compressed graph comparison problem, which reduces the number of genome graph nodes in the calculation process, reduces the amount of calculation, and effectively improves the comparison speed;

[0052] 2. When performing sequence-to-graph comparison, the compressed genome graph and sequencing sequence are encoded based on four binary marker bits, which can effectively reduce the size of graph data and reduce memory space consumption;

[0053] 3. Introduce base substitution penalty, provide alignment scores under multiple penalty modes such as linear penalty, affine gap penalty, and double affine gap penalty, determine the best alignment score position based on the alignment score, and then backtrack to obtain the best alignment path, which has high alignment validity and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In the attached picture:

[0055] Figure 1 Schematic diagram of the flow of a sequence-to-graph comparison method based on graph compression in an embodiment;

[0056] Figure 2 It is a schematic diagram of compression coding in the figure in the embodiment;

[0057] Figure 3 This is a schematic diagram of the best alignment path obtained by backtracking in the embodiment. DETAILED DESCRIPTION

[0058] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings.

[0059] This embodiment provides a sequence-to-graph comparison method based on graph compression, see Figure 1 , including the following steps:

[0060] Step 1: Obtain genome map and sequencing sequence.

[0061] Specifically, read the genome map in GFA format from the hard disk G and Fasta format sequencing sequences R .

[0062] Step 2: Compression of genome graph: traverse all nodes in the genome graph, and obtain nodes with only one predecessor node and one successor node as nodes to be merged. If there are several nodes to be merged that have a common predecessor node and successor node, then several nodes to be merged are mergeable nodes. The mergeable nodes in the genome graph are merged to generate a merged node, and the genome graph is updated to obtain a compressed graph.

[0063] Specifically, after obtaining a node with only one predecessor node and one successor node as the node to be merged, it also includes: using a group of predecessor nodes and successor nodes of the node to be merged as keys of a hash table, and storing the ID of the node to be merged as a value in the hash table, traversing the hash table, and if the length of the value list corresponding to the key is greater than 1, it is determined that the corresponding several nodes to be merged have a common predecessor node and successor node, and are mergeable nodes.

[0064] In this embodiment, the genome map G= ( V , E ) to traverse all nodes, where V Represents a set of nodes, which stores a single base and the name ID of the node; E Represents edge e A collection of edges e i =( v i ,v j ) represents a node v i To Node v j If the node Satisfies only one predecessor node and 1 successor node , then is the key value of the hash table, and stores the node ID in the value list. is a list of all mergeable nodes that have a unique predecessor and a unique successor. For example, Represents a node , , Each has a unique predecessor node and the only successor node , , , is a mergeable node. Traverse the hash table H ,if The length of the corresponding value list is greater than 1, indicating that these nodes have a common predecessor node. v pred and successor nodes v pred , there are mergeable nodes, merge these mergeable nodes to generate merged nodes v merge , node v merge The predecessor and successor nodes of v pred and v pred .

[0065] Step 3: Encoding: Encode the bases in the merged nodes and non-merged nodes in the compressed graph based on the four-bit binary mark bit to obtain the encoded compressed graph;

[0066] Each base in the sequencing sequence is encoded based on the four-bit binary marker to obtain the encoded sequencing sequence.

[0067] Specifically, base encoding is performed on the merged nodes and non-merged nodes of the compressed graph based on a four-bit binary mark bit: if the mark bit is 1, it indicates that the base exists in the merged node and the non-merged node before the merge; if the mark bit is 0, it indicates that the base does not exist in the merged node and the non-merged node before the merge.

[0068] In this embodiment, if Figure 2As shown in the figure, the merge node is encoded as 1001, where the first bit 1 and the fourth bit 1 respectively indicate that the A and T bases exist before the merge, and the second and third bits 0 indicate that the C and G bases do not exist before the merge. The non-merged nodes are also re-encoded using the four-bit binary mark bit, and the encoding method is the same as that of the merged nodes.

[0069] Step 4: Sequence-to-graph alignment: Topologically sort the encoded compressed graph and perform partial order alignment with the encoded sequencing sequence. Based on the alignment results, the pre-set matching penalty and mismatch penalty, a base substitution penalty is introduced. Based on the introduced base substitution penalty, the alignment scores in the linear penalty, affine penalty and double affine penalty modes are obtained respectively.

[0070] Based on the alignment score, the alignment score between the terminal node of the encoded compressed graph after topological sorting and the terminal base of the encoded sequencing sequence is determined as the best alignment score.

[0071] Specifically, the base substitution penalty introduced is calculated as follows:

[0072] ,

[0073] in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of is the matching penalty entered by the user, is the mismatch penalty entered by the user, is the bitwise AND function.

[0074] Based on the introduced base substitution penalty, the alignment score in the linear penalty mode is obtained, specifically:

[0075] ,

[0076] in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, For Node All predecessor nodes and the j-1th base in the encoded sequence The comparison score, For Node All predecessor nodes and the jth base in the sequence The comparison score, For Node and the j-1th base in the sequence The comparison score, is the missing penalty, For insertion penalty, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of Nodes are nodes The predecessor node of For Node The set of predecessor nodes of max To get the maximum value.

[0077] Based on the introduced base substitution penalty, the alignment score in the affine penalty mode is obtained, specifically:

[0078] ,

[0079] Among them, M is the state without penalty, X is the state with missing penalty, and Y is the state with insertion penalty. The node in the topological sorting and the jth base in the encoded sequence The score of the M state, For Node All predecessor nodes and the j-1th base in the encoded sequence M The comparison score under the state, For Node All predecessor nodes and the j-1th base in the encoded sequence X The comparison score under the state, For Node All predecessor nodes and the j-1th base in the encoded sequence Y The comparison score under the state, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of Nodes are nodes The predecessor node of For Node The set of predecessor nodes; The node in topological sorting and the jth base in the encoded sequence of XThe comparison score under the state, and Node All predecessor nodes and the jth base in the sequence of M Status and X Status score, is the missing penalty for the first vacancy, Penalty points for extended missing; The node in the topological sorting and the jth base in the encoded sequence Y The comparison score under the state, and Node and the j-1th base in the sequence The comparison scores between the M state and the Y state, is the insertion penalty for the first vacancy, Penalty for extension insertion, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, max To get the maximum value.

[0080] In the invention, the calculation of the alignment score in the double affine penalty mode after the base substitution penalty is introduced is also provided, specifically:

[0081] ,

[0082] Among them, M is the state without penalty, For the missing penalty state of the first affine penalty, To perform the missing penalty state for the second affine penalty, To perform the insertion penalty state of the first affine penalty, To perform the insertion penalty state for the second affine penalty, The node in the topological sorting and the jth base in the encoded sequence The score of the M state, For Node All predecessor nodes and the j-1th base in the encoded sequence M The comparison score under the state, , Node All the predecessor nodes and the j-1 base in the encoded sequence are inX 1. X The comparison score in 2 states, , Node All predecessor nodes and the alignment score of the j-1th base in the encoded sequencing sequence in the Y1 and Y2 states, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of Nodes are nodes The predecessor node of For Node The set of predecessor nodes; , are the nodes in the topological sorting order i and the jth base in the encoded sequence exist X 1. X The comparison score in 2 states, and , Node All predecessor nodes and the jth base in the sequence of M Status and X 1. X 2 state score, , They are X 1. X The missing penalty for the first vacancy in the 2-state, , They are X 1. X Extension missing penalty in 2 states; , are the node in the topological sorting and the jth base in the encoded sequence. of Y 1. Y The comparison score in 2 states, and , Node and the j-1th base in the sequence In the M state and Y 1. Y The comparison score in 2 states, , They are Y 1.Y The insertion penalty for the first vacancy in state 2, , They are Y 1. Y Extended insertion penalty in 2 states, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, max To get the maximum value.

[0083] The present invention adopts an improved partial order comparison algorithm to compare the compressed image after encoding. G c and the encoded sequence R Perform a comparison and output the best comparison score .

[0084] Step 5: construct a two-dimensional backtracking matrix based on the alignment score, determine the backtracking starting point based on the best alignment score position, select the alignment score source direction in its adjacent positions in turn based on the backtracking starting point as the backtracking direction to obtain the best alignment path, and perform sequence-to-graph alignment based on the best alignment path.

[0085] Based on the backtracking starting point, the source direction of the comparison score is selected in its adjacent position as the backtracking direction for backtracking, specifically:

[0086] In linear penalty:

[0087] if ,So ,

[0088] if ,So ,

[0089] if ,So ,

[0090] In the affine penalty:

[0091] if ,So ,

[0092] if ,So ,

[0093] if ,So ,

[0094] In the biaffine penalty:

[0095] if ,So ,

[0096] if ,So ,

[0097] if ,So ,

[0098] if ,So ,

[0099] if ,So ,

[0100] in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, For Node All predecessor nodes and the j-1th base in the encoded sequence The comparison score, For Node All predecessor nodes and the jth base in the sequence The comparison score, For Node and the j-1th base in the sequence The comparison score, is the missing penalty, For insertion penalty, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of is the i-th node after topological sorting of the encoded compressed graph and the jth base in the encoded sequence The backtracking direction of the corresponding score matrix unit, Forward node The order of The node in the topological sorting and the jth base in the encoded sequence The score of the M state, , , are the nodes in the topological sorting order i and the jth base in the encoded sequence of X , X 1 , X 2 The comparison score under the state, , , are the nodes in the topological sorting order i and the jth base in the encoded sequence Y, Y 1 、Y 2 The comparison score under the state.

[0101] The present invention adopts an improved backtracking algorithm based on the best comparison score Score Calculate and output the best alignment path P , sequence-to-graph alignment based on the best alignment path.

[0102] The present invention also provides a sequence-to-graph comparison system based on graph compression, comprising:

[0103] Data acquisition module: used to obtain genome maps and sequencing sequences.

[0104] Graph compression module: used to traverse all nodes in the genome graph, and obtain nodes with only one predecessor node and one successor node as nodes to be merged. If there are several nodes to be merged that have a common predecessor node and successor node, then several nodes to be merged are mergeable nodes. The mergeable nodes in the genome graph are merged to generate a merged node, and the genome graph is updated to obtain a compressed graph.

[0105] Coding module: used to encode the bases in the merged nodes and non-merged nodes in the compression graph based on the four-bit binary mark bit to obtain the encoded compression graph; encode each base in the sequencing sequence based on the four-bit binary mark bit to obtain the encoded sequencing sequence.

[0106] Sequence-to-graph alignment module: used to topologically sort the encoded compressed graph, perform partial order alignment with the encoded sequencing sequence, introduce base substitution penalty based on the alignment result, pre-set matching penalty and mismatch penalty, and obtain alignment scores in linear penalty, affine penalty and double affine penalty modes based on the introduced base substitution penalty. Based on the alignment score, the alignment score of the terminal node after topological sorting of the encoded compressed graph and the terminal base in the encoded sequencing sequence is obtained as the best alignment score.

[0107] Backtracking module: construct a two-dimensional backtracking matrix based on the alignment score, determine the backtracking starting point based on the best alignment score position, select the alignment score source direction in the adjacent positions of the backtracking starting point in turn as the backtracking direction to obtain the best alignment path, and perform sequence-to-graph alignment based on the best alignment path.

[0108] In addition, the present invention also provides a sequence-to-graph comparison device based on graph compression, comprising a processor and a memory, wherein the processor implements the sequence-to-graph comparison method based on graph compression as described above when executing a computer program stored in the memory.

[0109] The present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the above-mentioned sequence-to-graph comparison method based on graph compression.

[0110] Experimental Section

[0111] (1) A 6000 bp long sequence fragment was randomly selected from the MHC region of the human reference genome GRch38. Five simulated reference sequences were simulated on the reference sequence with SNP mutation rates of 1%, 5%, 10%, 15%, and 20% using the Mutation-Simulator. Together with the original sequence, a reference map was generated (genome map). .

[0112] (2) Genome map Compress to generate compressed image G c ,The number of nodes and edges of the graph before and after compression are shown in Table 1.

[0113] Table 1 Comparison of the number of vertices and edges before and after graph compression

[0114]

[0115] As can be seen from Table 1, the use of graph compression technology can compress about 16% of nodes and 25% of edges, which can effectively reduce the size of the graph.

[0116] The simulation sequence tool Pbsim was used to simulate 10-fold, 30-fold, and 50-fold sequencing sequences of the MHC region (chr6:29,000,000–34,000,000).

[0117] (4) Align the sequencing sequence to the compressed graph. The alignment results are shown in Table 2. The experimental results show that the alignment speed is effectively improved after compression.

[0118] Table 2 Comparison of image comparison time before and after compression

[0119]

[0120] In summary, the present invention compresses the graph structure, proposes a compressed graph comparison score calculation algorithm, and improves the backtracking algorithm, thereby realizing a sequence-to-graph comparison method with high accuracy, small storage space, and fast calculation speed.

Claims

1. A sequence-to-graph comparison method based on graph compression, characterized in that: The following steps are involved: S1. Obtain genome map and sequencing sequence; S2. Compression of genome graph: traverse all nodes in the genome graph, obtain nodes with only one predecessor node and one successor node as nodes to be merged, if there are several nodes to be merged that have a common predecessor node and successor node, then several nodes to be merged are mergeable nodes, merge the mergeable nodes in the genome graph to generate a merged node, and update the genome graph to obtain a compressed graph; S3, encoding: encoding the bases in the merged nodes and the non-merged nodes in the compressed graph based on the four-bit binary mark bit to obtain the encoded compressed graph; Encoding each base in the sequencing sequence based on four binary marker bits to obtain an encoded sequencing sequence; S4. Sequence-to-graph alignment: The encoded compressed graph is topologically sorted and partially aligned with the encoded sequencing sequence. A base substitution penalty is introduced based on the alignment result, the pre-set match penalty and mismatch penalty. Based on the introduced base substitution penalty, the alignment scores in the linear penalty, affine penalty and double affine penalty modes are obtained respectively. Based on the alignment score, the alignment score between the terminal node after topological sorting of the encoded compressed graph and the terminal base in the encoded sequencing sequence is determined as the best alignment score; The introduced base substitution penalty is calculated as follows: , in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of is the matching penalty entered by the user, is the mismatch penalty entered by the user, is the bitwise AND function; The alignment score in the linear penalty mode is obtained based on the introduced base substitution penalty, specifically: , in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, For Node All predecessor nodes and the j-1th base in the encoded sequence The comparison score, For Node All predecessor nodes and the jth base in the sequence The comparison score, For Node and the j-1th base in the sequence The comparison score, is the missing penalty, For insertion penalty, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of Nodes are nodes The predecessor node of For Node The predecessor node set of max To obtain the maximum value; The alignment score under the affine penalty mode is obtained based on the introduced base substitution penalty, specifically: , Among them, M is the state without penalty, X is the state with missing penalty, and Y is the state with insertion penalty. The node in the topological sorting and the jth base in the encoded sequence The score of the M state, For Node All predecessor nodes and the j-1th base in the encoded sequence M The comparison score under the state, For Node All predecessor nodes and the j-1th base in the encoded sequence X The comparison score under the state, For Node All predecessor nodes and the j-1th base in the encoded sequence Y The comparison score under the state, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of Nodes are nodes The predecessor node of For Node The set of predecessor nodes; The node in topological sorting and the jth base in the encoded sequence of X The comparison score under the state, and Node All predecessor nodes and the jth base in the sequence of M Status and X Status score, is the missing penalty for the first vacancy, Penalty points for extended missing; The node in the topological sorting and the jth base in the encoded sequence Y The comparison score under the state, and Node and the j-1th base in the sequence The comparison scores between the M state and the Y state, is the insertion penalty for the first vacancy, Penalty for extension insertion, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, max To obtain the maximum value; The calculation of the alignment score in the double affine penalty mode after the base substitution penalty is introduced is specifically: , Among them, M is the state without penalty, For the missing penalty state of the first affine penalty, To perform the missing penalty state for the second affine penalty, To perform the insertion penalty state of the first affine penalty, To perform the insertion penalty state for the second affine penalty, The node in the topological sorting and the jth base in the encoded sequence The score of the M state, For Node All predecessor nodes and the j-1th base in the encoded sequence M The comparison score under the state, , Node All the predecessor nodes and the j-1 base in the encoded sequence are in X 1. X The comparison score in 2 states, , Node All predecessor nodes and the alignment score of the j-1th base in the encoded sequencing sequence in the Y1 and Y2 states, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of Nodes are nodes The predecessor node of For Node The set of predecessor nodes; , are the nodes in the topological sorting order i and the jth base in the encoded sequence exist X 1. X The comparison score in 2 states, and , Node All predecessor nodes and the jth base in the sequence of M Status and X 1. X 2 state score, , They are X 1. X The missing penalty for the first vacancy in the 2-state, , They are X 1. X Extension missing penalty in 2 states; , are the node in the topological sorting and the jth base in the encoded sequence. of Y 1. Y The comparison score in 2 states, and , Node and the j-1th base in the sequence In the M state and Y 1. Y The comparison score in 2 states, , They are Y 1. Y The insertion penalty for the first vacancy in state 2, , They are Y 1. Y Extended insertion penalty in 2 states, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, max To obtain the maximum value; S5. Construct a two-dimensional backtracking matrix based on the alignment score, determine the backtracking starting point based on the best alignment score position, select the alignment score source direction in the adjacent positions of the backtracking starting point in turn as the backtracking direction to perform backtracking, obtain the best alignment path, and perform sequence-to-graph alignment based on the best alignment path.

2. The sequence-to-graph comparison method based on graph compression according to claim 1, characterized in that: In S5, based on the backtracking starting point, the direction of the source of the comparison score is selected in the adjacent positions in turn as the backtracking direction for backtracking, specifically: In linear penalty: if ,So , if ,So , if ,So , In the affine penalty: if ,So , if ,So , if ,So , In the biaffine penalty: if ,So , if ,So , if ,So , if ,So , if ,So , in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence The comparison score, For Node All predecessor nodes and the j-1th base in the encoded sequence The comparison score, For Node All predecessor nodes and the jth base in the sequence The comparison score, For Node and the j-1th base in the sequence The comparison score, is the missing penalty, For insertion penalty, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of is the i-th node after topological sorting of the encoded compressed graph and the jth base in the encoded sequence The backtracking direction of the corresponding score matrix unit, Forward node The order of The node in the topological sorting and the jth base in the encoded sequence The score of the M state, , , are the nodes in the topological sorting order i and the jth base in the encoded sequence of X , X 1 , X 2 The comparison score under the state, , , are the nodes in the topological sorting order i and the jth base in the encoded sequence Y, Y 1 、Y 2 The comparison score under the state.

3. The sequence-to-graph comparison method based on graph compression according to claim 1, characterized in that: After obtaining a node with only one predecessor node and one successor node as a node to be merged in S2, it also includes: using a group of predecessor nodes and successor nodes of the node to be merged as keys of a hash table, and storing the ID of the node to be merged as a value in the hash table, traversing the hash table, and if the length of the value list corresponding to the key is greater than 1, it is determined that the corresponding several nodes to be merged have a common predecessor node and successor node, and are mergeable nodes.

4. The sequence-to-graph comparison method based on graph compression according to claim 1, characterized in that: In the S3, base encoding is performed on the merging nodes and non-merging nodes of the compressed graph based on a four-bit binary mark bit, as follows: if the mark bit is 1, it indicates that the base exists in the merging nodes and non-merging nodes before the merging; if the mark bit is 0, it indicates that the base does not exist in the merging nodes and non-merging nodes before the merging.

5. A sequence-to-graph comparison system based on graph compression, characterized in that: include: Data acquisition module: used to obtain genome maps and sequencing sequences; Graph compression module: used to traverse all nodes in the genome graph, obtain nodes with only one predecessor node and one successor node as nodes to be merged, if there are several nodes to be merged that have a common predecessor node and successor node, then several nodes to be merged are mergeable nodes, merge the mergeable nodes in the genome graph to generate a merged node, and obtain a compressed graph after updating the genome graph; Encoding module: used to encode the bases in the merged nodes and the non-merged nodes in the compressed graph based on the four-bit binary mark bit to obtain the encoded compressed graph; Encoding each base in the sequencing sequence based on four binary marker bits to obtain an encoded sequencing sequence; Sequence-to-graph alignment module: used to topologically sort the encoded compressed graph, perform partial order alignment with the encoded sequencing sequence, introduce base substitution penalty based on the alignment result, pre-set matching penalty and mismatch penalty, obtain alignment scores in linear penalty, affine penalty and double affine penalty modes based on the introduced base substitution penalty, and obtain the alignment score of the last node after topological sorting of the encoded compressed graph and the last base in the encoded sequencing sequence as the best alignment score based on the alignment score; The introduced base substitution penalty is calculated as follows: , in, is the topological sorting of the compressed graph after encoding. i Bit Node and the jth base in the encoded sequence Base substitution penalty of is the matching penalty entered by the user, is the mismatch penalty entered by the user, is the bitwise AND function; Backtracking module: construct a two-dimensional backtracking matrix based on the alignment score, determine the backtracking starting point based on the best alignment score position, select the alignment score source direction in the adjacent positions of the backtracking starting point in turn as the backtracking direction to obtain the best alignment path, and perform sequence-to-graph alignment based on the best alignment path.

6. A sequence-to-graph comparison device based on graph compression, characterized in that: The method comprises a processor and a memory, wherein when the processor executes the computer program stored in the memory, the method for sequence-to-graph comparison based on graph compression as described in any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the sequence-to-graph comparison method based on graph compression as described in any one of claims 1 to 4 is implemented.