Search in sources :

Example 6 with FeaturedDNASequence

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

the class FeaturesSectionTest method processFeatures2.

@Test
public void processFeatures2() {
    FeaturedDNASequence sequence = new FeaturedDNASequence();
    FeaturesSection tag = new FeaturesSection(sequence);
    String[] lines = features2.split("\n");
    for (String line : lines) tag.process(line);
    Assert.assertNotNull(sequence);
    Assert.assertEquals(3, sequence.getFeatures().size());
    // source
    DNAFeature feature = sequence.getFeatures().get(0);
    Assert.assertEquals(8, feature.getNotes().size());
    // gene
    feature = sequence.getFeatures().get(1);
    Assert.assertEquals(1, feature.getNotes().size());
    // cds
    feature = sequence.getFeatures().get(2);
    Assert.assertEquals(7, feature.getNotes().size());
}
Also used : DNAFeature(org.jbei.ice.lib.dto.DNAFeature) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Test(org.junit.Test)

Example 7 with FeaturedDNASequence

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

the class FeaturesSectionTest method processFeatures.

@Test
public void processFeatures() {
    FeaturedDNASequence sequence = new FeaturedDNASequence();
    FeaturesSection tag = new FeaturesSection(sequence);
    String[] lines = features.split("\n");
    for (String line : lines) tag.process(line);
    Assert.assertNotNull(sequence);
    Assert.assertEquals(3, sequence.getFeatures().size());
}
Also used : FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Test(org.junit.Test)

Example 8 with FeaturedDNASequence

use of org.jbei.ice.lib.dto.FeaturedDNASequence 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);
    Assert.assertNotNull(plasmid);
    SequenceDAO sequenceDAO = new SequenceDAO();
    Assert.assertFalse(sequenceDAO.hasSequence(plasmid.getId()));
    FeaturedDNASequence dnaSequence = GeneralParser.parse(sequenceString);
    PartSequence partSequence = new PartSequence(account.getEmail(), plasmid.getRecordId());
    partSequence.save(dnaSequence);
    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 : Account(org.jbei.ice.storage.model.Account) Curation(org.jbei.ice.lib.dto.Curation) ArrayList(java.util.ArrayList) SequenceFeature(org.jbei.ice.storage.model.SequenceFeature) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Feature(org.jbei.ice.storage.model.Feature) SequenceFeature(org.jbei.ice.storage.model.SequenceFeature) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) Plasmid(org.jbei.ice.storage.model.Plasmid) SequenceFeatureDAO(org.jbei.ice.storage.hibernate.dao.SequenceFeatureDAO) PartSequence(org.jbei.ice.lib.entry.sequence.PartSequence) SequenceDAO(org.jbei.ice.storage.hibernate.dao.SequenceDAO) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) Test(org.junit.Test)

Example 9 with FeaturedDNASequence

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

the class PartSequenceTest method testDelete.

@Test
public void testDelete() throws Exception {
    Account account = AccountCreator.createTestAccount("PartSequenceTest.testDelete", false);
    PartSequence partSequence = new PartSequence(account.getEmail(), EntryType.PLASMID);
    FeaturedDNASequence sequence = GeneralParser.parse(genbank);
    Assert.assertNotNull(sequence);
    partSequence.save(sequence);
    Assert.assertNotNull(partSequence.get(true));
    partSequence.delete();
    Assert.assertNull(partSequence.get(true));
}
Also used : Account(org.jbei.ice.storage.model.Account) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Test(org.junit.Test) HibernateRepositoryTest(org.jbei.ice.storage.hibernate.HibernateRepositoryTest)

Example 10 with FeaturedDNASequence

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

the class PartSequenceTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    Account account = AccountCreator.createTestAccount("PartSequenceTest.testUpdate", false);
    PartSequence partSequence = new PartSequence(account.getEmail(), EntryType.PART);
    Assert.assertNotNull(partSequence);
    // parse sequence
    ByteArrayInputStream inputStream = new ByteArrayInputStream(genbank.getBytes());
    SequenceInfo sequenceInfo = partSequence.parseSequenceFile(inputStream, "testFile2.gb", false);
    Assert.assertNotNull(sequenceInfo);
    // remove all existing features and add new feature
    FeaturedDNASequence dnaSequence = partSequence.get(true);
    dnaSequence.getFeatures().clear();
    // todo : what happens when location is specified but no sequence (or they differ?)
    DNAFeature feature = new DNAFeature();
    feature.setName("test");
    feature.setType("misc_feature");
    feature.getLocations().add(new DNAFeatureLocation(61, 89));
    dnaSequence.getFeatures().add(feature);
    partSequence.update(dnaSequence, false);
    // check for correct update
    List<DNAFeature> currentFeatures = partSequence.get(true).getFeatures();
    Assert.assertEquals(1, currentFeatures.size());
    Assert.assertEquals(sequenceInfo.getSequence().getSequence(), dnaSequence.getSequence());
    compareFeatures(feature, currentFeatures.get(0));
    // change feature location
    feature.getLocations().clear();
    feature.getLocations().add(new DNAFeatureLocation(20, 40));
    dnaSequence.getFeatures().clear();
    dnaSequence.getFeatures().add(feature);
    partSequence.update(dnaSequence, false);
    // check for correct update
    currentFeatures = partSequence.get(true).getFeatures();
    Assert.assertEquals(1, currentFeatures.size());
    Assert.assertEquals(sequenceInfo.getSequence().getSequence(), dnaSequence.getSequence());
    compareFeatures(feature, currentFeatures.get(0));
    // add a second feature
    DNAFeature secondFeature = new DNAFeature();
    secondFeature.setName("test2");
    secondFeature.setType("promoter");
    secondFeature.getLocations().add(new DNAFeatureLocation(0, 10));
    dnaSequence.getFeatures().add(secondFeature);
    partSequence.update(dnaSequence, false);
    // check
    FeaturedDNASequence featuredDNASequence = partSequence.get(true);
    Assert.assertNotNull(featuredDNASequence);
    currentFeatures = featuredDNASequence.getFeatures();
    Assert.assertEquals(2, currentFeatures.size());
    if (!"test".equalsIgnoreCase(currentFeatures.get(0).getName())) {
        compareFeatures(feature, currentFeatures.get(1));
        compareFeatures(secondFeature, currentFeatures.get(0));
    } else {
        compareFeatures(feature, currentFeatures.get(0));
        compareFeatures(secondFeature, currentFeatures.get(1));
    }
}
Also used : Account(org.jbei.ice.storage.model.Account) ByteArrayInputStream(java.io.ByteArrayInputStream) SequenceInfo(org.jbei.ice.lib.dto.entry.SequenceInfo) DNAFeatureLocation(org.jbei.ice.lib.dto.DNAFeatureLocation) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Test(org.junit.Test) HibernateRepositoryTest(org.jbei.ice.storage.hibernate.HibernateRepositoryTest)

Aggregations

FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)47 Test (org.junit.Test)23 HibernateRepositoryTest (org.jbei.ice.storage.hibernate.HibernateRepositoryTest)17 Account (org.jbei.ice.storage.model.Account)17 Sequence (org.jbei.ice.storage.model.Sequence)14 DNAFeature (org.jbei.ice.lib.dto.DNAFeature)8 Plasmid (org.jbei.ice.storage.model.Plasmid)8 IOException (java.io.IOException)5 SequenceInfo (org.jbei.ice.lib.dto.entry.SequenceInfo)5 Strain (org.jbei.ice.storage.model.Strain)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InvalidFormatParserException (org.jbei.ice.lib.parsers.InvalidFormatParserException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ArrayList (java.util.ArrayList)3 BioException (org.biojava.bio.BioException)3 PartData (org.jbei.ice.lib.dto.entry.PartData)3 BufferedReader (java.io.BufferedReader)2 StringReader (java.io.StringReader)2 Date (java.util.Date)2 LinkedList (java.util.LinkedList)2