Search in sources :

Example 1 with FastaSequenceWriterWrapper

use of com.milaboratory.core.io.sequence.fasta.FastaSequenceWriterWrapper in project mixcr by milaboratory.

the class ActionExportCloneReads method createWriter.

private static SequenceWriter createWriter(boolean paired, String fileName) throws IOException {
    String[] split = fileName.split("\\.");
    String ext = split[split.length - 1];
    boolean gz = ext.equals("gz");
    if (gz)
        ext = split[split.length - 2];
    if (ext.equals("fasta")) {
        if (paired)
            throw new IllegalArgumentException("Fasta does not support paired reads.");
        return new FastaSequenceWriterWrapper(fileName);
    } else if (ext.equals("fastq")) {
        if (paired) {
            String fileName1 = fileName.replace(".fastq", "_R1.fastq");
            String fileName2 = fileName.replace(".fastq", "_R2.fastq");
            return new PairedFastqWriter(fileName1, fileName2);
        } else
            return new SingleFastqWriter(fileName);
    }
    if (paired)
        return new PairedFastqWriter(fileName + "_R1.fastq.gz", fileName + "_R2.fastq.gz");
    else
        return new SingleFastqWriter(fileName + ".fastq.gz");
}
Also used : SingleFastqWriter(com.milaboratory.core.io.sequence.fastq.SingleFastqWriter) FastaSequenceWriterWrapper(com.milaboratory.core.io.sequence.fasta.FastaSequenceWriterWrapper) PairedFastqWriter(com.milaboratory.core.io.sequence.fastq.PairedFastqWriter)

Aggregations

FastaSequenceWriterWrapper (com.milaboratory.core.io.sequence.fasta.FastaSequenceWriterWrapper)1 PairedFastqWriter (com.milaboratory.core.io.sequence.fastq.PairedFastqWriter)1 SingleFastqWriter (com.milaboratory.core.io.sequence.fastq.SingleFastqWriter)1