Package org.biojava.ontology.obo
Class OboFileParser
- java.lang.Object
-
- org.biojava.ontology.obo.OboFileParser
-
public class OboFileParser extends Object
A class to parse the content of an OBO file. It delegates handling of the content to the OBOFileEventListener implementation. This file contains parts of the OBO-Edit file OBOParseEngine, (particularly the encoding and decoding part) http://geneontology.cvs.sourceforge.net/geneontology/go-dev/java/oboedit/sources/org/geneontology/oboedit/dataadapter/OBOParseEngine.java?revision=1.10&view=markup Thanks to the OboEdit developers for giving permission to release this in BioJava.- Since:
- 1.6
- Author:
- Andreas Prlic, John Day Richter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOboFileParser.SOPair
-
Field Summary
Fields Modifier and Type Field Description protected intbytesReadprotected SimpleDateFormatdateFormatprotected static Map<Character,Character>escapeCharsprotected Stringlineprotected intlinenumprotected StringBuffertempBufferprotected inttotalSizeprotected static Map<Character,Character>unescapeChars
-
Constructor Summary
Constructors Constructor Description OboFileParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOboFileEventListener(OboFileEventListener listener)static Stringescape(String str, boolean escapespaces)static intfindUnescaped(String str, char toChar)static intfindUnescaped(String str, char toChar, int startIndex, int endIndex)static intfindUnescaped(String str, char toChar, int startindex, int endindex, boolean honorQuotes)protected Map<String,Object>[]getDbxrefList(String line, int startoffset, int endoffset)protected intgetNestedValue(org.biojava.ontology.obo.NestedValue nv, String str, int startIndex)List<OboFileEventListener>getOboFileEventListener()protected StringBuffergetTempBuffer()static booleanisEscapeStarter(char c)static booleanisQuote(char c)voidparseOBO(BufferedReader oboFile)parse an ontology fileprotected Map<String,Object>parseXref(String line, int startoffset, int endoffset)protected OboFileParser.SOPairreadQuotedString(String value, int startIndex, int stopIndex, char terminatingChar, boolean requireQuotes, boolean legalEndOfLine)Stringunescape(String str)OboFileParser.SOPairunescape(String str, char toChar, int startindex, boolean mustFindChar)OboFileParser.SOPairunescape(String str, char toChar, int startindex, int endindex, boolean mustFindChar)
-
-
-
Field Detail
-
linenum
protected int linenum
-
totalSize
protected int totalSize
-
bytesRead
protected int bytesRead
-
tempBuffer
protected StringBuffer tempBuffer
-
dateFormat
protected SimpleDateFormat dateFormat
-
escapeChars
protected static final Map<Character,Character> escapeChars
-
unescapeChars
protected static final Map<Character,Character> unescapeChars
-
-
Constructor Detail
-
OboFileParser
public OboFileParser()
-
-
Method Detail
-
addOboFileEventListener
public void addOboFileEventListener(OboFileEventListener listener)
-
getOboFileEventListener
public List<OboFileEventListener> getOboFileEventListener()
-
parseOBO
public void parseOBO(BufferedReader oboFile) throws IOException, ParseException
parse an ontology file- Parameters:
oboFile-- Throws:
IOExceptionParseException
-
getDbxrefList
protected Map<String,Object>[] getDbxrefList(String line, int startoffset, int endoffset) throws ParseException
- Throws:
ParseException
-
parseXref
protected Map<String,Object> parseXref(String line, int startoffset, int endoffset) throws ParseException
- Throws:
ParseException
-
unescape
public String unescape(String str) throws ParseException
- Throws:
ParseException
-
unescape
public OboFileParser.SOPair unescape(String str, char toChar, int startindex, boolean mustFindChar) throws ParseException
- Throws:
ParseException
-
unescape
public OboFileParser.SOPair unescape(String str, char toChar, int startindex, int endindex, boolean mustFindChar) throws ParseException
- Throws:
ParseException
-
findUnescaped
public static int findUnescaped(String str, char toChar)
-
findUnescaped
public static int findUnescaped(String str, char toChar, int startIndex, int endIndex)
-
findUnescaped
public static int findUnescaped(String str, char toChar, int startindex, int endindex, boolean honorQuotes)
-
isEscapeStarter
public static boolean isEscapeStarter(char c)
-
isQuote
public static boolean isQuote(char c)
-
getTempBuffer
protected StringBuffer getTempBuffer()
-
readQuotedString
protected OboFileParser.SOPair readQuotedString(String value, int startIndex, int stopIndex, char terminatingChar, boolean requireQuotes, boolean legalEndOfLine) throws ParseException
- Throws:
ParseException
-
getNestedValue
protected int getNestedValue(org.biojava.ontology.obo.NestedValue nv, String str, int startIndex) throws ParseException
- Throws:
ParseException
-
-