public MutableMs2Experiment makeMutable(Ms2Experiment experiment) { if (experiment instanceof MutableMs2Experiment) return (MutableMs2Experiment) experiment; else return new MutableMs2Experiment(experiment); }
public void setExperimentInformation(Ms2Experiment exp) { if (exp instanceof MutableMs2Experiment) { this.experiment = (MutableMs2Experiment)exp; } else { this.experiment = new MutableMs2Experiment(exp); } }
private List<ExperimentWithAnnotatedSpectra> extractSpectra(Ms2Dataset ms2Dataset){ List<ExperimentWithAnnotatedSpectra> experimentsWithAnnotatedSpectra = new ArrayList<>(); final List<Ms2Experiment> experiments = ms2Dataset.getExperiments(); for (Ms2Experiment experiment : experiments) { List<Spectrum<PeakWithAnnotation>> ms1 = convert(experiment.getMs1Spectra()); List<Spectrum<PeakWithAnnotation>> ms2 = convert(experiment.getMs2Spectra()); experimentsWithAnnotatedSpectra.add(new ExperimentWithAnnotatedSpectra(new MutableMs2Experiment(experiment), ms1, ms2)); } return experimentsWithAnnotatedSpectra; }
@Override public MutableMs2Experiment validate(Ms2Experiment originalInput, Warning warn, boolean repair) throws InvalidException { final MutableMs2Experiment input = new MutableMs2Experiment(originalInput); if (input.getMs1Spectra() == null || input.getMs1Spectra().isEmpty()) throw new InvalidException("Missing MS1 spectra"); checkIonization(warn, repair, input); checkMergedMs1(warn, repair, input); // checkNeutralMass(warn, repair, input); return input; }
@Deprecated public List<IdentificationResult> identifyPrecursorAndIonization(Ms2Experiment uexperiment, int numberOfCandidates, IsotopePatternHandling iso) { final MutableMs2Experiment exp = new MutableMs2Experiment(uexperiment); exp.setAnnotation(PossibleIonModes.class, PossibleIonModes.defaultFor(uexperiment.getPrecursorIonType().getCharge())); return identify(exp, numberOfCandidates, true, iso); }
/** * Creates a Ms2Experiment object from the given MS and MS/MS spectra. A Ms2Experiment is NOT a single run or measurement, but a measurement of a concrete compound. So a MS spectrum might contain several Ms2Experiments. However, each MS/MS spectrum should have on precursor or parent mass. All MS/MS spectra with the same precursor together with the MS spectrum containing this precursor peak can be seen as one Ms2Experiment. * * @param parentMass the measured mass of the precursor ion. Can be either the MS peak or (if present) a MS/MS peak * @param ion PrecursorIonType (contains ion mode as well as adducts and in-source fragmentations of the precursor ion) * @param ms1 the MS spectrum containing the isotope pattern of the measured compound. Might be null * @param ms2 a list of MS/MS spectra containing the fragmentation pattern of the measured compound * @return a MS2Experiment instance, ready to be analyzed by SIRIUS */ public Ms2Experiment getMs2Experiment(double parentMass, PrecursorIonType ion, Spectrum<Peak> ms1, Spectrum... ms2) { final MutableMs2Experiment mexp = new MutableMs2Experiment(); mexp.setPrecursorIonType(ion); mexp.setIonMass(parentMass); for (Spectrum<Peak> spec : ms2) { mexp.getMs2Spectra().add(new MutableMs2Spectrum(spec, mexp.getIonMass(), CollisionEnergy.none(), 2)); } return mexp; }
@Override public MutableMs2Experiment validate(Ms2Experiment originalInput, Warning warn, boolean repair) throws InvalidException { final MutableMs2Experiment input = new MutableMs2Experiment(originalInput); checkInchi(warn, repair, input); if (input.getMs2Spectra() == null) throw new InvalidException("Missing MS2 spectra"); removeEmptySpectra(warn, input); if (input.getMs2Spectra().isEmpty() && input.getMs1Spectra().isEmpty() && input.getMergedMs1Spectrum()==null) throw new InvalidException("Missing MS2 and MS1 spectra"); if (input.getMs1Spectra() == null) input.setMs1Spectra(new ArrayList<SimpleSpectrum>()); checkIonization(warn, repair, input); checkMergedMs1(warn, repair, input); checkIonMass(warn, repair, input); // checkNeutralMass(warn, repair, input); return input; }
private SimpleSpectrum extractIsotopePattern(Ms2Experiment experiment) { Ms2Experiment experiment2; if (experiment.getMergedMs1Spectrum()!=null) experiment2 = experiment; else { experiment2 = new MutableMs2Experiment(experiment); if (experiment2.getMs1Spectra().size() > 0) { ((MutableMs2Experiment)experiment2).setMergedMs1Spectrum(Spectrums.mergeSpectra(experiment2.<Spectrum<Peak>>getMs1Spectra())); } else { return new SimpleSpectrum(new double[0], new double[0]); } } //todo again the problem with the measurementprofile?! return sirius.getMs1Analyzer().extractPattern(experiment2, experiment2.getIonMass()); }
MutableMs2Experiment mutableMs2Experiment = new MutableMs2Experiment(result.getExperiment()); String name = mutableMs2Experiment.getName(); List<Ms2Experiment> experimentList = nameToExperiment.get(name);
/** * compute {@link IsotopePattern}s. Only use if possible pattern contains precursor peak(mass) * @param mass * @param spectrum * @param profile * @param precursorMass * @param charge * @return */ private List<IsotopePattern> computeIsotopePatterns(double mass, MutableSpectrum<Peak> spectrum, MeasurementProfile profile, double precursorMass, int charge) { int absCharge = Math.abs(charge); boolean mergeMasses = false; SimpleMutableSpectrum isotopeSpec = Spectrums.extractIsotopePattern(spectrum, profile, mass, absCharge, mergeMasses); isotopeSpec = trimToPossiblePattern(isotopeSpec); // if (!containsMass(precursorMass, isotopeSpec)) return new ArrayList<>(); MutableMs2Experiment mutableIsoExperiment = new MutableMs2Experiment(); mutableIsoExperiment.setPrecursorIonType(PrecursorIonType.unknown(charge)); mutableIsoExperiment.setIonMass(mass); mutableIsoExperiment.setMergedMs1Spectrum(new SimpleSpectrum(isotopeSpec)); FormulaConstraints constraints = sirius.predictElementsFromMs1(mutableIsoExperiment); setUpperBounds(constraints); IsotopePatternAnalysis isotopePatternAnalysis = sirius.getMs1Analyzer(); MutableMeasurementProfile mutableMeasurementProfile = new MutableMeasurementProfile(profile); mutableMeasurementProfile.setFormulaConstraints(constraints); List<IsotopePattern> isotopePatterns = isotopePatternAnalysis.deisotope(mutableIsoExperiment, mutableMeasurementProfile); return isotopePatterns; }
if (!inst.hasNext()) return null; ++inst.specIndex; final MutableMs2Experiment exp = new MutableMs2Experiment(); exp.setMs2Spectra(new ArrayList<MutableMs2Spectrum>()); exp.setMs1Spectra(new ArrayList<SimpleSpectrum>());
public FTree beautifyTree(MasterJJob<?> master, FTree tree, Ms2Experiment experiment, boolean recalibrating) { if (tree.getAnnotation(Beautified.class, Beautified.IS_UGGLY).isBeautiful()) return tree; final PrecursorIonType ionType = tree.getAnnotationOrThrow(PrecursorIonType.class); final MutableMs2Experiment mexp = new MutableMs2Experiment(experiment); mexp.setPrecursorIonType(ionType); final MolecularFormula formula;
MutableMs2Experiment input = new MutableMs2Experiment(originalExperiment); Ms2Experiment exp = input; final ProcessedInput pinput = new ProcessedInput(new MutableMs2Experiment(exp), originalExperiment, new MutableMeasurementProfile(profile)); if (constraints==null && (originalExperiment.getAnnotation(FormulaSettings.class,null)!=null)) { constraints = originalExperiment.getAnnotation(FormulaSettings.class).getConstraints();
experiment = null; if (compoundName == null) return; final MutableMs2Experiment exp = new MutableMs2Experiment(); exp.setIonMass(parentMass); exp.setMolecularFormula(formula);