/** @throws Exception */ public void process() throws Exception { byte[] lineSep = System.getProperty("line.separator").getBytes(); for (GeneSequence sequence : sequences) { String header = headerFormat.getHeader(sequence); os.write('>'); os.write(header.getBytes()); os.write(lineSep); int compoundCount = 0; String seq = ""; // GeneSequence currently has a strand attribute to indicate direction seq = sequence.getSequence5PrimeTo3Prime().getSequenceAsString(); if (showExonUppercase) { StringBuilder sb = new StringBuilder(seq.toLowerCase()); int geneBioBegin = sequence.getBioBegin(); int geneBioEnd = sequence.getBioEnd(); for (ExonSequence exonSequence : sequence.getExonSequences()) { int featureBioBegin = 0; int featureBioEnd = 0; if (sequence.getStrand() != Strand.NEGATIVE) { featureBioBegin = exonSequence.getBioBegin() - geneBioBegin; featureBioEnd = exonSequence.getBioEnd() - geneBioBegin; } else { featureBioBegin = geneBioEnd - exonSequence.getBioEnd(); featureBioEnd = geneBioEnd - exonSequence.getBioBegin(); } if (featureBioBegin < 0 || featureBioEnd < 0 || featureBioEnd > sb.length() || featureBioBegin > sb.length()) { System.out.println( "Bad Feature " + sequence.getAccession().toString() + " " + sequence.getStrand() + " " + geneBioBegin + " " + geneBioEnd + " " + exonSequence.getBioBegin() + " " + exonSequence.getBioEnd()); } else { for (int i = featureBioBegin; i <= featureBioEnd; i++) { char ch = sb.charAt(i); // probably not the fastest but the safest way if language is not standard ASCII String temp = ch + ""; ch = temp.toUpperCase().charAt(0); sb.setCharAt(i, ch); } } } seq = sb.toString(); } for (int i = 0; i < seq.length(); i++) { os.write(seq.charAt(i)); compoundCount++; if (compoundCount == lineLength) { os.write(lineSep); compoundCount = 0; } } // If we had sequence which was a reciprocal of line length // then don't write the line terminator as this has already written // it if ((sequence.getLength() % getLineLength()) != 0) { os.write(lineSep); } } }