Search in sources :

Example 1 with ABIParser

use of org.jbei.ice.lib.parsers.ABIParser 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;
}
Also used : DNASequence(org.jbei.ice.lib.dto.DNASequence) ABIParser(org.jbei.ice.lib.parsers.ABIParser) InvalidFormatParserException(org.jbei.ice.lib.parsers.InvalidFormatParserException) DNASequence(org.jbei.ice.lib.dto.DNASequence)

Aggregations

DNASequence (org.jbei.ice.lib.dto.DNASequence)1 ABIParser (org.jbei.ice.lib.parsers.ABIParser)1 InvalidFormatParserException (org.jbei.ice.lib.parsers.InvalidFormatParserException)1