Search in sources :

Example 11 with FeaturedDNASequence

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

the class SequenceDAOTest method testHasSequence.

@Test
public void testHasSequence() throws Exception {
    Account account1 = AccountCreator.createTestAccount("SequenceDAOTest.testHasSequence1", false);
    Account account2 = AccountCreator.createTestAccount("SequenceDAOTest.testHasSequence2", false);
    Account account3 = AccountCreator.createTestAccount("SequenceDAOTest.testHasSequence3", false);
    Plasmid plasmid1 = TestEntryCreator.createTestPlasmid(account1);
    Plasmid plasmid2 = TestEntryCreator.createTestPlasmid(account2);
    Plasmid plasmid3 = TestEntryCreator.createTestPlasmid(account3);
    // create sequence for plasmid1
    FeaturedDNASequence dnaSequence = GeneralParser.parse(sequenceString);
    Sequence sequence = SequenceUtil.dnaSequenceToSequence(dnaSequence);
    Assert.assertNotNull(sequence);
    sequence.setEntry(plasmid1);
    sequence = sequenceDAO.create(sequence);
    Assert.assertNotNull(sequence);
    // create sequence for plasmid3
    dnaSequence = GeneralParser.parse(sequenceString + "atc");
    sequence = SequenceUtil.dnaSequenceToSequence(dnaSequence);
    Assert.assertNotNull(sequence);
    sequence.setEntry(plasmid3);
    sequence = sequenceDAO.create(sequence);
    Assert.assertNotNull(sequence);
    // test
    Assert.assertTrue(sequenceDAO.hasSequence(plasmid1.getId()));
    Assert.assertFalse(sequenceDAO.hasSequence(plasmid2.getId()));
    Assert.assertTrue(sequenceDAO.hasSequence(plasmid3.getId()));
}
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 12 with FeaturedDNASequence

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

the class SequenceDAOTest method testHasOriginalSequence.

@Test
public void testHasOriginalSequence() throws Exception {
    Account account = AccountCreator.createTestAccount("SequenceDAOTest.testHasOriginalSequence", 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.setSequenceUser(sequenceString);
    sequence.setEntry(plasmid);
    sequence = sequenceDAO.create(sequence);
    Assert.assertNotNull(sequence);
    // test
    Assert.assertTrue(sequenceDAO.hasOriginalSequence(plasmid.getId()));
    // test with another sequence
    Plasmid plasmid2 = TestEntryCreator.createTestPlasmid(account);
    dnaSequence = GeneralParser.parse(sequenceString + "atc");
    sequence = SequenceUtil.dnaSequenceToSequence(dnaSequence);
    Assert.assertNotNull(sequence);
    sequence.setEntry(plasmid2);
    sequence = sequenceDAO.create(sequence);
    Assert.assertNotNull(sequence);
    Assert.assertFalse(sequenceDAO.hasOriginalSequence(plasmid2.getId()));
}
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 13 with FeaturedDNASequence

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

the class SequenceDAOTest method testGetSequenceFilename.

@Test
public void testGetSequenceFilename() throws Exception {
    Account account = AccountCreator.createTestAccount("SequenceDAOTest.testGetSequenceFilename", 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.setFileName("testFile.gb");
    sequence.setEntry(plasmid);
    sequence = sequenceDAO.create(sequence);
    Assert.assertNotNull(sequence);
    String filename = sequenceDAO.getSequenceFilename(plasmid);
    Assert.assertEquals("testFile.gb", filename);
}
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 14 with FeaturedDNASequence

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

the class SequenceDAOTest method testRetrieve.

@Test
public void testRetrieve() throws Exception {
    Account account = AccountCreator.createTestAccount("SequenceDAOTest.testRetrieve", 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.get(sequence.getId());
    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)

Example 15 with FeaturedDNASequence

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

the class SequenceDAOTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    Account account = AccountCreator.createTestAccount("SequenceDAOTest.testUpdate", 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.get(sequence.getId());
    Assert.assertNotNull(result);
    Assert.assertEquals(result, sequence);
    // update
    String newSequence = "gatgatgtggtttctacaggatctgacattattattgttggaagaggactattt";
    sequence.setSequence(newSequence);
    sequence = sequenceDAO.update(sequence);
    Assert.assertNotNull(sequence);
    // get
    result = sequenceDAO.get(sequence.getId());
    Assert.assertNotNull(result);
    Assert.assertEquals(result, sequence);
    Assert.assertEquals(newSequence, result.getSequence());
    Assert.assertEquals(newSequence, sequence.getSequence());
}
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