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());
}
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());
}
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());
}
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));
}
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));
}
}
Aggregations