Package ubic.basecode.io.reader
Class SparseRaggedMatrixReader
- java.lang.Object
-
- ubic.basecode.io.reader.AbstractMatrixReader<DoubleMatrix<String,String>,Double>
-
- ubic.basecode.io.reader.DoubleMatrixReader
-
- ubic.basecode.io.reader.SparseRaggedMatrixReader
-
public class SparseRaggedMatrixReader extends DoubleMatrixReader
Best data structure for reading really big, really sparse matrices when a matrix represetation is needed. This uses a completely different file format than what we use for dense matrices.- Author:
- pavlidis
- See Also:
DoubleMatrixReader
-
-
Field Summary
-
Fields inherited from class ubic.basecode.io.reader.AbstractMatrixReader
log
-
-
Constructor Summary
Constructors Constructor Description SparseRaggedMatrixReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleMatrix<String,String>
read(InputStream stream, int offset)
Read an entire sparse matrix from a stream (JW format).DoubleMatrix<String,String>
readFromAdjList(InputStream stream)
DoubleMatrix<String,String>
readFromAdjList(String fileName)
Read a sparse symmetric square matrix that is expressed as an adjacency list in a tab-delimited file:DoubleMatrix<String,String>
readOneRow(BufferedReader dis, int offset)
Use this to read one row from a matrix (JW format).-
Methods inherited from class ubic.basecode.io.reader.DoubleMatrixReader
createEmptyRow, createMatrix, read, read, read, read, read, read, read, read
-
Methods inherited from class ubic.basecode.io.reader.AbstractMatrixReader
readHeader
-
-
-
-
Method Detail
-
read
public DoubleMatrix<String,String> read(InputStream stream, int offset) throws IOException
Read an entire sparse matrix from a stream (JW format).- Parameters:
stream
-offset
- A value indicating the lowest value for the indexes listed. This is here in case the indexes in the stream are numbered starting from 1 instead of zero.- Returns:
- Throws:
IOException
-
readFromAdjList
public DoubleMatrix<String,String> readFromAdjList(InputStream stream) throws NumberFormatException, IOException
- Parameters:
stream
-- Returns:
- Throws:
IOException
NumberFormatException
- Read a sparse symmetric square matrix that is expressed as an adjacency list in a tab-delimited file:item1 item2 weight item1 item5 weight
IMPORTANT: By definition the resulting matrix is square and symmetric, even if the symmetric edges are not explicitly listed.
-
readFromAdjList
public DoubleMatrix<String,String> readFromAdjList(String fileName) throws IOException
Read a sparse symmetric square matrix that is expressed as an adjacency list in a tab-delimited file:item1 item2 weight item1 item5 weight
IMPORTANT: By definition the resulting matrix is square and symmetric, even if the symmetric edges are not explicitly listed.
- Parameters:
name
- of file- Returns:
- Throws:
IOException
-
readOneRow
public DoubleMatrix<String,String> readOneRow(BufferedReader dis, int offset) throws IOException
Use this to read one row from a matrix (JW format). It does not close the reader. (this actually has to read several lines to get the data for one matrix row)- Parameters:
stream
-offset
- A value indicating the lowest value for the indexes listed. This is here in case the indexes in the stream are numbered starting from 1 instead of zero.- Returns:
- Throws:
IOException
-
-