Search in sources :

Example 6 with DNASequence

use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.

the class AnnotationsTest method testCurate.

@Test
public void testCurate() throws Exception {
    Account account = AccountCreator.createTestAccount("AnnotationsTest.testCurate", true);
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    SequenceDAO sequenceDAO = new SequenceDAO();
    Assert.assertFalse(sequenceDAO.hasSequence(plasmid.getId()));
    DNASequence dnaSequence = GeneralParser.getInstance().parse(sequenceString);
    Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
    sequence.setEntry(plasmid);
    sequence = sequenceDAO.saveSequence(sequence);
    Assert.assertNotNull(sequence);
    SequenceFeatureDAO sequenceFeatureDAO = new SequenceFeatureDAO();
    List<SequenceFeature> sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
    Assert.assertEquals(1, sequenceFeatures.size());
    Feature feature = sequenceFeatures.get(0).getFeature();
    DNAFeature dnaFeature = feature.toDataTransferObject();
    Curation curation = new Curation();
    curation.setExclude(true);
    dnaFeature.setCuration(curation);
    List<DNAFeature> features = new ArrayList<>();
    features.add(dnaFeature);
    Annotations annotations = new Annotations(account.getEmail());
    annotations.curate(features);
    sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
    feature = sequenceFeatures.get(0).getFeature();
    Assert.assertTrue(feature.getCuration().isExclude());
}
Also used : Curation(org.jbei.ice.lib.dto.Curation) ArrayList(java.util.ArrayList) DNASequence(org.jbei.ice.lib.dto.DNASequence) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) SequenceFeatureDAO(org.jbei.ice.storage.hibernate.dao.SequenceFeatureDAO) DNASequence(org.jbei.ice.lib.dto.DNASequence) SequenceDAO(org.jbei.ice.storage.hibernate.dao.SequenceDAO) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) Test(org.junit.Test)

Example 7 with DNASequence

use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.

the class PlainParser method parse.

@Override
public DNASequence parse(String textSequence) throws InvalidFormatParserException {
    SymbolList sl;
    try {
        textSequence = cleanSequence(textSequence);
        sl = new SimpleSymbolList(DNATools.getDNA().getTokenization("token"), textSequence.replaceAll("\\s+", "").replaceAll("[\\.|~]", "-").replaceAll("[0-9]", ""));
    } catch (BioException e) {
        throw new InvalidFormatParserException("Couldn't parse Plain sequence!", e);
    }
    return new DNASequence(sl.seqString());
}
Also used : DNASequence(org.jbei.ice.lib.dto.DNASequence) BioException(org.biojava.bio.BioException) SimpleSymbolList(org.biojava.bio.symbol.SimpleSymbolList) SymbolList(org.biojava.bio.symbol.SymbolList) SimpleSymbolList(org.biojava.bio.symbol.SimpleSymbolList)

Example 8 with DNASequence

use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.

the class AbstractParser method save.

protected SequenceInfo save(DNASequence dnaSequence, String sequenceString) {
    Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
    sequence.setSequenceUser(sequenceString);
    sequence.setEntry(entry);
    if (!StringUtils.isBlank(fileName))
        sequence.setFileName(fileName);
    Sequence result = sequenceDAO.saveSequence(sequence);
    BlastPlus.scheduleBlastIndexRebuildTask(true);
    SequenceInfo info = result.toDataTransferObject();
    info.setSequence(dnaSequence);
    return info;
}
Also used : SequenceInfo(org.jbei.ice.lib.dto.entry.SequenceInfo) Sequence(org.jbei.ice.storage.model.Sequence) DNASequence(org.jbei.ice.lib.dto.DNASequence)

Example 9 with DNASequence

use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.

the class SequenceDAOTest method testUpdateSequence.

@Test
public void testUpdateSequence() throws Exception {
    // create account and sequence
    Account account = AccountCreator.createTestAccount("SequenceDAOTest.testUpdateSequence", false);
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    DNASequence dnaSequence = GeneralParser.getInstance().parse(sequenceString);
    Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
    sequence.setEntry(plasmid);
    sequence = sequenceDAO.saveSequence(sequence);
    Assert.assertNotNull(sequence);
    // update to add new sequence feature
    List<SequenceFeature> newFeatures = DAOFactory.getSequenceFeatureDAO().getEntrySequenceFeatures(plasmid);
    SequenceFeature sequenceFeature = new SequenceFeature();
    Feature feature = new Feature();
    feature.setSequence("atgtcgaaag");
    feature.setName("test");
    feature.setHash("hash");
    sequenceFeature.setFeature(feature);
    AnnotationLocation location = new AnnotationLocation();
    location.setGenbankStart(1);
    location.setEnd(feature.getSequence().length());
    sequenceFeature.getAnnotationLocations().clear();
    sequenceFeature.getAnnotationLocations().add(location);
    newFeatures.add(sequenceFeature);
    sequence = sequenceDAO.updateSequence(sequence, new HashSet<>(newFeatures));
    Assert.assertNotNull(sequence);
    newFeatures = DAOFactory.getSequenceFeatureDAO().getEntrySequenceFeatures(plasmid);
    Assert.assertEquals(2, newFeatures.size());
    Assert.assertNotEquals(newFeatures.get(0).getFeature(), newFeatures.get(1).getFeature());
}
Also used : DNASequence(org.jbei.ice.lib.dto.DNASequence) DNASequence(org.jbei.ice.lib.dto.DNASequence) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with DNASequence

use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.

the class SequenceDAOTest method testSaveSequence.

@Test
public void testSaveSequence() throws Exception {
    Account account = AccountCreator.createTestAccount("SequenceDAOTest.testSaveSequence", false);
    Strain strain = TestEntryCreator.createTestStrain(account);
    // parse sequence and associate with strain
    DNASequence dnaSequence = GeneralParser.getInstance().parse(sequenceString);
    Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
    sequence.setEntry(strain);
    Assert.assertNotNull(sequenceDAO.saveSequence(sequence));
    // create second strain and associate with same sequence
    Strain strain2 = TestEntryCreator.createTestStrain(account);
    dnaSequence = GeneralParser.getInstance().parse(sequenceString);
    sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
    sequence.setEntry(strain2);
    Assert.assertNotNull(sequenceDAO.saveSequence(sequence));
    // same sequence so same number of features
    List<SequenceFeature> sequence1Feature = DAOFactory.getSequenceFeatureDAO().getEntrySequenceFeatures(strain);
    List<SequenceFeature> sequence2Feature = DAOFactory.getSequenceFeatureDAO().getEntrySequenceFeatures(strain2);
    Assert.assertEquals(sequence1Feature.size(), sequence2Feature.size());
    // same feature
    Assert.assertEquals(sequence1Feature.get(0).getFeature(), sequence2Feature.get(0).getFeature());
}
Also used : DNASequence(org.jbei.ice.lib.dto.DNASequence) DNASequence(org.jbei.ice.lib.dto.DNASequence) 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