Search in sources :

Example 1 with Plasmid

use of org.jbei.ice.storage.model.Plasmid 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 2 with Plasmid

use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.

the class TransferredPartsTest method testReceiveTransferredEntry.

@Test
public void testReceiveTransferredEntry() throws Exception {
    Account account = AccountCreator.createTestAccount("testReceivedTransferredEntry", false);
    Strain strain = createStrainObject(account);
    Plasmid plasmid = createPlasmidObject(account);
    // link the two
    PartData strainData = strain.toDataTransferObject();
    PartData plasmidData = plasmid.toDataTransferObject();
    strainData.getLinkedParts().add(plasmidData);
    strainData = parts.receiveTransferredEntry(strainData);
    Assert.assertNotNull(strainData);
    strain = (Strain) DAOFactory.getEntryDAO().get(strainData.getId());
    Assert.assertNotNull(strain);
    Assert.assertTrue(strain.getVisibility() == Visibility.TRANSFERRED.getValue());
    plasmid = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(0).getId());
    Assert.assertNotNull(plasmid);
    Assert.assertTrue(plasmid.getVisibility() == Visibility.TRANSFERRED.getValue());
    Assert.assertTrue(strain.getLinkedEntries().contains(plasmid));
    // create new plasmid
    Plasmid plasmid2 = createPlasmidObject(account);
    strainData.getLinkedParts().add(plasmid2.toDataTransferObject());
    Assert.assertEquals(2, strainData.getLinkedParts().size());
    // transfer strain (with 2 linked plasmids)
    PartData received = parts.receiveTransferredEntry(strainData);
    Assert.assertNotNull(received);
    // check return
    strain = (Strain) DAOFactory.getEntryDAO().get(strainData.getId());
    Assert.assertNotNull(strain);
    plasmid = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(0).getId());
    Assert.assertNotNull(plasmid);
    Assert.assertTrue(strain.getLinkedEntries().contains(plasmid));
    plasmid2 = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(1).getId());
    Assert.assertNotNull(plasmid2);
    Assert.assertTrue(strain.getLinkedEntries().contains(plasmid2));
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) PartData(org.jbei.ice.lib.dto.entry.PartData) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 3 with Plasmid

use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.

the class EntryLinksTest method testAddLink.

@Test
public void testAddLink() throws Exception {
    Account account = AccountCreator.createTestAccount("testAddLink", false);
    String userId = account.getEmail();
    Account differentAccount = AccountCreator.createTestAccount("testAddLink2", false);
    // create strain and plasmid
    Strain strain = TestEntryCreator.createTestStrain(account);
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(differentAccount);
    // give each account read permissions
    AccessPermission accessPermission = new AccessPermission(AccessPermission.Article.ACCOUNT, account.getId(), AccessPermission.Type.READ_ENTRY, plasmid.getId(), "");
    PermissionsController permissionsController = new PermissionsController();
    Assert.assertNotNull(permissionsController.addPermission(differentAccount.getEmail(), accessPermission));
    accessPermission = new AccessPermission(AccessPermission.Article.ACCOUNT, differentAccount.getId(), AccessPermission.Type.READ_ENTRY, strain.getId(), "");
    Assert.assertNotNull(permissionsController.addPermission(account.getEmail(), accessPermission));
    // add plasmid links to strain
    EntryLinks entryLinks = new EntryLinks(userId, Long.toString(strain.getId()));
    // attempt to add as a parent (expected to fail)
    Assert.assertFalse(entryLinks.addLink(plasmid.toDataTransferObject(), LinkType.PARENT));
    // now add as a child
    Assert.assertTrue(entryLinks.addLink(plasmid.toDataTransferObject(), LinkType.CHILD));
    // add second plasmid
    Plasmid plasmid2 = TestEntryCreator.createTestPlasmid(account);
    Assert.assertTrue(entryLinks.addLink(plasmid2.toDataTransferObject(), LinkType.CHILD));
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) AccessPermission(org.jbei.ice.lib.dto.access.AccessPermission) Strain(org.jbei.ice.storage.model.Strain) PermissionsController(org.jbei.ice.lib.access.PermissionsController) Test(org.junit.Test)

Example 4 with Plasmid

use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.

the class CustomFieldsTest method testGetPartsByFields.

@Test
public void testGetPartsByFields() throws Exception {
    // create part
    Account account = AccountCreator.createTestAccount("testGetPartsByFields", false);
    final String userId = account.getEmail();
    Strain strain = TestEntryCreator.createTestStrain(account);
    Assert.assertNotNull(strain);
    // create fields for strain
    long strainId = strain.getId();
    fields.createField(userId, strainId, new CustomField(strainId, "type", "promoter"));
    fields.createField(userId, strainId, new CustomField(strainId, "strength", "weak"));
    // search for strength:weak
    List<CustomField> searchFields = new ArrayList<>();
    searchFields.add(new CustomField("strength", "weak"));
    List<PartData> results = fields.getPartsByFields(userId, searchFields);
    Assert.assertEquals(1, results.size());
    // create additional entry
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    Assert.assertNotNull(plasmid);
    long plasmidId = plasmid.getId();
    fields.createField(userId, plasmidId, new CustomField(plasmidId, "type", "promoter"));
    fields.createField(userId, plasmidId, new CustomField(plasmidId, "strength", "strong"));
    searchFields.clear();
    searchFields.add(new CustomField("strength", "strong"));
    results = fields.getPartsByFields(userId, searchFields);
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(plasmid.getId(), results.get(0).getId());
    // search for type:promoter
    searchFields.clear();
    searchFields.add(new CustomField("type", "promoter"));
    results = fields.getPartsByFields(userId, searchFields);
    Assert.assertEquals(2, results.size());
    Assert.assertTrue(strain.getId() == results.get(0).getId() || results.get(1).getId() == strain.getId());
    // test two
    searchFields.clear();
    searchFields.add(new CustomField(strainId, "type", "promoter"));
    searchFields.add(new CustomField(strainId, "strength", "weak"));
    results = fields.getPartsByFields(userId, searchFields);
    Assert.assertNotNull(results);
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(strain.getId(), results.get(0).getId());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) ArrayList(java.util.ArrayList) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 5 with Plasmid

use of org.jbei.ice.storage.model.Plasmid in project ice by JBEI.

the class EntryHistoryTest method testDeleteAll.

@Test
public void testDeleteAll() throws Exception {
    Account account = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteAll", false);
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    Account reader = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteAllReader", false);
    EntryHistory entryHistory = new EntryHistory(reader.getEmail(), plasmid.getId());
    entryHistory.add();
    entryHistory = new EntryHistory(account.getEmail(), plasmid.getId());
    Results<History> history = entryHistory.get(20, 0, true, null);
    Assert.assertNotNull(history);
    Assert.assertEquals(1, entryHistory.deleteAll());
    history = entryHistory.get(20, 0, true, null);
    Assert.assertEquals(0, history.getResultCount());
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) Account(org.jbei.ice.storage.model.Account) History(org.jbei.ice.lib.dto.History) Test(org.junit.Test)

Aggregations

Plasmid (org.jbei.ice.storage.model.Plasmid)24 Account (org.jbei.ice.storage.model.Account)22 Test (org.junit.Test)22 HibernateRepositoryTest (org.jbei.ice.storage.hibernate.HibernateRepositoryTest)11 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)8 Sequence (org.jbei.ice.storage.model.Sequence)7 Strain (org.jbei.ice.storage.model.Strain)7 PartData (org.jbei.ice.lib.dto.entry.PartData)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 Random (java.util.Random)3 History (org.jbei.ice.lib.dto.History)3 Audit (org.jbei.ice.storage.model.Audit)3 PermissionsController (org.jbei.ice.lib.access.PermissionsController)1 Curation (org.jbei.ice.lib.dto.Curation)1 DNAFeature (org.jbei.ice.lib.dto.DNAFeature)1 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)1 PlasmidData (org.jbei.ice.lib.dto.entry.PlasmidData)1 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)1 Entries (org.jbei.ice.lib.entry.Entries)1