Package ubic.basecode.io.writer
Class MatrixWriter<R,C>
- java.lang.Object
-
- ubic.basecode.io.writer.MatrixWriter<R,C>
-
public class MatrixWriter<R,C> extends Object
Class for writing matrices to disk- Author:
- Raymond Lim, paul
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<C,String>
colNameMap
static String
DEFAULT_SEP
static String
DEFAULT_TOP_LEFT
protected Format
formatter
protected Writer
out
protected Map<R,String>
rowNameMap
protected String
sep
protected Map<?,String>
sliceNameMap
protected String
topLeft
-
Constructor Summary
Constructors Constructor Description MatrixWriter(OutputStream out)
MatrixWriter(OutputStream out, Format formatter)
MatrixWriter(OutputStream out, Format formatter, String sep)
MatrixWriter(Writer out)
MatrixWriter(Writer out, String sep)
MatrixWriter(Writer out, Format formatter)
MatrixWriter(Writer out, Format formatter, String sep)
MatrixWriter(String fileName, Format formatter)
MatrixWriter(String fileName, Format formatter, String sep)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setColNameMap(Map<C,String> colNameMap)
Use to customize the labels instead of relying on the toString method of the column objectvoid
setRowNameMap(Map<R,String> rowNameMap)
Use to customize the labels instead of relying on the toString method of the row objectvoid
setSep(String sep)
void
setSliceNameMap(Map<?,String> sliceNameMap)
void
setTopLeft(String topLeft)
void
writeMatrix(cern.colt.matrix.DoubleMatrix1D coltMatrix)
Write a bare 1D matrix (one value per line)void
writeMatrix(cern.colt.matrix.DoubleMatrix2D coltMatrix)
Write a bare matrix without row names or columns<V> void
writeMatrix(Matrix2D<R,C,V> matrix, boolean printNames)
<S,V>
voidwriteMatrix(Matrix3D<R,C,S,V> matrix, boolean printNames)
Writes a 3d matrix, collapsing the rows and columns
-
-
-
Field Detail
-
DEFAULT_SEP
public static final String DEFAULT_SEP
- See Also:
- Constant Field Values
-
DEFAULT_TOP_LEFT
public static final String DEFAULT_TOP_LEFT
- See Also:
- Constant Field Values
-
formatter
protected Format formatter
-
out
protected Writer out
-
sep
protected String sep
-
topLeft
protected String topLeft
-
-
Constructor Detail
-
MatrixWriter
public MatrixWriter(OutputStream out)
-
MatrixWriter
public MatrixWriter(OutputStream out, Format formatter)
-
MatrixWriter
public MatrixWriter(OutputStream out, Format formatter, String sep)
-
MatrixWriter
public MatrixWriter(String fileName, Format formatter) throws IOException
- Throws:
IOException
-
MatrixWriter
public MatrixWriter(String fileName, Format formatter, String sep) throws IOException
- Throws:
IOException
-
MatrixWriter
public MatrixWriter(Writer out)
-
-
Method Detail
-
setColNameMap
public void setColNameMap(Map<C,String> colNameMap)
Use to customize the labels instead of relying on the toString method of the column object- Parameters:
colNameMap
-
-
setRowNameMap
public void setRowNameMap(Map<R,String> rowNameMap)
Use to customize the labels instead of relying on the toString method of the row object- Parameters:
rowNameMap
-
-
setSep
public void setSep(String sep)
-
setTopLeft
public void setTopLeft(String topLeft)
-
writeMatrix
public <V> void writeMatrix(Matrix2D<R,C,V> matrix, boolean printNames) throws IOException
- Type Parameters:
V
-- Parameters:
matrix
-printNames
- Should the row and column names be included; FIXME this fails if names aren't provided- Throws:
IOException
-
writeMatrix
public void writeMatrix(cern.colt.matrix.DoubleMatrix2D coltMatrix) throws IOException
Write a bare matrix without row names or columns- Parameters:
coltMatrix
-- Throws:
IOException
-
writeMatrix
public void writeMatrix(cern.colt.matrix.DoubleMatrix1D coltMatrix) throws IOException
Write a bare 1D matrix (one value per line)- Parameters:
coltMatrix
-- Throws:
IOException
-
writeMatrix
public <S,V> void writeMatrix(Matrix3D<R,C,S,V> matrix, boolean printNames) throws IOException
Writes a 3d matrix, collapsing the rows and columns- Parameters:
matrix
-printNames
-- Throws:
IOException
-
-