Quality control algorithm of nucleic acid sequence
By designing a quality control algorithm for nucleic acid sequences, integrating multiple quality control standards and using multi-threaded processing, the low-efficiency and multi-dimensional quality control problems in the existing technology are solved, efficient and accurate nucleic acid sequence screening is achieved, and data Reliability and adaptability.
Patent Information
- Application Number
- CN202411733347.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2024-12-31
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing nucleic acid sequence quality control methods are difficult to integrate multiple quality control standards, have low processing efficiency, and are difficult to adapt to the massive data generated by high-throughput sequencing technology, resulting in low-quality data entering the subsequent analysis process, affecting the reliability of the results.
A quality control algorithm for nucleic acid sequences was designed. By reading the sequence from the FASTA format file, calculating the sequence length, mixed base ratio, illegal bases and repeat sequences, setting thresholds for screening, labeling and classifying them as 'success' or 'fail' and accelerate the quality control process through multithreading.
It realizes efficient and accurate multi-dimensional quality control, can quickly identify and remove low-quality sequences, ensure data reliability and adapt to large-scale data processing needs, and provides flexible quality control standard adjustments to apply to different types of nucleic acid data. .
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of bioinformatics, and in particular, relates to a quality control algorithm for nucleic acid sequences. Background Art
[0002] With the rapid development of high-throughput sequencing technology, a large amount of nucleic acid sequence data has been accumulated in the field of bioinformatics. These data play a vital role in the research of genomics, transcriptomics and evolutionary biology. However, low-quality sequence data will inevitably be generated during the sequencing process, such as sequences containing incorrect bases, sequences that are too short or sequences with too high a ratio of mixed bases. If these low-quality data are not screened and enter the subsequent analysis process, they may lead to wrong conclusions, seriously affecting the reliability of the analysis and the accuracy of the research results.
[0003] Existing quality control methods usually focus on the following aspects: Sequence length: Sequences that are too short are often generated during sequencing. These short sequences may be the result of misoperation of the sequencing instrument or data truncation. Sequences that are too short may not provide sufficient biological information in alignment and analysis, so length filtering is required.
[0004] Mixed base ratio: Mixed bases refer to base positions that cannot be determined (such as N, R, Y, etc.), which usually indicate that there may be multiple bases at that position. Too high a mixed base ratio in a sequence will lead to inaccurate alignment, so a reasonable threshold needs to be set during data processing to filter out such sequences.
[0005] Illegal bases: Due to sequencing errors or data format problems, other characters that are not in the standard base set (A, T, C, G) or mixed base sets may appear in the sequence. Such sequences usually indicate incorrect data and must be removed before analysis.
[0006] Repeated sequences: In the same data set, repeated sequences will affect gene abundance estimation and evolutionary analysis, so the detection and removal of repeated sequences are necessary steps in data cleaning.
[0007] Although existing quality control tools and methods are able to partially process the above-mentioned types of low-quality data, they are usually difficult to integrate multiple quality control standards and the processing efficiency is not high. For example, some tools can only filter based on sequence length, but cannot comprehensively consider mixed base ratios, illegal bases, and repeated sequences. In addition, most existing tools are inefficient when processing large-scale high-throughput sequencing data and are difficult to adapt to the massive data generated by modern sequencing technologies. Therefore, there is an urgent need for an efficient, accurate, and integrated sequence quality control method that can quickly screen out high-quality sequences and ensure the reliability of the data. Summary of the invention
[0008] The purpose of the present invention is to provide a quality control algorithm for nucleic acid sequences, which solves the problems existing in the prior art.
[0009] The purpose of the present invention can be achieved through the following technical solutions: A quality control algorithm for nucleic acid sequences, characterized in that it specifically comprises the following steps: Step 1: read multiple nucleic acid sequences from the FASTA format input file, each sequence contains a sequence ID and nucleic acid sequence data; Step 2: Perform quality control on each nucleic acid sequence; Step 3: Based on the quality control results, the sequences are marked and classified as “successful” or “failed”; Step 4: Save the quality control results of each sequence to the specified output file. The output content includes the sequence ID and the quality control results.
[0010] Preferably, quality control of each nucleic acid sequence specifically comprises the following steps: S1. Calculate the total length of the sequence; S2, checking whether the sequence length is greater than or equal to a preset minimum length threshold; S3, calculating the ratio of mixed bases in the sequence, and comparing it with a preset mixed base ratio threshold; S4, checking whether the sequence contains non-bases, that is, whether the sequence contains bases beyond the valid nucleotide set and mixed base set; S5. Check whether the sequence is a repeated sequence.
[0011] Preferably, the "failure" category in step 3 includes the following situations: a. The sequence length is less than the preset minimum length threshold; b. The ratio of mixed bases in the sequence exceeds the set mixed base ratio threshold; c. The sequence contains illegal bases; d. The sequence is a repetitive sequence.
[0012] Preferably, the preset minimum length threshold is 1000 bases.
[0013] Preferably, the ratio threshold of mixed bases is 0.05, that is, the ratio of mixed bases in the sequence shall not exceed 5%.
[0014] Preferably, the valid base set includes A, T, C, G, and the mixed base set includes N, R, Y, S, W, K, M, B, D, H, V, wherein an illegal base refers to any other character that is not in the valid base set and the mixed base set.
[0015] Preferably, the method of checking whether a sequence is a repeated sequence comprises storing processed sequences in a set, and checking whether each new sequence already exists in the set when processing it.
[0016] Beneficial effects of the present invention: The present invention can efficiently and automatically screen low-quality nucleic acid sequences through a multi-dimensional quality control process to ensure the accuracy of downstream data analysis.
[0017] Its main beneficial effects include: strong comprehensiveness: integrating multiple quality control standards, including sequence length, mixed base ratio, illegal bases and repeated sequences, etc., which can effectively identify and remove low-quality sequences. High efficiency: through automated quality control processes and efficient data structures, the present invention can quickly process large-scale high-throughput sequencing data and adapt to the big data processing needs in modern bioinformatics research. Accuracy: by reasonably setting quality control thresholds and multiple screening criteria, the present invention can ensure the accuracy of data screening and avoid mistakenly screening out valuable sequences. Flexibility: the quality control standards of the present invention (such as sequence length and mixed base ratio thresholds) can be adjusted according to specific project requirements and are suitable for different types of nucleic acid sequence data. DETAILED DESCRIPTION
[0018] The following will be combined with the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] The present invention is a quality control algorithm for nucleic acid sequences, which specifically comprises the following steps: Step 1: Read multiple nucleic acid sequences from an input file in FASTA format, each sequence containing a sequence ID and nucleic acid sequence data; store the read sequences in a list structure, in which each element is a tuple, respectively containing a sequence ID and a corresponding nucleic acid sequence.
[0020] The sequence ID begins with a > symbol, followed by the actual sequence content. The present invention reads the FASTA file line by line, parses each sequence and stores it in the form of a key-value pair (ID and sequence) for subsequent processing.
[0021] def read_fasta(file_path): with open(file_path, "r") as file: sequences = [] seq_id = "" seq = "" for line in file: line = line.strip() # remove the spaces at the end of each line if line.startswith(">"): # Check sequence ID line if seq_id and seq: # Save the previous sequence sequences.append((seq_id, seq)) seq_id = line[1:] # Get the sequence ID, remove the '>' symbol seq = "" # Initialize a new sequence else: seq += line # add sequence line if seq_id and seq: # Save the last sequence sequences.append((seq_id, seq)) return sequences Input: FASTA format file path.
[0022] Output: A list containing sequence IDs and corresponding nucleic acid sequences.
[0023] Step 2: Perform quality control on each nucleic acid sequence; The quality control of each nucleic acid sequence specifically includes the following steps: S1. Calculate the total length of the sequence; sequence length is one of the important criteria for nucleic acid sequence quality control. During the sequencing process, too short sequences are often generated, and these sequences may not have sufficient biological information. In the present invention, the minimum sequence length threshold is set to 1000 bases, and any sequence with a length less than this threshold will be marked as "failed".
[0024] is_short = seq_len <min_length Threshold: min_length=1000 Result: If the sequence length is less than 1000 bases, the sequence is marked as "Failed: sequence length too short".
[0025] S2, checking whether the sequence length is greater than or equal to a preset minimum length threshold; S3. Calculate the ratio of mixed bases in the sequence and compare it with the preset mixed base ratio threshold; mixed bases (such as N, R, Y, S, etc.) usually indicate that there are uncertain bases at this position. If the mixed base ratio is too high, it will lead to inaccurate sequence alignment, so the present invention sets the threshold of the mixed base ratio to 5%. If the ratio of mixed bases in the sequence exceeds this threshold, the sequence is marked as "failed".
[0026] mixed_base_count = sum(1 for base in seq if base in mixed_bases) mixed_base_ratio = mixed_base_count / seq_len is_mixed = mixed_base_ratio>mixed_base_threshold Threshold: mixed_base_threshold=0.05 Result: If the mixed base ratio exceeds 5%, the sequence is marked as "Failed: Mixed base ratio too high".
[0027] S4. Check whether the sequence contains non-bases, that is, whether the sequence contains bases beyond the valid nucleotide set and the mixed base set; the valid base set includes A, T, C, G, and the mixed base set includes N, R, Y, S, W, K, M, B, D, H, V, and the illegal base refers to any other character that is not in the valid base set and the mixed base set.
[0028] An illegal base is a character that does not belong to a standard base or a mixed base set. An illegal base may be the result of a sequencing error or a data format problem. The present invention detects illegal bases in a sequence, and once found, the sequence will be marked as "failed".
[0029] invalid_base_count = sum(1 for base in seq if base not in valid_nucleotides | mixed_bases) is_invalid = invalid_base_count>0 Result: If there are illegal bases in the sequence, the sequence is marked as "Failed: Illegal nucleotide sequence".
[0030] S5. Check whether the sequence is a repeated sequence. The method of checking whether the sequence is a repeated sequence includes storing the processed sequences in a set, and checking whether each new sequence already exists in the set when processing it.
[0031] Step 3: Based on the quality control results, the sequences are marked and classified as "successful" or "failed". The "failed" category includes the following situations: a. The sequence length is less than the preset minimum length threshold; b. The ratio of mixed bases in the sequence exceeds the set mixed base ratio threshold; the mixed base ratio threshold is 0.05, that is, the ratio of mixed bases in the sequence shall not exceed 5%.
[0032] c. The sequence contains illegal bases; d. The sequence is a repetitive sequence. In nucleic acid sequence data, repetitive sequences will affect the accuracy of analysis, especially in gene expression quantification and evolutionary analysis. The present invention identifies and removes repetitive sequences by examining the processed sequence set.
[0033] is_duplicate = seq in seen_sequences Result: If the sequence is identical to a sequence already processed, the sequence is marked as Failed: Duplicate sequence.
[0034] Step 4: Save the quality control results of each sequence to the specified output file. The output content includes the sequence ID and the quality control results.
[0035] The quality control results will eventually be output as a file or displayed to the user for subsequent data analysis. The file contains the ID of each sequence and its corresponding quality control result.
[0036] Assume that results is the generated quality control results list for result in results: print(f"Serial number: {result['id']}, Quality control result: {result['result']}") Output: Save the quality control results as a file in a specified format for subsequent analysis.
[0037] To further improve processing efficiency, especially when processing large-scale high-throughput sequencing data, the present invention can also accelerate the quality control process through multi-threaded parallel processing. During the quality control process, multiple sequences can be simultaneously tested for length, mixed bases, illegal bases, and repeated sequences.
[0038] from concurrent.futures import ThreadPoolExecutor def process_sequence(seq_id, seq): # Perform specific quality control steps... return {"id": seq_id, "result": result} with ThreadPoolExecutor(max_workers=4) as executor: results = list(executor.map(lambda s: process_sequence(s[0], s[1]), sequences)) Optimization effect: Multi-threaded processing can significantly reduce the execution time of the quality control process, especially on large-scale data sets.
[0039] The quality control standards of the present invention (such as minimum sequence length, mixed base ratio threshold, etc.) can be customized according to different application scenarios. For example, different quality control parameters can be set through user input or configuration files to meet different research needs.
[0040] min_length = 500 # can be adjusted according to project requirements mixed_base_threshold = 0.1 # Allow a higher mixed base ratio Flexibility: Adjust quality control standards according to different project requirements, suitable for different types of nucleic acid data such as genome sequencing and transcriptome analysis.
[0041] In the description of the specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0042] The above contents are merely examples and explanations of the concept of the present invention. The technicians in this technical field may make various modifications or additions to the specific embodiments described or replace them in a similar manner. As long as they do not deviate from the concept of the invention or exceed the scope defined by the claims, they should all fall within the protection scope of the present invention.
Claims
1. A quality control algorithm for nucleic acid sequences, characterized in that: The specific steps include: Step 1: read multiple nucleic acid sequences from the FASTA format input file, each sequence containing a sequence ID and nucleic acid sequence data; Step 2: Perform quality control on each nucleic acid sequence; Step 3: Based on the quality control results, the sequences are marked and classified as "successful" or "failed"; Step 4: Save the quality control results of each sequence to the specified output file. The output content includes the sequence ID and the quality control results.
2. A nucleic acid sequence quality control algorithm according to claim 1, characterized in that: The quality control of each nucleic acid sequence specifically includes the following steps: S1. Calculate the total length of the sequence; S2, checking whether the sequence length is greater than or equal to a preset minimum length threshold; S3, calculating the ratio of mixed bases in the sequence, and comparing it with a preset mixed base ratio threshold; S4, checking whether the sequence contains non-bases, that is, whether the sequence contains bases beyond the valid nucleotide set and mixed base set; S5. Check whether the sequence is a repeated sequence.
3. A nucleic acid sequence quality control algorithm according to claim 1, characterized in that: The "failure" category in step 3 includes the following situations: a. The sequence length is less than the preset minimum length threshold; b. The ratio of mixed bases in the sequence exceeds the set mixed base ratio threshold; c. The sequence contains illegal bases; d. The sequence is a repetitive sequence.
4. A nucleic acid sequence quality control algorithm according to claim 2, characterized in that: The preset minimum length threshold is 1000 bases.
5. A nucleic acid sequence quality control algorithm according to claim 2, characterized in that: The threshold of the ratio of mixed bases is 0.05, that is, the ratio of mixed bases in the sequence shall not exceed 5%.
6. A nucleic acid sequence quality control algorithm according to claim 2, characterized in that: The valid base set includes A, T, C, and G, and the mixed base set includes N, R, Y, S, W, K, M, B, D, H, and V. An illegal base refers to any other character that is not in the valid base set and the mixed base set.
7. A nucleic acid sequence quality control algorithm according to claim 2, characterized in that: A method for checking whether a sequence is a duplicate consists of storing the processed sequences in a set and checking whether each new sequence already exists in the set when it is processed.
Citation Information
Patent Citations
Method for detecting mononucleotide polymorphism
CN101539967A
Quality evaluation method for nucleic acid sequencing data
CN116246703A
Base sequencing quality evaluation method
CN116434843A
Processing method and device for efficiently utilizing next-generation sequencing data of microbial amplicons, storage medium and equipment
CN117373535A
System and method for consensus-calling with per-base quality values for sample assemblies
US20040053246A1