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); } }
public static IdentifiedPSM processPeptide(final String line, double retentionTime, String id) { String peptide = XMLUtil.extractAttribute(line, "peptide"); if (peptide == null) throw new IllegalArgumentException("bad line " + line); Polypeptide polypeptide = Polypeptide.fromString(peptide); polypeptide.setRetentionTime(retentionTime); return new IdentifiedPSM(id, polypeptide); }
public static IProtein processProtein(final String line) { String peptide = XMLUtil.extractAttribute(line, "protein_descr"); if (peptide == null) throw new IllegalArgumentException("bad line " + line); return Protein.getProtein(peptide, "", "", null); }