use of org.jbei.ice.lib.dto.FeaturedDNASequence in project ice by JBEI.
the class SequenceDAOTest method testGetSequence.
@Test
public void testGetSequence() throws Exception {
Account account = AccountCreator.createTestAccount("SequenceDAOTest.testGetSequence", 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);
Assert.assertNotNull(sequenceDAO.getSequence(0));
}
use of org.jbei.ice.lib.dto.FeaturedDNASequence in project ice by JBEI.
the class SequenceDAOTest method testDelete.
@Test
public void testDelete() throws Exception {
Account account = AccountCreator.createTestAccount("SequenceDAOTest.testDelete", 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);
// delete
sequenceDAO.delete(result);
// get
Assert.assertNull(sequenceDAO.get(sequence.getId()));
Assert.assertNull(sequenceDAO.getByEntry(strain));
}
use of org.jbei.ice.lib.dto.FeaturedDNASequence in project ice by JBEI.
the class GeneralParserTest method parse.
@Test
public void parse() {
FeaturedDNASequence sequence = GeneralParser.parse(TestInputSequences.fromAPE);
Assert.assertNotNull(sequence);
Assert.assertEquals(sequence.getFeatures().size(), 25);
Assert.assertTrue(hasCorrectNotes(sequence, "promoter", "AOX1 promoter", 8));
Assert.assertTrue(hasCorrectNotes(sequence, "CDS", "alpha-factor secretion signal", 10));
// Assert.assertTrue(hasCorrectNotes(sequence, "misc_feature", "jgi_PenbrAgRF18_1_353857_MatureChain_29_961", 0));
Assert.assertTrue(hasCorrectNotes(sequence, "source", "source:synthetic DNA construct", 9));
}
use of org.jbei.ice.lib.dto.FeaturedDNASequence in project ice by JBEI.
the class GenBankParserTest method testParse.
@Test
public void testParse() throws Exception {
GenBankParser parser = new GenBankParser();
FeaturedDNASequence sequence = parser.parse(IOUtils.lineIterator(new ByteArrayInputStream(genbank.getBytes()), Charset.defaultCharset()));
Assert.assertNotNull(sequence);
Assert.assertEquals(3, sequence.getFeatures().size());
Assert.assertEquals(936, sequence.getSequence().length());
// parse genbank 2
FeaturedDNASequence sequence2 = parser.parse(IOUtils.lineIterator(new ByteArrayInputStream(getGenbank2.getBytes()), Charset.defaultCharset()));
Assert.assertNotNull(sequence2);
Assert.assertEquals(3, sequence2.getFeatures().size());
}
use of org.jbei.ice.lib.dto.FeaturedDNASequence in project ice by JBEI.
the class FastaParser method parse.
@Override
public FeaturedDNASequence parse(Iterator<String> iterator, String... entryType) throws InvalidFormatParserException {
try {
String textSequence = getSequence(iterator);
textSequence = cleanSequence(textSequence);
textSequence = textSequence.replaceAll("\t", "\n");
try (BufferedReader br = new BufferedReader(new StringReader(textSequence))) {
FeaturedDNASequence sequence;
RichSequenceIterator richSequences;
if (entryType.length > 0 && entryType[0].equals("protein")) {
richSequences = IOTools.readFastaProtein(br, null);
} else {
richSequences = IOTools.readFastaDNA(br, null);
}
if (richSequences.hasNext()) {
RichSequence richSequence = richSequences.nextRichSequence();
sequence = new FeaturedDNASequence(richSequence.seqString(), new LinkedList<>());
} else {
throw new InvalidFormatParserException("No sequence found in sequence file!");
}
return sequence;
}
} catch (BioException | IOException e) {
throw new InvalidFormatParserException("Couldn't parse FASTA sequence!", e);
}
}
Aggregations