public void readFileAndGenerate(boolean onlyUniquePeptides, ISpectrumDataFilter... filters) { @SuppressWarnings("UnusedDeclaration") int numberProcessed = 0; @SuppressWarnings("UnusedDeclaration") double lastRetentionTime = 0; @SuppressWarnings("UnusedDeclaration") int numberUnProcessed = 0; try { LineNumberReader rdr = new LineNumberReader(new FileReader(m_File)); String line = rdr.readLine(); while (line != null) { if (line.contains("<spectrum_query")) { String retention_time_sec = XMLUtil.extractAttribute(line, "retention_time_sec"); scan_id = XMLUtil.extractAttribute(line, "start_scan"); if (retention_time_sec == null) { lastRetentionTime = 0; } else { try { lastRetentionTime = Double.parseDouble(retention_time_sec.trim()); } catch (NumberFormatException e) { lastRetentionTime = 0; } } } //noinspection StatementWithEmptyBody,StatementWithEmptyBody if (line.contains("<search_result")) { String[] searchHitLines = readSearchHitLines(line, rdr); // System.out.println(line); boolean processed = handleSearchHit(searchHitLines, lastRetentionTime, onlyUniquePeptides, filters); if (processed) { for (int i = 0; i < searchHitLines.length; i++) { @SuppressWarnings("UnusedDeclaration") String searchHitLine = searchHitLines[i]; } numberProcessed++; } else numberUnProcessed++; } line = rdr.readLine(); } //noinspection UnnecessaryReturnStatement return; } catch (IOException e) { throw new RuntimeException(e); } }
protected String[] readSearchHitLines( String line, LineNumberReader rdr, @SuppressWarnings("UnusedParameters") ISpectrumDataFilter... filters) { List<String> holder = new ArrayList<String>(); try { while (line != null) { holder.add(line); if (line.contains("</search_result")) { break; // done } line = rdr.readLine(); // read next line } } catch (IOException e) { throw new RuntimeException(e); } String[] ret = new String[holder.size()]; holder.toArray(ret); return ret; }