use of org.biojava.bio.BioException in project ice by JBEI.
the class FastaParser method parse.
@Override
public FeaturedDNASequence parse(String textSequence) throws InvalidFormatParserException {
try {
textSequence = cleanSequence(textSequence);
try (BufferedReader br = new BufferedReader(new StringReader(textSequence))) {
FeaturedDNASequence sequence;
RichSequenceIterator 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);
}
}
use of org.biojava.bio.BioException 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());
}
Aggregations