Package uk.ac.ebi.pride.jmztab2.model
Class MZTabColumnFactory
- java.lang.Object
-
- uk.ac.ebi.pride.jmztab2.model.MZTabColumnFactory
-
public class MZTabColumnFactory extends Object
This is a static factory class which used to generate a couple of MZTabColumn objects, and organizes them into "logicalPosition, MZTabColumn" pairs. Currently, mzTab table including three kinds of columns:-
Stable column with stable order: header name, data type, logical position and
order are stable in these columns. All of them are defined in
SmallMoleculeColumn,SmallMoleculeFeatureColumn, andSmallMoleculeEvidenceColumn. -
Optional column with stable order: column name, data type and order are
defined in the
SmallMoleculeColumn,SmallMoleculeFeatureColumn, andSmallMoleculeEvidenceColumn. But header name, logical position dynamically depend onIndexedElement. -
Optional columns which are placed at the end of a table-based section. There
are three types of optional column:
AbundanceColumn,OptionColumnandParameterOptionColumn, which always are added at the end of the table. These optional columns have no stable column name, data type or order. In this factory, we useaddOptionalColumn(String, Class)to createOptionColumn; andaddOptionalColumn(de.isas.mztab2.model.IndexedElement, java.lang.String, java.lang.Class)oraddOptionalColumn(IndexedElement, Parameter, Class)to createParameterOptionColumn.
- Since:
- 23/05/13
- Author:
- qingwei, nilshoffmann
-
Stable column with stable order: header name, data type, logical position and
order are stable in these columns. All of them are defined in
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaddAbundanceOptionalColumn(de.isas.mztab2.model.Assay assay, String order)addAbundanceOptionalColumn.StringaddAbundanceOptionalColumn(de.isas.mztab2.model.StudyVariable studyVariable, String columnHeader, String order)StringaddIdConfidenceMeasureColumn(de.isas.mztab2.model.Parameter parameter, Integer index, Class columnType)addIdConfidenceMeasureColumn.StringaddOptionalColumn(de.isas.mztab2.model.Parameter param, Class columnType)StringaddOptionalColumn(String name, Class columnType)<T extends de.isas.mztab2.model.IndexedElement>
StringaddOptionalColumn(T columnEntity, de.isas.mztab2.model.Parameter param, Class columnType)AddParameterOptionColumnfollowed by an indexed element (study variable, assay, ms run) intooptionalColumnMappingandcolumnMapping.<T extends de.isas.mztab2.model.IndexedElement>
StringaddOptionalColumn(T columnEntity, String name, Class columnType)AddOptionColumnfollowed by an indexed element (study variable, assay, ms run) intooptionalColumnMappingandcolumnMapping.IMZTabColumnfindColumnByHeader(String header)Query the MZTabColumn in factory, based on column header with case-insensitive.SortedMap<String,IMZTabColumn>getColumnMapping()Get all columns in the factory.static MZTabColumnFactorygetInstance(Section section)Retrieves the MZTabColumnFactory accordingly to thesectionSortedMap<Integer,IMZTabColumn>getOffsetColumnsMap()The offset record the position of MZTabColumn in header line.SortedMap<String,IMZTabColumn>getOptionalColumnMapping()Get all optional columns, including option column with stable order and name, abundance columns, optional columns and cv param optional columns.SortedMap<String,IMZTabColumn>getStableColumnMapping()Get stable columns mapping.
-
-
-
Method Detail
-
getInstance
public static MZTabColumnFactory getInstance(Section section)
Retrieves the MZTabColumnFactory accordingly to thesection- Parameters:
section- SHOULD beSection.Protein_Header,Section.Peptide_HeaderSection.PSM_HeaderorSection.Small_Molecule_Header.- Returns:
- a
MZTabColumnFactoryobject.
-
getStableColumnMapping
public SortedMap<String,IMZTabColumn> getStableColumnMapping()
Get stable columns mapping. Key is logical position, and value is MZTabColumn object. Stable column with stable order: header name, data type, logical position and order are stable in these columns. All of them have been defined in nullSmallMoleculeColumn,SmallMoleculeFeatureColumn,SmallMoleculeEvidenceColumn.- Returns:
- a
SortedMapobject.
-
getOptionalColumnMapping
public SortedMap<String,IMZTabColumn> getOptionalColumnMapping()
Get all optional columns, including option column with stable order and name, abundance columns, optional columns and cv param optional columns. Key is logical position, and value is MZTabColumn object.- Returns:
- a
SortedMapobject. - See Also:
AbundanceColumn,OptionColumn,ParameterOptionColumn
-
getColumnMapping
public SortedMap<String,IMZTabColumn> getColumnMapping()
Get all columns in the factory. In this class, we maintain the following constraint at any time:- Returns:
- a
SortedMapobject.
-
addOptionalColumn
public String addOptionalColumn(String name, Class columnType)
Add globalOptionColumnintooptionalColumnMappingandcolumnMapping. The header like: opt_global_{name}- Parameters:
name- SHOULD NOT be empty.columnType- SHOULD NOT be empty.- Returns:
- the column's logic position.
-
addOptionalColumn
public <T extends de.isas.mztab2.model.IndexedElement> String addOptionalColumn(T columnEntity, String name, Class columnType)
AddOptionColumnfollowed by an indexed element (study variable, assay, ms run) intooptionalColumnMappingandcolumnMapping. The header will look like: opt_study_variable[1]_{name} for a study variable- Type Parameters:
T- the type of the columnEntity.- Parameters:
columnEntity- SHOULD NOT be empty.name- SHOULD NOT be empty.columnType- SHOULD NOT be empty.- Returns:
- the column's logic position.
-
addOptionalColumn
public String addOptionalColumn(de.isas.mztab2.model.Parameter param, Class columnType)
Add globalParameterOptionColumnintooptionalColumnMappingandcolumnMapping. The header like: opt_global_cv_{accession}_{parameter name}- Parameters:
param- SHOULD NOT empty.columnType- SHOULD NOT empty.- Returns:
- the column's logic position.
-
addOptionalColumn
public <T extends de.isas.mztab2.model.IndexedElement> String addOptionalColumn(T columnEntity, de.isas.mztab2.model.Parameter param, Class columnType)
AddParameterOptionColumnfollowed by an indexed element (study variable, assay, ms run) intooptionalColumnMappingandcolumnMapping. The header will look like: opt_assay[1]_cv_{accession}_{parameter name} for an assay.- Type Parameters:
T- the type of the columnEntity.- Parameters:
columnEntity- SHOULD NOT empty.param- SHOULD NOT empty.columnType- SHOULD NOT empty.- Returns:
- the column's logic position.
-
addAbundanceOptionalColumn
public String addAbundanceOptionalColumn(de.isas.mztab2.model.Assay assay, String order)
addAbundanceOptionalColumn.
- Parameters:
assay- aAssayobject.order- the order string for this column.- Returns:
- the column's logic position.
-
addAbundanceOptionalColumn
public String addAbundanceOptionalColumn(de.isas.mztab2.model.StudyVariable studyVariable, String columnHeader, String order)
Add anAbundanceColumnintoAbundanceColumn,optionalColumnMappingandcolumnMapping. The header can be one of abundance_study_variable[1], abundance_coeffvar_study_variable[1].- Parameters:
studyVariable- SHOULD NOT empty.columnHeader- the column header without the 'abundance_' prefix.order- the order string for this column.- Returns:
- the column's logic position.
- See Also:
AbundanceColumn.createOptionalColumns(uk.ac.ebi.pride.jmztab2.model.Section, de.isas.mztab2.model.StudyVariable, java.lang.String, java.lang.String)
-
addIdConfidenceMeasureColumn
public String addIdConfidenceMeasureColumn(de.isas.mztab2.model.Parameter parameter, Integer index, Class columnType)
addIdConfidenceMeasureColumn.
- Parameters:
parameter- aParameterobject.index- aIntegerobject.columnType- the class of values in this column.- Returns:
- the column's logic position.
-
getOffsetColumnsMap
public SortedMap<Integer,IMZTabColumn> getOffsetColumnsMap()
The offset record the position of MZTabColumn in header line. For example, protein header line, the relationships between Logical Position, MZTabColumn, offset and order are like following structure: Logical Position MZTabColumn offset order "01" accession 1 01 "02" description 2 02 ...... "08" best_search_engine_score 8 08 "091" search_engine_score_ms_run[1] 9 09 "092" search_engine_score_ms_run[2] 10 09 "10" reliability 11 10 "111" num_psms_ms_run[1] 12 11 "112" num_psms_ms_run[2] 13 11- Returns:
- a
SortedMapobject with the offsets for each column.
-
findColumnByHeader
public IMZTabColumn findColumnByHeader(String header)
Query the MZTabColumn in factory, based on column header with case-insensitive. Notice: for optional columns, header name maybe flexible. For example, num_psms_ms_run[1]. At this time, user SHOULD BE provide the full header name to query MZTabColumn. If just provide num_psms_ms_run, return null.- Parameters:
header- the column header to use as the search key.- Returns:
- a
IMZTabColumnobject or null.
-
-