/// <summary> /// Score a <see cref="PrSm" /> based on its sequence and MS/MS spectrum. /// </summary> /// <param name="prsm">The <see cref="PrSm" /> to score.</param> private void UpdatePrSmScore(PrSm prsm) { if (this.ScorerFactory == null) { return; } var ms2Spectrum = prsm.Ms2Spectrum; if (ms2Spectrum == null) { return; } var scorer = this.ScorerFactory.GetScorer(prsm.Ms2Spectrum); prsm.Score = IonUtils.ScoreSequence(scorer, prsm.Sequence); }
/// <summary> /// Implementation of the CreatePRSM command. /// Creates a new protein-spectrum match for the selected sequence, /// charge, and scan number. /// </summary> private void CreatePrSmImplementation() { var sequenceReader = new SequenceReader(); Sequence sequence = null; try { sequence = sequenceReader.Read(this.SequenceText); if (sequence == null) { throw new FormatException("Invalid Sequence."); } } catch (FormatException e) { this.dialogService.MessageBox(e.Message); return; } finally { if (sequence == null) { sequence = new Sequence(new List <AminoAcid>()); } } if (sequence.Count > 0 && this.SelectedCharge == 0) { this.dialogService.MessageBox("Invalid Charge state."); return; } if (sequence.Count == 0 && this.SelectedScan < 0) { this.dialogService.MessageBox("Invalid scan number."); return; } ILcMsRun lcms = this.SelectedDataSetViewModel.LcMs; double score = -1.0; if (lcms != null && this.SelectedScan > 0 && this.ScorerFactory != null && sequence.Count > 0) { var spectrum = lcms.GetSpectrum(this.SelectedScan) as ProductSpectrum; if (spectrum != null) { var scorer = this.ScorerFactory.GetScorer(spectrum); score = IonUtils.ScoreSequence(scorer, sequence); } } string rawFileName = this.SelectedDataSetViewModel.Title; var prsm = new PrSm { Heavy = false, RawFileName = rawFileName, ProteinName = string.Empty, ProteinDesc = string.Empty, Scan = Math.Min(Math.Max(this.SelectedScan, 0), lcms.MaxLcScan), LcMs = lcms, Charge = this.SelectedCharge, Sequence = sequence, SequenceText = this.SequenceText, Score = score, }; this.SelectedPrSm = prsm; }