is.seek(chrSummary.getStartPosition());
AsciiLineReader reader = new AsciiLineReader(is);
// Create containers to hold data
IntArrayList startLocations = new IntArrayList(nRowsEst);
IntArrayList endLocations = (hasEndLocations ? new IntArrayList(nRowsEst) : null);
List<String> probes = new ArrayList(nRowsEst);
Map<String, FloatArrayList> dataMap = new HashMap();
for (String h : dataHeaders) {
dataMap.put(h, new FloatArrayList(nRowsEst));
}
// Begin loop through rows
String chromosome = chrSummary.getName();
boolean chromosomeStarted = false;
String nextLine = reader.readLine();
while ((nextLine != null) && (nextLine.trim().length() > 0)) {
if (!nextLine.startsWith("#")) {
try {
String[] tokens = Globals.tabPattern.split(nextLine, -1);
String thisChromosome = genome.getChromosomeAlias(tokens[chrColumn].trim());
if (thisChromosome.equals(chromosome)) {
chromosomeStarted = true;
// chromosomeData.setMarkerId(nRows, tokens[0]);
// The probe. A new string is created to prevent holding on to the entire row through a substring reference
String probe = new String(tokens[probeColumn]);
probes.add(probe);
int start = ParsingUtils.parseInt(tokens[startColumn].trim()) - startBase;
if (hasEndLocations) {
endLocations.add(ParsingUtils.parseInt(tokens[endColumn].trim()));
}
startLocations.add(start);
if(tokens.length <= firstDataColumn + (dataHeaders.length - 1)*skipColumns){
String msg = "Line has too few data columns: " + nextLine;
log.error(msg);
throw new RuntimeException(msg);
}
for (int idx = 0; idx < dataHeaders.length; idx++) {
int i = firstDataColumn + idx * skipColumns;
float copyNo = i <= lastDataColumn ? readFloat(tokens[i]) : Float.NaN;
String heading = dataHeaders[idx];
dataMap.get(heading).add(copyNo);
}
} else if (chromosomeStarted) {
break;
}
} catch (NumberFormatException numberFormatException) {
// Skip line
log.info("Skipping line (NumberFormatException) " + nextLine);
}
}
nextLine = reader.readLine();
}
// Loop complete
ChromosomeData cd = new ChromosomeData(chrSummary.getName());
cd.setProbes(probes.toArray(new String[]{}));
cd.setStartLocations(startLocations.toArray());
if (hasEndLocations) {
cd.setEndLocations(endLocations.toArray());
}
for (String h : dataHeaders) {
cd.setData(h, dataMap.get(h).toArray());
}