Recipe 3.2. Editing a MS peak list
Problem
You want to edit a MS peak list.
Solution
MS peak list instances are immutable as no setters is able to modify it. The only way to modify a peak list pass by a manager that will handle it.
JPLMSPeakListManager manager = JPLMSPeakListManager.getInstance();
This manager provides setters to modify any PeakListImpl:
// the peak list to edit pl = new PeakListImpl.Builder(masses).intensities(intensities).build(); // modify an mz manager.setMzAt(pl, 2.9, 1); // modify an intensity manager.setIntensityAt(pl, 29, 1); // add annotation manager.addAnnotationAt(pl, new FragmentAnnotationImpl.Builder( PeptideTypeImpl.A, 2).build(), 1); // remove all annotations at given peak manager.removeAnnotationsAt(pl, 1); Assert.assertFalse(pl.hasAnnotations());
Discussion
See Also