Class MZTabHeaderLineParser
- java.lang.Object
-
- uk.ac.ebi.pride.jmztab2.utils.parser.MZTabLineParser
-
- uk.ac.ebi.pride.jmztab2.utils.parser.MZTabHeaderLineParser
-
- Direct Known Subclasses:
SEHLineParser
,SFHLineParser
,SMHLineParser
public abstract class MZTabHeaderLineParser extends MZTabLineParser
A couple of common method used to parse a header line intoMZTabColumnFactory
structure. NOTICE:MZTabColumnFactory
maintain a couple ofMZTabColumn
which have internal logical position and order. In physical mzTab file, we allow user not obey this logical position organized way, and provide their date with own order. In order to distinguish them, we use physical position (a positive integer) to record the column location in mzTab file. And usePositionMapping
structure the maintain the mapping between them.- Since:
- 11/02/13
- Author:
- qingwei
- See Also:
SMHLineParser
,SMFLineParser
,SMELineParser
-
-
Field Summary
Fields Modifier and Type Field Description protected MZTabColumnFactory
factory
protected Metadata
metadata
-
Fields inherited from class uk.ac.ebi.pride.jmztab2.utils.parser.MZTabLineParser
context, errorList, items, line, lineNumber, section
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MZTabHeaderLineParser(MZTabParserContext context, MZTabColumnFactory factory, Metadata metadata)
Parse a header line intoMZTabColumnFactory
structure.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected int
checkAbundanceColumns(int offset, String order)
checkAbundanceColumns.protected boolean
checkOptColumnName(String nameLabel)
Additional columns can be added to the end of the protein table.protected String
fromIndexToOrder(Integer index)
fromIndexToOrder.MZTabColumnFactory
getFactory()
Getter for the fieldfactory
.void
parse(int lineNumber, String line, MZTabErrorList errorList)
We assume that user before call this method, have parse the raw line is not empty line and start with section prefix.protected abstract int
parseColumns()
This methods delegates to the subclasses the parsing of the columns.protected int
parseIndex(String header, String id)
Parse header to a index id number.protected abstract void
refine()
Some validate operation need to be done after the wholeMZTabColumnFactory
created.protected void
refineOptionalColumn(Section section, String columnHeader)
Refine optional columns and check, whether they were properly defined.
-
-
-
Field Detail
-
factory
protected MZTabColumnFactory factory
-
-
Constructor Detail
-
MZTabHeaderLineParser
protected MZTabHeaderLineParser(MZTabParserContext context, MZTabColumnFactory factory, Metadata metadata)
Parse a header line intoMZTabColumnFactory
structure.- Parameters:
context
- the parser context, keeping dynamic state and lookup associations.factory
- SHOULD NOT set nullmetadata
- SHOULD NOT set null
-
-
Method Detail
-
parse
public void parse(int lineNumber, String line, MZTabErrorList errorList) throws MZTabException
We assume that user before call this method, have parse the raw line is not empty line and start with section prefix. Parse a header line intoMZTabColumnFactory
structure. There are several steps in this method: Step 1:parseColumns()
focus on validate and parse all columns. Step 2:refine()
- Overrides:
parse
in classMZTabLineParser
- Parameters:
lineNumber
- a int.line
- aString
object.errorList
- aMZTabErrorList
object.- Throws:
MZTabException
- if any.
-
parseColumns
protected abstract int parseColumns() throws MZTabException
This methods delegates to the subclasses the parsing of the columns. All of the columns are defined inSmallMoleculeColumn
,SmallMoleculeFeatureColumn
, orSmallMoleculeEvidenceColumn
.- Returns:
- the next physical index of column available after the parsing.
- Throws:
MZTabException
- if any structural or logical errors are encountered that prohibit further processing.
-
refine
protected abstract void refine() throws MZTabException
Some validate operation need to be done after the wholeMZTabColumnFactory
created. Thus, user can add them, and called at the end of theparse(int, String, MZTabErrorList)
method.- Throws:
MZTabException
- if any structural or logical errors are encountered that prohibit further processing.
-
refineOptionalColumn
protected void refineOptionalColumn(Section section, String columnHeader) throws MZTabException
Refine optional columns and check, whether they were properly defined. These re-validate operation will called inrefine()
method.- Parameters:
section
- aSection
object defining the part of the document.columnHeader
- aString
object.- Throws:
MZTabException
- if any structural or logical errors are encountered that prohibit further processing.
-
fromIndexToOrder
protected String fromIndexToOrder(Integer index)
fromIndexToOrder.
-
checkOptColumnName
protected boolean checkOptColumnName(String nameLabel) throws MZTabException
Additional columns can be added to the end of the protein table. These column headers MUST start with the prefix "opt_". Column names MUST only contain the following characters: 'A'-'Z', 'a'-'z', '0'-'9', '_', '-', '[', ']', and ':'. the format: opt_{IndexedElement[id]}_{value}. Spaces within the parameter's name MUST be replaced by '_'.- Parameters:
nameLabel
- aString
object.- Returns:
- a boolean.
- Throws:
MZTabException
- if any structural or logical errors are encountered that prohibit further processing.
-
checkAbundanceColumns
protected int checkAbundanceColumns(int offset, String order) throws MZTabException
checkAbundanceColumns.
- Parameters:
offset
- a int.order
- aString
object.- Returns:
- a int.
- Throws:
MZTabException
- if any structural or logical errors are encountered that prohibit further processing.
-
parseIndex
protected int parseIndex(String header, String id) throws MZTabException
Parse header to a index id number. If exists parse error, stop validate and throwMZTabException
directly.- Parameters:
header
- aString
object.id
- aString
object.- Returns:
- a int.
- Throws:
MZTabException
- if any structural or logical errors are encountered that prohibit further processing.
-
getFactory
public MZTabColumnFactory getFactory()
Getter for the field
factory
.- Returns:
- a
MZTabColumnFactory
object.
-
-