use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.
the class TraceSequences method parseTraceSequence.
private boolean parseTraceSequence(String fileName, byte[] bytes) {
DNASequence dnaSequence = null;
// First try parsing as ABI
ABIParser abiParser = new ABIParser();
try {
dnaSequence = abiParser.parse(bytes);
} catch (InvalidFormatParserException e) {
//
}
if (dnaSequence == null) {
// try parsing as fasta, genbank, etc
dnaSequence = GeneralParser.getInstance().parse(bytes);
if (dnaSequence == null || dnaSequence.getSequence() == null) {
String errMsg = ("Could not parse \"" + fileName + "\". Only Fasta, GenBank & ABI files are supported.");
Logger.error(errMsg);
return false;
}
}
TraceSequence traceSequence = importTraceSequence(fileName, dnaSequence.getSequence().toLowerCase(), new ByteArrayInputStream(bytes));
if (traceSequence == null)
return false;
Sequence sequence = DAOFactory.getSequenceDAO().getByEntry(entry);
if (sequence == null)
return true;
buildOrRebuildAlignment(traceSequence, sequence);
return true;
}
use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.
the class GenBankParserTest method testParse.
@Test
public void testParse() throws Exception {
GenBankParser parser = new GenBankParser();
DNASequence sequence = parser.parse(genbank);
Assert.assertNotNull(sequence);
FeaturedDNASequence featuredDNASequence = (FeaturedDNASequence) sequence;
Assert.assertEquals(3, featuredDNASequence.getFeatures().size());
Assert.assertEquals(936, featuredDNASequence.getSequence().length());
// parse genbank 2
FeaturedDNASequence sequence2 = (FeaturedDNASequence) parser.parse(getGenbank2);
Assert.assertNotNull(sequence2);
Assert.assertEquals(3, sequence2.getFeatures().size());
}
Aggregations