我有一个 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();
}
}
关于java - 将 FASTA 文件读入字符串 JAVA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49756410/