Source:
<code>private MgfMsSpectrum processSpectrum(BufferedReader reader) throws IOException { String line; String title = ""; int precursorCharge = 0; double precursorMass = 0; Matcher matcher = null; double mz[] = new double[16]; float intensive[] = new float[16]; int index = 0; int matcherId = -1; String groupped; <START> while (!(line = reader.readLine()).equals("END IONS")) { <END> if (line.contains("PEPMASS") || line.contains("TITLE") || line.contains("CHARGE")) { if (line.contains("PEPMASS")) { matcher = patterns.get("PEPMASS").matcher(line); matcherId = 1; } else if (line.contains("TITLE")) { matcher = patterns.get("TITLE").matcher(line); matcherId = 2; } else if (line.contains("CHARGE")) { matcher = patterns.get("CHARGE").matcher(line); matcherId = 3; } if (matcher.find()) { groupped = matcher.group(); switch (matcherId) { case 1: precursorMass = Double.parseDouble(groupped); break; case 2: title = groupped; break; case 3: String trimmed = groupped.substring(0, groupped.length() - 1); precursorCharge = Integer.parseInt(trimmed); if (groupped.charAt(groupped.length() - 1) == '-') { precursorCharge *= -1; } break; default: break; } } } else { String[] floats = line.split(" "); mz = ArrayUtil.addToArray(mz, Double.parseDouble(floats[0]), index); intensive = ArrayUtil.addToArray(intensive, Float.parseFloat(floats[1]), index); index++; } } MgfMsSpectrum spectrum = new MgfMsSpectrum(mz, intensive, index - 1, title, precursorCharge, precursorMass, MsSpectrumType.CENTROIDED); return spectrum; }</code><technical_language>is happen if is "END IONS" in file</technical_language>

Target:
private MgfMsSpectrum processSpectrum(BufferedReader reader) throws IOException, MSDKException { String title = ""; int precursorCharge = 0; double precursorMass = 0; double mz[] = new double[16]; float intensity[] = new float[16]; int index = 0; String line; String matched; while (true) { if (cancelled) return null; line = reader.readLine(); if (line == null || line.equals("END IONS")) { break; } try { if (line.contains("PEPMASS")) { matched = matchPattern(line, PEPMASS_PATTERN); precursorMass = Double.parseDouble(matched); } else if (line.contains("TITLE")) { title = matchPattern(line, TITLE_PATTERN); } else if (line.contains("CHARGE")) { matched = matchPattern(line, CHARGE_PATTERN); String unsignedIntString = matched.substring(0, matched.length() - 1); precursorCharge = Integer.parseInt(unsignedIntString); char sign = matched.charAt(matched.length() - 1); if (sign == '-') { precursorCharge *= -1; } } else { String[] floats = line.split(" "); if (floats.length < 2) { logger.debug("Failure on string :: {}", line); throw new MSDKRuntimeException("Incorrect amount of columns in MGF file"); } double mzValue = Double.parseDouble(floats[0]); float intensityValue = Float.parseFloat(floats[1]); mz = ArrayUtil.addToArray(mz, mzValue, index); intensity = ArrayUtil.addToArray(intensity, intensityValue, index); index++; } } catch (IllegalStateException e) { logger.debug("Regex could not recognize the pattern :: {}", line); throw new MSDKException("Incorrect data format", e); } } MsSpectrumType type = SpectrumTypeDetectionAlgorithm.detectSpectrumType(mz, intensity, index - 1); DataPointSorter.sortDataPoints(mz, intensity, index - 1, SortingProperty.MZ, SortingDirection.ASCENDING); MgfMsSpectrum spectrum = new MgfMsSpectrum(mz, intensity, index - 1, title, precursorCharge, precursorMass, type); return spectrum; }