Search in sources :

Example 11 with DNASequence

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;
}
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)

Example 12 with DNASequence

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());
}
Also used : DNASequence(org.jbei.ice.lib.dto.DNASequence) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Test(org.junit.Test)

Aggregations

DNASequence (org.jbei.ice.lib.dto.DNASequence)12 Test (org.junit.Test)6 Sequence (org.jbei.ice.storage.model.Sequence)3 IOException (java.io.IOException)2 SymbolList (org.biojava.bio.symbol.SymbolList)2 SequenceInfo (org.jbei.ice.lib.dto.entry.SequenceInfo)2 InvalidFormatParserException (org.jbei.ice.lib.parsers.InvalidFormatParserException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 BioException (org.biojava.bio.BioException)1 SimpleSymbolList (org.biojava.bio.symbol.SimpleSymbolList)1 Curation (org.jbei.ice.lib.dto.Curation)1 DNAFeature (org.jbei.ice.lib.dto.DNAFeature)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1 SequenceController (org.jbei.ice.lib.entry.sequence.SequenceController)1 ABIParser (org.jbei.ice.lib.parsers.ABIParser)1 ABITrace (org.jbei.ice.lib.parsers.abi.ABITrace)1 GenBankParser (org.jbei.ice.lib.parsers.genbank.GenBankParser)1