// Path: src/be/uzleuven/gc/logistics/GBSX/utils/fasta/model/FastaRead.java
// public class FastaRead {
//     
//     private String sequence;
//     private String description;
//     
//     /**
//      * creates a new fasta read with "no description" and the given sequence
//      * @param sequence | String the sequence
//      */
//     private FastaRead(String sequence){
//         this.description = "> no description";
//         this.sequence = sequence;
//     }
//     
//     /**
//      * creates a new fasta read with the given description and the given sequence
//      * @param sequence | String the sequence
//      */
//     public FastaRead(String description, String sequence){
//         if (! description.startsWith(">")){
//             description = ">" + description;
//         }
//         this.description = description;
//         this.sequence = sequence;
//     }
//     
//     /**
//      * 
//      * @return String | the description of the fasta read
//      */
//     public String getDescription(){
//         return this.description;
//     }
//     
//     /**
//      * 
//      * @return String | the sequence of the fasta read
//      */
//     public String getSequence(){
//         return this.sequence;
//     }
//     
// }


import be.uzleuven.gc.logistics.GBSX.utils.fasta.model.FastaRead;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.GZIPOutputStream;
     */
    public FastaBufferedWriter(URL url, boolean ziped) throws FileNotFoundException, IOException{
        if (ziped){
            this.fastaBufferedWriter = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(url.getPath()))));
        }else{
            this.fastaBufferedWriter = new BufferedWriter(new OutputStreamWriter(new DataOutputStream(new FileOutputStream(url.getPath()))));
        }
    } 
    /**
     * creates a new FastaBufferedReader of the given URL.
     * @param url | the URL of the file that must be writen
     * @param  ziped | true if the file must be zipped
     * @param append | true if append to existing file
     * @throws FileNotFoundException | if the given file isn't found
     * @throws IOException | if an error occures while opening the file
     */
    public FastaBufferedWriter(URL url, boolean ziped, boolean append) throws FileNotFoundException, IOException{
        if (ziped){
            this.fastaBufferedWriter = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(url.getPath(), append))));
        }else{
            this.fastaBufferedWriter = new BufferedWriter(new OutputStreamWriter(new DataOutputStream(new FileOutputStream(url.getPath(), append))));
        }
    } 
    
    
    /**
     * writes the next lines in the fasta file. 
     * @param fasta | a fastaRead
     * @throws IOException | if any error occures while writing the file
     */
// Path: src/be/uzleuven/gc/logistics/GBSX/utils/fasta/model/FastaRead.java
// public class FastaRead {
//     
//     private String sequence;
//     private String description;
//     
//     /**
//      * creates a new fasta read with "no description" and the given sequence
//      * @param sequence | String the sequence
//      */
//     private FastaRead(String sequence){
//         this.description = "> no description";
//         this.sequence = sequence;
//     }
//     
//     /**
//      * creates a new fasta read with the given description and the given sequence
//      * @param sequence | String the sequence
//      */
//     public FastaRead(String description, String sequence){
//         if (! description.startsWith(">")){
//             description = ">" + description;
//         }
//         this.description = description;
//         this.sequence = sequence;
//     }
//     
//     /**
//      * 
//      * @return String | the description of the fasta read
//      */
//     public String getDescription(){
//         return this.description;
//     }
//     
//     /**
//      * 
//      * @return String | the sequence of the fasta read
//      */
//     public String getSequence(){
//         return this.sequence;
//     }
//     
// }


// Path: src/be/uzleuven/gc/logistics/GBSX/utils/fasta/infrastructure/FastaBufferedWriter.java
import be.uzleuven.gc.logistics.GBSX.utils.fasta.model.FastaRead;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.GZIPOutputStream;

     */
    public FastaBufferedWriter(URL url, boolean ziped) throws FileNotFoundException, IOException{
        if (ziped){
            this.fastaBufferedWriter = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(url.getPath()))));
        }else{
            this.fastaBufferedWriter = new BufferedWriter(new OutputStreamWriter(new DataOutputStream(new FileOutputStream(url.getPath()))));
        }
    } 
    /**
     * creates a new FastaBufferedReader of the given URL.
     * @param url | the URL of the file that must be writen
     * @param  ziped | true if the file must be zipped
     * @param append | true if append to existing file
     * @throws FileNotFoundException | if the given file isn't found
     * @throws IOException | if an error occures while opening the file
     */
    public FastaBufferedWriter(URL url, boolean ziped, boolean append) throws FileNotFoundException, IOException{
        if (ziped){
            this.fastaBufferedWriter = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(url.getPath(), append))));
        }else{
            this.fastaBufferedWriter = new BufferedWriter(new OutputStreamWriter(new DataOutputStream(new FileOutputStream(url.getPath(), append))));
        }
    } 
    
    
    /**
     * writes the next lines in the fasta file. 
     * @param fasta | a fastaRead
     * @throws IOException | if any error occures while writing the file
     */
    public void write(FastaRead fasta) throws IOException{