将 FASTA 文件读入字符串 JAVA

Read a FASTA file into string JAVA

我有一个 FASTA 文件格式,其中包含大约 5M~ 个字符。 我想知道你们是否有任何代码可以将这些大信息读入字符串。

您可以尝试 FASTA_format

中的代码示例
import java.io.*;
import java.util.Scanner;

public class ReadFastaFile {

    public static void main(String[] args) throws FileNotFoundException {

        boolean first = true;

        try (Scanner sc = new Scanner(new File("test.fasta"))) {
            while (sc.hasNextLine()) {
                String line = sc.nextLine().trim();
                if (line.charAt(0) == '>') {
                    if (first)
                        first = false;
                    else
                        System.out.println();
                    System.out.printf("%s: ", line.substring(1));
                } else {
                    System.out.print(line);
                }
            }
        }
        System.out.println();
    }

}