Exemplo n.º 1
0
        /// <summary>
        /// Parse a CLEAN sequence (containing no pre/post residues or modifications).
        /// </summary>
        /// <param name="sequenceText">The clean sequence.</param>
        /// <param name="modInfo">The modification info for the sequence.</param>
        /// <returns>The parsed sequence.</returns>
        private Sequence ParseSequence(string sequenceText, List <clsAminoAcidModInfo> modInfo)
        {
            var sequenceReader = new SequenceReader();
            var sequence       = sequenceReader.Read(sequenceText);

            foreach (var mod in modInfo)
            {
                if (mod.AmbiguousMod)
                {
                    continue;
                }

                var location     = mod.ResidueLocInPeptide - 1;
                var aminoAcid    = sequence[location];
                var modification = TryGetExistingModification(
                    mod.ModDefinition.MassCorrectionTag,
                    mod.ModDefinition.ModificationMass);

                if (modification == null)
                {   // could not find existing modification
                    modification = new Modification(0, mod.ModDefinition.ModificationMass, mod.ModDefinition.MassCorrectionTag);
                    Modifications.Add(modification);
                }

                sequence[location] = new ModifiedAminoAcid(aminoAcid, modification);
            }

            // Force it to recalculate mass now that the modifications have been added.
            sequence = new Sequence(sequence);

            return(sequence);
        }
Exemplo n.º 2
0
        /// <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;
        }