Search in sources :

Example 36 with FeaturedDNASequence

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

the class PartSequenceTest method testRandomSequence.

@Test
public void testRandomSequence() throws Exception {
    Account account = AccountCreator.createTestAccount("PartSequenceTest.testRandomSequence", false);
    // generate a random sequence of length 50k bps with 600 features
    RandomSequence randomSequence = new RandomSequence(50000);
    FeaturedDNASequence sequence = randomSequence.generate(600);
    // create part for sequence
    PartSequence partSequence = new PartSequence(account.getEmail(), EntryType.PLASMID);
    partSequence.save(sequence);
    // retrieve sequence with default of 20 annotations
    FeaturedDNASequence retrieved = partSequence.get(false);
    Assert.assertNotNull(retrieved);
}
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 37 with FeaturedDNASequence

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

the class PartSequenceTest method testGet.

@Test
public void testGet() throws Exception {
    Account account = AccountCreator.createTestAccount("PartSequenceTest.testGet", false);
    Strain strain = TestEntryCreator.createTestStrain(account);
    PartSequence partSequence = new PartSequence(account.getEmail(), strain.getRecordId());
    FeaturedDNASequence sequence = partSequence.get(true);
    Assert.assertNull(sequence);
    ByteArrayInputStream inputStream = new ByteArrayInputStream(genbank.getBytes());
    SequenceInfo sequenceInfo = partSequence.parseSequenceFile(inputStream, "testFile.gb", false);
    Assert.assertNotNull(sequenceInfo);
    FeaturedDNASequence featuredDNASequence = (FeaturedDNASequence) sequenceInfo.getSequence();
    Assert.assertNotNull(featuredDNASequence);
    Assert.assertEquals(1, featuredDNASequence.getFeatures().size());
    sequence = partSequence.get(true);
    Assert.assertNotNull(sequence);
    Assert.assertEquals(234, sequence.getSequence().length());
    Assert.assertEquals(1, sequence.getFeatures().size());
}
Also used : Account(org.jbei.ice.storage.model.Account) ByteArrayInputStream(java.io.ByteArrayInputStream) SequenceInfo(org.jbei.ice.lib.dto.entry.SequenceInfo) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test) HibernateRepositoryTest(org.jbei.ice.storage.hibernate.HibernateRepositoryTest)

Example 38 with FeaturedDNASequence

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

the class FeaturesSectionTest method processFeatures3.

@Test
public void processFeatures3() {
    FeaturedDNASequence sequence = new FeaturedDNASequence();
    FeaturesSection tag = new FeaturesSection(sequence);
    String[] lines = features3.split("\n");
    for (String line : lines) tag.process(line);
    Assert.assertNotNull(sequence);
    Assert.assertEquals(4, sequence.getFeatures().size());
    // exon
    DNAFeature feature = sequence.getFeatures().get(0);
    Assert.assertEquals(2, feature.getNotes().size());
    // intron
    feature = sequence.getFeatures().get(1);
    Assert.assertEquals(2, feature.getNotes().size());
    // mRNA
    feature = sequence.getFeatures().get(2);
    Assert.assertEquals(1, feature.getNotes().size());
    // CDS
    feature = sequence.getFeatures().get(3);
    Assert.assertEquals(5, feature.getNotes().size());
}
Also used : DNAFeature(org.jbei.ice.lib.dto.DNAFeature) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Test(org.junit.Test)

Example 39 with FeaturedDNASequence

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

the class SequenceDAOTest method testSequenceString.

@Test
public void testSequenceString() throws Exception {
    Account account = AccountCreator.createTestAccount("SequenceDAOTest.testSequenceString", false);
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    Assert.assertNotNull(plasmid);
    // parse sequence and associate with plasmid
    FeaturedDNASequence dnaSequence = GeneralParser.parse(sequenceString);
    Sequence sequence = SequenceUtil.dnaSequenceToSequence(dnaSequence);
    Assert.assertNotNull(sequence);
    sequence.setEntry(plasmid);
    sequence = sequenceDAO.create(sequence);
    Assert.assertNotNull(sequence);
    // get
    Optional<String> result = sequenceDAO.getSequenceString(plasmid);
    Assert.assertTrue(result.isPresent());
    Assert.assertEquals(result.get(), dnaSequence.getSequence());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) Sequence(org.jbei.ice.storage.model.Sequence) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Test(org.junit.Test) HibernateRepositoryTest(org.jbei.ice.storage.hibernate.HibernateRepositoryTest)

Example 40 with FeaturedDNASequence

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

the class SequenceDAOTest method testCreate.

@Test
public void testCreate() throws Exception {
    Account account = AccountCreator.createTestAccount("SequenceDAOTest.testCreate", false);
    Strain strain = TestEntryCreator.createTestStrain(account);
    Assert.assertNotNull(strain);
    // parse sequence and associate with strain
    FeaturedDNASequence dnaSequence = GeneralParser.parse(sequenceString);
    Sequence sequence = SequenceUtil.dnaSequenceToSequence(dnaSequence);
    Assert.assertNotNull(sequence);
    sequence.setEntry(strain);
    sequence = sequenceDAO.create(sequence);
    Assert.assertNotNull(sequence);
    // get
    Sequence result = sequenceDAO.getByEntry(strain);
    Assert.assertNotNull(result);
    Assert.assertEquals(result, sequence);
}
Also used : Account(org.jbei.ice.storage.model.Account) Sequence(org.jbei.ice.storage.model.Sequence) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) Strain(org.jbei.ice.storage.model.Strain) 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