【BioCode】將多個蛋白質序列分成單個的txt文檔
阿新 • • 發佈:2017-07-04
span package bsp -1 http println != show ade
代碼說明:
fasta格式的蛋白質序列,一個txt裏面有很多蛋白質序列,計算ss、pssm或disorder score時候都需要單條計算,需要分開。
分割前:
分割後:
show you the code:
package single; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.*; import java.io.IOException; //將整個文件分成單個的TXT文件 public class Single {public static void getTxt(String path) throws IOException { try { FileReader reader = new FileReader(path); BufferedReader br = new BufferedReader(reader); String str = null; String str1 = null; int count = 0; while ((str = br.readLine()) != null) { System.out.println(str); str1 = br.readLine(); count++; //E:\experiment----N-formylated\single FileWriter fileWritter = new FileWriter("E:\\experiment--help\\linglingbao\\new-single\\" + count + ".txt");//使用數字對每個txt編號 BufferedWriter bufferWritter = newBufferedWriter(fileWritter); bufferWritter.write(str+"\n"); bufferWritter.write(str1); bufferWritter.flush(); } System.out.println(count); br.close(); reader.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void main(String[] args) { String path = "E:\\experiment--help\\linglingbao\\new-single\\seq.txt"; try { getTxt(path); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
【BioCode】將多個蛋白質序列分成單個的txt文檔