11/*
22 * The baseCode project
3- *
3+ *
44 * Copyright (c) 2006 University of British Columbia
5- *
5+ *
66 * Licensed under the Apache License, Version 2.0 (the "License");
77 * you may not use this file except in compliance with the License.
88 * You may obtain a copy of the License at
3737
3838/**
3939 * Reader for {@link basecode.dataStructure.matrix.DoubleMatrix}. Lines beginning with "#" or "!" will be ignored.
40- *
40+ *
4141 * @author Paul Pavlidis
42- *
42+ *
4343 */
4444public class DoubleMatrixReader extends AbstractMatrixReader <DoubleMatrix <String , String >, Double > {
4545
46- private static NumberFormat nf = NumberFormat .getInstance ( Locale .ENGLISH );
47- static {
48- if ( nf instanceof DecimalFormat ) {
49- // ( ( DecimalFormat ) nf ).setDecimalSeparatorAlwaysShown( true );
50- }
51- }
5246 private List <String > colNames ;
5347 private int numHeadings ;
5448
@@ -87,6 +81,11 @@ public DoubleMatrix<String, String> read( InputStream stream, Collection<String>
8781 public DoubleMatrix <String , String > read ( InputStream stream , Collection <String > wantedRowNames ,
8882 boolean createEmptyRows , int skipColumns , int maxRows ) throws IOException {
8983
84+ NumberFormat nf = NumberFormat .getInstance ( Locale .ENGLISH );
85+ if ( nf instanceof DecimalFormat ) {
86+ // ( ( DecimalFormat ) nf ).setDecimalSeparatorAlwaysShown( true );
87+ }
88+
9089 BufferedReader dis = new BufferedReader ( new InputStreamReader ( stream ) );
9190
9291 List <DoubleArrayList > MTemp = new Vector <DoubleArrayList >();
@@ -113,7 +112,7 @@ public DoubleMatrix<String, String> read( InputStream stream, Collection<String>
113112 continue ;
114113 }
115114
116- String rowName = parseRow ( row , rowNames , MTemp , wantedRowNames , skipColumns );
115+ String rowName = parseRow ( row , rowNames , MTemp , wantedRowNames , skipColumns , nf );
117116
118117 if ( rowName == null ) {
119118 // signals a blank or skipped row.
@@ -183,7 +182,7 @@ public DoubleMatrix<String, String> read( String filename ) throws IOException {
183182
184183 /**
185184 * Read a matrix from a file, subject to filtering criteria.
186- *
185+ *
187186 * @param filename data file to read from (can be compressed)
188187 * @param wantedRowNames contains names of rows we want to get
189188 * @return NamedMatrix object constructed from the data file
@@ -277,7 +276,7 @@ protected DoubleMatrix<String, String> createMatrix( List<DoubleArrayList> MTemp
277276 * @throws IOException
278277 */
279278 private String parseRow ( String row , Collection <String > rowNames , List <DoubleArrayList > MTemp ,
280- Collection <String > wantedRowNames , int skipColumns ) throws IOException {
279+ Collection <String > wantedRowNames , int skipColumns , NumberFormat nf ) throws IOException {
281280
282281 if ( row .startsWith ( "#" ) || row .startsWith ( "!" ) ) {
283282 return null ;
0 commit comments