Package org.biojava.ontology.obo
Class OboFileParser
- java.lang.Object
-
- org.biojava.ontology.obo.OboFileParser
-
public class OboFileParser extends java.lang.ObjectA 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 java.text.SimpleDateFormatdateFormatprotected static java.util.Map<java.lang.Character,java.lang.Character>escapeCharsprotected java.lang.Stringlineprotected intlinenumprotected java.lang.StringBuffertempBufferprotected inttotalSizeprotected static java.util.Map<java.lang.Character,java.lang.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 java.lang.Stringescape(java.lang.String str, boolean escapespaces)static intfindUnescaped(java.lang.String str, char toChar)static intfindUnescaped(java.lang.String str, char toChar, int startIndex, int endIndex)static intfindUnescaped(java.lang.String str, char toChar, int startindex, int endindex, boolean honorQuotes)protected java.util.Map<java.lang.String,java.lang.Object>[]getDbxrefList(java.lang.String line, int startoffset, int endoffset)protected intgetNestedValue(org.biojava.ontology.obo.NestedValue nv, java.lang.String str, int startIndex)java.util.List<OboFileEventListener>getOboFileEventListener()protected java.lang.StringBuffergetTempBuffer()static booleanisEscapeStarter(char c)static booleanisQuote(char c)voidparseOBO(java.io.BufferedReader oboFile)parse an ontology fileprotected java.util.Map<java.lang.String,java.lang.Object>parseXref(java.lang.String line, int startoffset, int endoffset)protected OboFileParser.SOPairreadQuotedString(java.lang.String value, int startIndex, int stopIndex, char terminatingChar, boolean requireQuotes, boolean legalEndOfLine)java.lang.Stringunescape(java.lang.String str)OboFileParser.SOPairunescape(java.lang.String str, char toChar, int startindex, boolean mustFindChar)OboFileParser.SOPairunescape(java.lang.String str, char toChar, int startindex, int endindex, boolean mustFindChar)
-
-
-
Field Detail
-
line
protected java.lang.String line
-
linenum
protected int linenum
-
totalSize
protected int totalSize
-
bytesRead
protected int bytesRead
-
tempBuffer
protected java.lang.StringBuffer tempBuffer
-
dateFormat
protected java.text.SimpleDateFormat dateFormat
-
escapeChars
protected static final java.util.Map<java.lang.Character,java.lang.Character> escapeChars
-
unescapeChars
protected static final java.util.Map<java.lang.Character,java.lang.Character> unescapeChars
-
-
Method Detail
-
addOboFileEventListener
public void addOboFileEventListener(OboFileEventListener listener)
-
getOboFileEventListener
public java.util.List<OboFileEventListener> getOboFileEventListener()
-
parseOBO
public void parseOBO(java.io.BufferedReader oboFile) throws java.io.IOException, ParseExceptionparse an ontology file- Parameters:
oboFile-- Throws:
java.io.IOExceptionParseException
-
getDbxrefList
protected java.util.Map<java.lang.String,java.lang.Object>[] getDbxrefList(java.lang.String line, int startoffset, int endoffset) throws ParseException- Throws:
ParseException
-
parseXref
protected java.util.Map<java.lang.String,java.lang.Object> parseXref(java.lang.String line, int startoffset, int endoffset) throws ParseException- Throws:
ParseException
-
escape
public static java.lang.String escape(java.lang.String str, boolean escapespaces)
-
unescape
public java.lang.String unescape(java.lang.String str) throws ParseException- Throws:
ParseException
-
unescape
public OboFileParser.SOPair unescape(java.lang.String str, char toChar, int startindex, boolean mustFindChar) throws ParseException
- Throws:
ParseException
-
unescape
public OboFileParser.SOPair unescape(java.lang.String str, char toChar, int startindex, int endindex, boolean mustFindChar) throws ParseException
- Throws:
ParseException
-
findUnescaped
public static int findUnescaped(java.lang.String str, char toChar)
-
findUnescaped
public static int findUnescaped(java.lang.String str, char toChar, int startIndex, int endIndex)
-
findUnescaped
public static int findUnescaped(java.lang.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 java.lang.StringBuffer getTempBuffer()
-
readQuotedString
protected OboFileParser.SOPair readQuotedString(java.lang.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, java.lang.String str, int startIndex) throws ParseException- Throws:
ParseException
-
-