zoukankan      html  css  js  c++  java
  • 【BioCode】将多个蛋白质序列分成单个的txt文档

    代码说明:

    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-formylatedsingle
                    FileWriter fileWritter = new FileWriter("E:\experiment--help\linglingbao\new-single\" + count + ".txt");//使用数字对每个txt编号
                    BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
                    bufferWritter.write(str+"
    ");
                    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();
            }
        }
    }
  • 相关阅读:
    切蛋糕
    STL----deque
    Java语法 [常识1]
    SQL Server 数据库基础编程
    SQL Server 数据库基础编程
    SQL Server 索引和视图
    SQL Server 索引和视图
    SQL Server 事务、异常和游标
    SQL Server 事务、异常和游标
    SQL Server 存储过程
  • 原文地址:https://www.cnblogs.com/yumiaomiao/p/7118248.html
Copyright © 2011-2022 走看看