Package ubic.basecode.io.reader
Class SparseDoubleMatrixReader
- java.lang.Object
-
- ubic.basecode.io.reader.AbstractMatrixReader<DoubleMatrix<String,String>,Double>
-
- ubic.basecode.io.reader.DoubleMatrixReader
-
- ubic.basecode.io.reader.SparseDoubleMatrixReader
-
public class SparseDoubleMatrixReader extends DoubleMatrixReader
- Author:
- pavlidis
-
-
Field Summary
-
Fields inherited from class ubic.basecode.io.reader.AbstractMatrixReader
log
-
-
Constructor Summary
Constructors Constructor Description SparseDoubleMatrixReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleMatrix<String,String>
read(InputStream stream)
Read a sparse matrix that is expressed as an adjacency list in a tab-delimited file:DoubleMatrix<String,String>
read(InputStream stream, Collection<String> wantedRowNames)
DoubleMatrix<String,String>
read(InputStream stream, Collection<String> wantedRowNames, boolean createEmptyRows, int skipColumns, int maxRows)
DoubleMatrix<String,String>
readJW(InputStream stream)
Read a sparse matrix in "JW" (Jason Weston) format.-
Methods inherited from class ubic.basecode.io.reader.DoubleMatrixReader
createEmptyRow, createMatrix, 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) throws IOException
Read a sparse matrix that is expressed as an adjacency list in a tab-delimited file:item1 item2 weight item1 item5 weight
By definition the resulting matrix is square and symmetric.
Note that the ordering of the items will be as they are encountered in the file.
- Overrides:
read
in classDoubleMatrixReader
- Parameters:
stream
- InputStream- Returns:
- NamedMatrix
- Throws:
IOException
-
read
public DoubleMatrix<String,String> read(InputStream stream, Collection<String> wantedRowNames)
- Overrides:
read
in classDoubleMatrixReader
- Parameters:
stream
- InputStreamwantedRowNames
- Set- Returns:
read( stream, wantedRowNames, createEmptyRows )
withcreateEmptyRows
set to true.
-
read
public DoubleMatrix<String,String> read(InputStream stream, Collection<String> wantedRowNames, boolean createEmptyRows, int skipColumns, int maxRows)
- Overrides:
read
in classDoubleMatrixReader
- Parameters:
stream
- InputStreamwantedRowNames
- SetcreateEmptyRows
- if a row contained inwantedRowNames
is not found in the file, create an empty row filled with Double.NaN iff this param is true.- Returns:
- matrix
-
readJW
public DoubleMatrix<String,String> readJW(InputStream stream) throws IOException
Read a sparse matrix in "JW" (Jason Weston) format. The format is like this:2 <--- number of items - the first line of the file only. NOTE - this line is often blank or not present. 1 2 <--- items 1 has 2 edges 1 2 <--- edge indices are to items 1 & 2 0.1 100 <--- with the following weights 2 2 <--- items 2 also has 2 edges 1 2 <--- edge indices are also to items 1 & 2 (fully connected) 100 0.1 <--- with the following weights
Note that the item numbering starts at 1. This is a requirement.
Note that this cannot handle very large matrices - the limit to rows x columns is the number Integer.MAX_VALUE. This is an implementation problem for colt's sparse matrix.
- Parameters:
stream
-wantedRowNames
-- Returns:
- Throws:
IOException
-
-