use of org.jbei.ice.storage.hibernate.dao.SequenceDAO in project ice by JBEI.
the class BlastPlus method writeBigFastaFile.
/**
* Retrieve all the sequences from the database, and writes it out to a fasta file on disk.
*
* @throws BlastException
*/
private static void writeBigFastaFile(BufferedWriter writer) throws BlastException {
SequenceDAO sequenceDAO = DAOFactory.getSequenceDAO();
long count = sequenceDAO.getSequenceCount();
if (count <= 0)
return;
int offset = 0;
while (offset < count) {
Sequence sequence = sequenceDAO.getSequence(offset++);
if (sequence == null || sequence.getEntry() == null)
continue;
long id = sequence.getEntry().getId();
String sequenceString = "";
String temp = sequence.getSequence();
// int sequenceLength = 0;
if (temp != null) {
SymbolList symL;
try {
symL = DNATools.createDNA(sequence.getSequence().trim());
} catch (IllegalSymbolException e1) {
// maybe it's rna?
try {
symL = RNATools.createRNA(sequence.getSequence().trim());
} catch (IllegalSymbolException e2) {
// skip this sequence
Logger.debug("Invalid characters in sequence for " + sequence.getEntry().getId() + ". Skipped for indexing");
Logger.debug(e2.toString());
continue;
}
}
// sequenceLength = symL.seqString().length();
sequenceString = SequenceUtils.breakUpLines(symL.seqString() + symL.seqString());
}
if (sequenceString.length() > 0) {
try {
String idString = ">" + id;
idString += DELIMITER + sequence.getEntry().getRecordType();
String name = sequence.getEntry().getName() == null ? "None" : sequence.getEntry().getName();
idString += DELIMITER + name;
String pNumber = sequence.getEntry().getPartNumber();
idString += DELIMITER + pNumber;
idString += "\n";
writer.write(idString);
writer.write(sequenceString + "\n");
} catch (IOException e) {
throw new BlastException(e);
}
}
}
}
Aggregations