use of org.jbei.ice.lib.parsers.AbstractParser in project ice by JBEI.
the class PartSequence method parseSequenceFile.
/**
* Parses a sequence in a file and associates it with the current entry
*
* @param inputStream input stream of bytes representing the file
* @param fileName name of file being parsed
* @return wrapper around the internal model used to represent sequence information
* @throws IOException on Exception parsing the contents of the file
*/
public SequenceInfo parseSequenceFile(InputStream inputStream, String fileName) throws IOException {
try {
AbstractParser parser;
String sequenceString = Utils.getString(inputStream);
switch(detectFormat(sequenceString)) {
case GENBANK:
parser = new GenBankParser();
break;
case SBOL2:
SBOLParser sbolParser = new SBOLParser(this.userId, Long.toString(this.entry.getId()));
return sbolParser.parseToEntry(sequenceString, fileName);
case FASTA:
parser = new FastaParser();
break;
default:
case PLAIN:
parser = new PlainParser();
break;
}
// parse actual sequence
DNASequence sequence = parser.parse(sequenceString);
return save(sequence, sequenceString, fileName);
} catch (InvalidFormatParserException e) {
Logger.error(e);
throw new IOException(e);
}
}
Aggregations