/** * Simply transfer every header and sequence remaining in the input stream to this output stream * * @param inputStream the stream to copy to this stream * @throws IOException if there was a problem openning or working with either stream */ public void appendRemaining(final DBInputStream inputStream) throws IOException { if (inputStream != null) { while (inputStream.gotoNextSequence()) { this.appendSequence(inputStream.getHeader(), inputStream.getSequence()); } } }
/** * goes through each header in a fasta file and checks to make sure it is a valid fasta header. If * any problems are encountered or a header does not check out then false is returned * * @param toCheck the file you want to see is a valid FASTA file * @return true if the file is a valid fasta file else false */ public static boolean isFASTAFileValid(final File toCheck) { DBInputStream in = null; try { in = new FASTAInputStream(toCheck); int sequenceCount = 0; in.beforeFirst(); while (in.gotoNextSequence()) { if (isHeader(in.getHeader())) { sequenceCount++; } else { return false; } } return (sequenceCount != 0); } catch (Exception e) { // SWALLOWED: We just return false as in "not valid" LOGGER.warn(e); return false; } finally { FileUtilities.closeQuietly(in); } }