Exemple #1
0
        /// <summary>
        /// Sequences are passed to Prosit as an array of indices mapping into an array
        /// of amino acids (with modifications). Actually throwing exceptions in this method
        /// slows down constructing inputs (for larger data sets with unknown mods (and aa's)significantly,
        /// which is why PrositExceptions (only) are set as an output parameter and null is returned.
        /// </summary>
        public static int[] EncodeSequence(SrmSettings settings, ISequenceContainer peptide, IsotopeLabelType label, out PrositException exception)
        {
            if (!peptide.Target.IsProteomic)
            {
                throw new PrositSmallMoleculeException(peptide.ModifiedTarget);
            }

            var sequence = peptide.Target.Sequence;

            if (sequence.Length > PrositConstants.PEPTIDE_SEQ_LEN)
            {
                exception = new PrositPeptideTooLongException(peptide.ModifiedTarget);
                return(null);
            }

            var modifiedSequence = ModifiedSequence.GetModifiedSequence(settings, peptide, label);
            var result           = new int[PrositConstants.PEPTIDE_SEQ_LEN];

            for (var i = 0; i < sequence.Length; ++i)
            {
                if (!PrositConstants.AMINO_ACIDS.TryGetValue(sequence[i], out var prositAA))
                {
                    exception = new PrositUnsupportedAminoAcidException(peptide.ModifiedTarget, i);
                    return(null);
                }

                var mods = modifiedSequence.ExplicitMods.Where(m => m.IndexAA == i).ToArray();
                foreach (var mod in mods)
                {
                    if (mod.MonoisotopicMass == 0.0)
                    {
                        continue;
                    }

                    var staticMod = UniMod.FindMatchingStaticMod(mod.StaticMod, true) ?? mod.StaticMod;
                    if (!PrositConstants.MODIFICATIONS.TryGetValue(staticMod.Name, out var prositAAMod))
                    {
                        exception = new PrositUnsupportedModificationException(peptide.ModifiedTarget,
                                                                               mod.StaticMod,
                                                                               mod.IndexAA);
                        return(null);
                    }

                    result[i] = prositAAMod.PrositIndex;
                    break;
                }

                if (result[i] == 0)
                {
                    // Not modified
                    result[i] = prositAA.PrositIndex;
                }
            }

            exception = null;
            return(result);
        }
Exemple #2
0
        public FragmentedMolecule GetSimplePrecursorMolecule()
        {
            if (_precursorMolecule == null)
            {
                var modifiedSequence = ModifiedSequence.GetModifiedSequence(Settings, Peptide.Sequence, ExplicitMods, LabelType)
                                       .SeverCrosslinks();
                _precursorMolecule = FragmentedMolecule.EMPTY.ChangeModifiedSequence(modifiedSequence);
            }

            return(_precursorMolecule);
        }
Exemple #3
0
        public static PeptideFormatter MakePeptideFormatter(SrmSettings srmSettings, Peptide peptide,
                                                            ExplicitMods explicitMods, ICollection <IsotopeLabelType> heavyLabelTypes,
                                                            ModFontHolder modFontHolder)
        {
            var lightModifiedSequence =
                ModifiedSequence.GetModifiedSequence(srmSettings, peptide.Sequence, explicitMods, IsotopeLabelType.light);
            var heavyModifiedSequences = new List <KeyValuePair <IsotopeLabelType, ModifiedSequence> >();

            foreach (var labelType in srmSettings.PeptideSettings.Modifications.GetHeavyModificationTypes())
            {
                if (!heavyLabelTypes.Contains(labelType))
                {
                    continue;
                }

                heavyModifiedSequences.Add(new KeyValuePair <IsotopeLabelType, ModifiedSequence>(labelType,
                                                                                                 ModifiedSequence.GetModifiedSequence(srmSettings, peptide.Sequence, explicitMods, labelType)));
            }

            var peptideFormatter = new PeptideFormatter(srmSettings, lightModifiedSequence, heavyModifiedSequences, modFontHolder);

            if (explicitMods != null && explicitMods.HasCrosslinks)
            {
                var linkedPeptides = new List <KeyValuePair <ModificationSite, PeptideFormatter> >();
                foreach (var entry in explicitMods.Crosslinks)
                {
                    if (entry.Value.Peptide == null)
                    {
                        continue;
                    }

                    var childFormatter = MakePeptideFormatter(srmSettings, entry.Value.Peptide,
                                                              entry.Value.ExplicitMods, heavyLabelTypes, modFontHolder)
                                         .ChangeCrosslinkedIndexAa(entry.Value.IndexAa);
                    linkedPeptides.Add(new KeyValuePair <ModificationSite, PeptideFormatter>(entry.Key, childFormatter));
                }

                peptideFormatter = peptideFormatter
                                   .ChangeLinkedPeptides(ImmutableSortedList.FromValues(linkedPeptides));
            }

            return(peptideFormatter);
        }
Exemple #4
0
        public static PeptideFormatter MakePeptideFormatter(SrmSettings srmSettings, PeptideDocNode peptideDocNode,
                                                            ModFontHolder modFontHolder)
        {
            var lightModifiedSequence =
                ModifiedSequence.GetModifiedSequence(srmSettings, peptideDocNode, IsotopeLabelType.light);
            var heavyModifiedSequences = new List <KeyValuePair <IsotopeLabelType, ModifiedSequence> >();

            foreach (var labelType in srmSettings.PeptideSettings.Modifications.GetHeavyModificationTypes())
            {
                if (!peptideDocNode.HasChildType(labelType))
                {
                    continue;
                }

                heavyModifiedSequences.Add(new KeyValuePair <IsotopeLabelType, ModifiedSequence>(labelType,
                                                                                                 ModifiedSequence.GetModifiedSequence(srmSettings, peptideDocNode, labelType)));
            }

            return(new PeptideFormatter(srmSettings, lightModifiedSequence, heavyModifiedSequences, modFontHolder));
        }
Exemple #5
0
        public void TestLooplink()
        {
            var peptide          = new Peptide("PEPTIDE");
            var srmSettings      = SrmSettingsList.GetDefault();
            var transitionFilter = srmSettings.TransitionSettings.Filter;

            transitionFilter = transitionFilter
                               .ChangeFragmentRangeFirstName(TransitionFilter.StartFragmentFinder.ION_1.Name)
                               .ChangeFragmentRangeLastName(@"last ion")
                               .ChangePeptideIonTypes(new[] { IonType.precursor, IonType.y, IonType.b });
            srmSettings = srmSettings.ChangeTransitionSettings(
                srmSettings.TransitionSettings.ChangeFilter(transitionFilter));

            var transitionGroup           = new TransitionGroup(peptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light);
            var crosslinkerDef            = new StaticMod("dss", null, null, "C8H10O2");
            var linkedPeptide             = new LinkedPeptide(null, 5, null);
            var crosslinkMod              = new ExplicitMod(2, crosslinkerDef).ChangeLinkedPeptide(linkedPeptide);
            var explicitModsWithCrosslink = new ExplicitMods(peptide, new[] { crosslinkMod }, new TypedExplicitModifications[0]);
            var transitionGroupDocNode    = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, srmSettings,
                                                                       explicitModsWithCrosslink, null, ExplicitTransitionGroupValues.EMPTY, null, null, false);
            var modifiedSequence = ModifiedSequence.GetModifiedSequence(srmSettings, peptide.Sequence,
                                                                        explicitModsWithCrosslink, IsotopeLabelType.light);

            Assert.AreEqual("PEPTIDE-[dss@3-6]", modifiedSequence.FullNames);

            var choices = transitionGroupDocNode.GetPrecursorChoices(srmSettings, explicitModsWithCrosslink, true)
                          .Cast <TransitionDocNode>().ToArray();
            var complexFragmentIons = choices.Select(transition => transition.ComplexFragmentIon.GetName()).ToArray();
            // Make sure none of the transitions involve a cleavage in between the two ends of the looplink
            // PEpTIdE
            var yOrdinals = complexFragmentIons.Where(ion => ion.IonType == IonType.y).Select(ion => ion.Ordinal)
                            .Distinct().ToList();
            var bOrdinals = complexFragmentIons.Where(ion => ion.IonType == IonType.b).Select(ion => ion.Ordinal)
                            .Distinct().ToList();

            CollectionAssert.AreEquivalent(new[] { 6, 5, 1 }, yOrdinals);
            CollectionAssert.AreEquivalent(new[] { 1, 2, 6 }, bOrdinals);
        }