package bullet;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

import java.io.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.*;
import org.biojava.bio.symbol.*;
import org.biojava.bio.seq.io.*;

public class convertToFasta {

  public convertToFasta() {
  }
  public static void main(String[] args) {
    Sequence s = bullet.LoadSeq(args[0]);
    String st = s.seqString();
    int m = 60;
    if(args.length>1) m = Integer.parseInt(args[1]);
    int  n = st.length()/m;
    System.out.println("Length = "+st.length()+" n = "+n);
    try{
    FileWriter fw = new FileWriter(args[0]+".fa");
    fw.write(">"+s.getURN()+"\n");
    for(int i=0;i<n;i++){
       //fw.write(Integer.toString(i*m+1)+" ");
       //System.out.println(i*m+1);
       fw.write(st.substring(i*m,(i+1)*m));
       fw.write(13);
       fw.write("\n");
    }
    fw.write(st.substring(n*m)+"\n");
    fw.close();

    }catch(Exception e){
      e.printStackTrace();
    }
  }
}