Beispiel #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((ModifiedSequence.GetHashCode() * 397) ^
                (ExplicitMods != null ? ExplicitMods.GetHashCode() : 0));
     }
 }
Beispiel #2
0
        public static ModifiedSequence GetFragmentSequence(ModifiedSequence modifiedSequence, IonType ionType,
                                                           int ordinal)
        {
            string unmodifiedSequence = modifiedSequence.GetUnmodifiedSequence();

            switch (ionType)
            {
            case IonType.a:
            case IonType.b:
            case IonType.c:
                return(new ModifiedSequence(unmodifiedSequence.Substring(0, ordinal),
                                            modifiedSequence.GetModifications().Where(mod => mod.IndexAA < ordinal),
                                            MassType.Monoisotopic));
            }

            int    offset           = unmodifiedSequence.Length - ordinal;
            string fragmentSequence = unmodifiedSequence.Substring(offset);
            var    newModifications = modifiedSequence.GetModifications()
                                      .Where(mod => mod.IndexAA >= offset)
                                      .Select(mod => mod.ChangeIndexAa(mod.IndexAA - offset));

            return(new ModifiedSequence(fragmentSequence, newModifications, MassType.Monoisotopic));
        }
Beispiel #3
0
        private static Molecule GetSequenceFormula(ModifiedSequence modifiedSequence, MassType massType, out double unexplainedMassShift)
        {
            unexplainedMassShift = 0;
            var    molecule           = new Dictionary <string, int>();
            string unmodifiedSequence = modifiedSequence.GetUnmodifiedSequence();
            var    modifications      = modifiedSequence.GetModifications().ToLookup(mod => mod.IndexAA);

            for (int i = 0; i < unmodifiedSequence.Length; i++)
            {
                char aminoAcid = unmodifiedSequence[i];
                AddAminoAcidFormula(massType, aminoAcid, molecule, ref unexplainedMassShift);
                foreach (var mod in modifications[i])
                {
                    string formula = mod.Formula;
                    if (formula == null)
                    {
                        var staticMod = mod.StaticMod;
                        var aa        = unmodifiedSequence[i];
                        if ((staticMod.LabelAtoms & LabelAtoms.LabelsAA) != LabelAtoms.None && AminoAcid.IsAA(aa))
                        {
                            formula = SequenceMassCalc.GetHeavyFormula(aa, staticMod.LabelAtoms);
                        }
                    }
                    if (formula != null)
                    {
                        var modFormula = Molecule.ParseExpression(formula);
                        Add(molecule, modFormula);
                    }
                    else
                    {
                        unexplainedMassShift += massType.IsMonoisotopic() ? mod.MonoisotopicMass : mod.AverageMass;
                    }
                }
            }
            return(Molecule.FromDict(molecule));
        }
Beispiel #4
0
 public FragmentedMolecule ChangeModifiedSequence(ModifiedSequence modifiedSequence)
 {
     return(ChangeMoleculeProp(im => im.ModifiedSequence = modifiedSequence));
 }
Beispiel #5
0
        public static FragmentedMolecule GetFragmentedMolecule(SrmSettings settings, PeptideDocNode peptideDocNode,
                                                               TransitionGroupDocNode transitionGroupDocNode, TransitionDocNode transitionDocNode)
        {
            FragmentedMolecule fragmentedMolecule = EMPTY
                                                    .ChangePrecursorMassShift(0, settings.TransitionSettings.Prediction.PrecursorMassType)
                                                    .ChangeFragmentMassShift(0, settings.TransitionSettings.Prediction.FragmentMassType);

            if (peptideDocNode == null)
            {
                return(fragmentedMolecule);
            }
            var labelType = transitionGroupDocNode == null
                ? IsotopeLabelType.light
                : transitionGroupDocNode.TransitionGroup.LabelType;

            if (peptideDocNode.IsProteomic)
            {
                fragmentedMolecule = fragmentedMolecule.ChangeModifiedSequence(
                    ModifiedSequence.GetModifiedSequence(settings, peptideDocNode, labelType));
                if (transitionGroupDocNode != null)
                {
                    fragmentedMolecule = fragmentedMolecule
                                         .ChangePrecursorCharge(transitionGroupDocNode.PrecursorCharge);
                }
                if (transitionDocNode == null || transitionDocNode.IsMs1)
                {
                    return(fragmentedMolecule);
                }
                var transition = transitionDocNode.Transition;
                fragmentedMolecule = fragmentedMolecule
                                     .ChangeFragmentIon(transition.IonType, transition.Ordinal)
                                     .ChangeFragmentCharge(transition.Charge);
                var transitionLosses = transitionDocNode.Losses;
                if (transitionLosses != null)
                {
                    var fragmentLosses = transitionLosses.Losses.Select(transitionLoss => transitionLoss.Loss);
                    fragmentedMolecule = fragmentedMolecule.ChangeFragmentLosses(fragmentLosses);
                }
                return(fragmentedMolecule);
            }
            if (transitionGroupDocNode == null)
            {
                return(fragmentedMolecule
                       .ChangePrecursorFormula(
                           Molecule.Parse(peptideDocNode.CustomMolecule.Formula ?? string.Empty)));
            }
            var customMolecule = transitionGroupDocNode.CustomMolecule;

            fragmentedMolecule =
                fragmentedMolecule.ChangePrecursorCharge(transitionGroupDocNode.TransitionGroup
                                                         .PrecursorCharge);
            if (customMolecule.Formula != null)
            {
                var ionInfo = new IonInfo(customMolecule.Formula,
                                          transitionGroupDocNode.PrecursorAdduct);
                fragmentedMolecule = fragmentedMolecule
                                     .ChangePrecursorFormula(Molecule.Parse(ionInfo.FormulaWithAdductApplied));
            }
            else
            {
                fragmentedMolecule = fragmentedMolecule.ChangePrecursorMassShift(
                    transitionGroupDocNode.PrecursorAdduct.MassFromMz(
                        transitionGroupDocNode.PrecursorMz, transitionGroupDocNode.PrecursorMzMassType),
                    transitionGroupDocNode.PrecursorMzMassType);
            }
            if (transitionDocNode == null || transitionDocNode.IsMs1)
            {
                return(fragmentedMolecule);
            }
            var customIon = transitionDocNode.Transition.CustomIon;

            if (customIon.Formula != null)
            {
                fragmentedMolecule = fragmentedMolecule.ChangeFragmentFormula(
                    Molecule.Parse(customIon.FormulaWithAdductApplied));
            }
            else
            {
                fragmentedMolecule = fragmentedMolecule.ChangeFragmentMassShift(
                    transitionDocNode.Transition.Adduct.MassFromMz(
                        transitionDocNode.Mz, transitionDocNode.MzMassType),
                    transitionDocNode.MzMassType);
            }
            fragmentedMolecule = fragmentedMolecule
                                 .ChangeFragmentCharge(transitionDocNode.Transition.Charge);
            return(fragmentedMolecule);
        }
Beispiel #6
0
 public string FormatModifiedSequence(ModifiedSequence modifiedSequence)
 {
     return(_modifiedSequenceFormatter(modifiedSequence));
 }
Beispiel #7
0
 public static string FormatUnimodId(SrmSettings settings, IEnumerable <ModifiedSequence.Modification> mods)
 {
     return(ModifiedSequence.FormatUnimodIds(mods));
 }
Beispiel #8
0
 public static string FormatFullName(SrmSettings settings, IEnumerable <ModifiedSequence.Modification> mods)
 {
     return(string.Join(string.Empty,
                        mods.Select(mod => ModifiedSequence.Bracket(ModifiedSequence.FormatFullName(mod)))));
 }
Beispiel #9
0
 public static string FormatMassDelta(SrmSettings settings, IEnumerable <ModifiedSequence.Modification> mods)
 {
     return(ModifiedSequence.FormatMassModification(mods,
                                                    settings.TransitionSettings.Prediction.PrecursorMassType, false));
 }
Beispiel #10
0
 protected bool Equals(ModifiedSequence other)
 {
     return(string.Equals(_unmodifiedSequence, other._unmodifiedSequence) &&
            _explicitMods.Equals(other._explicitMods) && _defaultMassType == other._defaultMassType);
 }
Beispiel #11
0
 public Modification ChangeLinkedPeptideSequence(ModifiedSequence linkedPeptideSequence)
 {
     return(ChangeProp(ImClone(this), im => im.LinkedPeptideSequence = linkedPeptideSequence));
 }