use of org.jbei.ice.lib.dto.DNASequence 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);
SequenceDAO sequenceDAO = new SequenceDAO();
Assert.assertFalse(sequenceDAO.hasSequence(plasmid.getId()));
DNASequence dnaSequence = GeneralParser.getInstance().parse(sequenceString);
Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
sequence.setEntry(plasmid);
sequence = sequenceDAO.saveSequence(sequence);
Assert.assertNotNull(sequence);
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.DNASequence in project ice by JBEI.
the class PlainParser method parse.
@Override
public DNASequence parse(String textSequence) throws InvalidFormatParserException {
SymbolList sl;
try {
textSequence = cleanSequence(textSequence);
sl = new SimpleSymbolList(DNATools.getDNA().getTokenization("token"), textSequence.replaceAll("\\s+", "").replaceAll("[\\.|~]", "-").replaceAll("[0-9]", ""));
} catch (BioException e) {
throw new InvalidFormatParserException("Couldn't parse Plain sequence!", e);
}
return new DNASequence(sl.seqString());
}
use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.
the class AbstractParser method save.
protected SequenceInfo save(DNASequence dnaSequence, String sequenceString) {
Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
sequence.setSequenceUser(sequenceString);
sequence.setEntry(entry);
if (!StringUtils.isBlank(fileName))
sequence.setFileName(fileName);
Sequence result = sequenceDAO.saveSequence(sequence);
BlastPlus.scheduleBlastIndexRebuildTask(true);
SequenceInfo info = result.toDataTransferObject();
info.setSequence(dnaSequence);
return info;
}
use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.
the class SequenceDAOTest method testUpdateSequence.
@Test
public void testUpdateSequence() throws Exception {
// create account and sequence
Account account = AccountCreator.createTestAccount("SequenceDAOTest.testUpdateSequence", false);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
DNASequence dnaSequence = GeneralParser.getInstance().parse(sequenceString);
Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
sequence.setEntry(plasmid);
sequence = sequenceDAO.saveSequence(sequence);
Assert.assertNotNull(sequence);
// update to add new sequence feature
List<SequenceFeature> newFeatures = DAOFactory.getSequenceFeatureDAO().getEntrySequenceFeatures(plasmid);
SequenceFeature sequenceFeature = new SequenceFeature();
Feature feature = new Feature();
feature.setSequence("atgtcgaaag");
feature.setName("test");
feature.setHash("hash");
sequenceFeature.setFeature(feature);
AnnotationLocation location = new AnnotationLocation();
location.setGenbankStart(1);
location.setEnd(feature.getSequence().length());
sequenceFeature.getAnnotationLocations().clear();
sequenceFeature.getAnnotationLocations().add(location);
newFeatures.add(sequenceFeature);
sequence = sequenceDAO.updateSequence(sequence, new HashSet<>(newFeatures));
Assert.assertNotNull(sequence);
newFeatures = DAOFactory.getSequenceFeatureDAO().getEntrySequenceFeatures(plasmid);
Assert.assertEquals(2, newFeatures.size());
Assert.assertNotEquals(newFeatures.get(0).getFeature(), newFeatures.get(1).getFeature());
}
use of org.jbei.ice.lib.dto.DNASequence in project ice by JBEI.
the class SequenceDAOTest method testSaveSequence.
@Test
public void testSaveSequence() throws Exception {
Account account = AccountCreator.createTestAccount("SequenceDAOTest.testSaveSequence", false);
Strain strain = TestEntryCreator.createTestStrain(account);
// parse sequence and associate with strain
DNASequence dnaSequence = GeneralParser.getInstance().parse(sequenceString);
Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
sequence.setEntry(strain);
Assert.assertNotNull(sequenceDAO.saveSequence(sequence));
// create second strain and associate with same sequence
Strain strain2 = TestEntryCreator.createTestStrain(account);
dnaSequence = GeneralParser.getInstance().parse(sequenceString);
sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
sequence.setEntry(strain2);
Assert.assertNotNull(sequenceDAO.saveSequence(sequence));
// same sequence so same number of features
List<SequenceFeature> sequence1Feature = DAOFactory.getSequenceFeatureDAO().getEntrySequenceFeatures(strain);
List<SequenceFeature> sequence2Feature = DAOFactory.getSequenceFeatureDAO().getEntrySequenceFeatures(strain2);
Assert.assertEquals(sequence1Feature.size(), sequence2Feature.size());
// same feature
Assert.assertEquals(sequence1Feature.get(0).getFeature(), sequence2Feature.get(0).getFeature());
}
Aggregations