Exemplo n.º 1
0
        public static double[] GetPhosphoXSeries(string sequence, PeptideModificationState fixedMods,
                                                 PeptideModificationState varMods,
                                                 out MsmsPeakAnnotation[] descriptions, bool includeNeutralLoss)
        {
            List <double>             masses = new List <double>();
            List <MsmsPeakAnnotation> descr  = new List <MsmsPeakAnnotation>();

            double[] y = GetYSeries(sequence, fixedMods, varMods);
            for (int i = 0; i < y.Length; i++)
            {
                int index = sequence.Length - 1 - i;
                if (varMods.GetModificationAt(index) != ushort.MaxValue)
                {
                    if (Tables.modificationList[varMods.GetModificationAt(index)].IsPhosphorylation)
                    {
                        double x = y[i] + MolUtil.MassO + MolUtil.MassC;
                        masses.Add(x);
                        descr.Add(new MsmsPeakAnnotation(MsmsSeriesType.X, i + 1, 1, false));
                        if (sequence[index] != 'Y' && includeNeutralLoss)
                        {
                            double xn = x - 97.976896;
                            masses.Add(xn);
                            descr.Add(new MsmsPeakAnnotation(MsmsSeriesType.X, i + 1, 1, true));
                        }
                    }
                }
            }
            descriptions = descr.ToArray();
            return(masses.ToArray());
        }
Exemplo n.º 2
0
        public string GetModificationClassification(HashSet <string> labelModificationSet)
        {
            PeptideModificationState trueMods = GetTrueModifications(labelModificationSet);

            ushort[] x     = trueMods.GetModifications();
            int      index = -1;
            int      count = 0;

            for (int i = 0; i < x.Length; i++)
            {
                if (x[i] != ushort.MaxValue)
                {
                    count++;
                    index = i;
                }
            }
            if (count == 0)
            {
                return("unmodified");
            }
            if (count > 1)
            {
                return("multiple");
            }
            return("" + x[index] + ";" + sequence[index]);
        }
 public override bool Equals(object anObject)
 {
     if (this == anObject)
     {
         return(true);
     }
     if (anObject is PeptideModificationState)
     {
         PeptideModificationState other = (PeptideModificationState)anObject;
         if (other.GetNTermModification() != GetNTermModification())
         {
             return(false);
         }
         if (other.GetCTermModification() != GetCTermModification())
         {
             return(false);
         }
         if (other.Length != Length)
         {
             return(false);
         }
         for (int i = 0; i < Length; i++)
         {
             if (other.GetModificationAt(i) != GetModificationAt(i))
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
        public static double[] GetNeutralLossBSeries(string sequence, PeptideModificationState fixedMods,
                                                     PeptideModificationState varMods)
        {
            double[] result           = new double[sequence.Length - 1];
            int      neutralLossIndex = -1;

            for (int i = 0; i < sequence.Length - 1; i++)
            {
                if (varMods.GetModificationAt(i) != ushort.MaxValue)
                {
                    if (Tables.modificationList[varMods.GetModificationAt(i)].HasNeutralLoss)
                    {
                        if (Tables.modificationList[varMods.GetModificationAt(i)].IsPhosphorylation && sequence[i] == 'Y')
                        {
                            continue;
                        }
                        neutralLossIndex = i;
                        break;
                    }
                }
            }

            if (neutralLossIndex != -1)
            {
                double[]     b    = GetBSeries(sequence, fixedMods, varMods);
                Modification mod  = Tables.modificationList[varMods.GetModificationAt(neutralLossIndex)];
                double       loss = mod.GetNeutralLoss()[0];
                for (int i = neutralLossIndex; i < sequence.Length - 1; i++)
                {
                    result[i] = b[i] - loss;
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        public static double[] GetNeutralLossXSeries(string sequence, PeptideModificationState fixedMods,
                                                     PeptideModificationState varMods)
        {
            double[] result           = new double[sequence.Length - 1];
            int      neutralLossIndex = -1;

            for (int i = result.Length - 1; i >= 0; i--)
            {
                if (varMods.GetModificationAt(i) != ushort.MaxValue)
                {
                    if (Tables.modificationList[varMods.GetModificationAt(i)].HasNeutralLoss)
                    {
                        neutralLossIndex = i;
                        break;
                    }
                }
            }
            if (neutralLossIndex != -1)
            {
                double[]     x    = GetXSeries(sequence, fixedMods, varMods);
                Modification mod  = Tables.modificationList[varMods.GetModificationAt(neutralLossIndex)];
                double       loss = mod.GetNeutralLoss()[0];
                for (int i = neutralLossIndex; i >= 0; i--)
                {
                    result[i] = x[i] - loss;
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        public static double[] GetYSeries(string sequence, PeptideModificationState fixedMods,
                                          PeptideModificationState varMods)
        {
            double m = MolUtil.YIonMassOffset;

            if (fixedMods.GetCTermModification() != ushort.MaxValue)
            {
                Modification mod = Tables.modificationList[fixedMods.GetCTermModification()];
                m += mod.DeltaMass;
            }
            if (varMods.GetCTermModification() != ushort.MaxValue)
            {
                Modification mod = Tables.modificationList[varMods.GetCTermModification()];
                m += mod.DeltaMass;
            }
            int n = sequence.Length - 1;

            double[] masses = new double[n];
            for (int i = 0; i < masses.Length; i++)
            {
                m += AminoAcid.aaMonoMasses[sequence[n - i]];
                if (fixedMods.GetModificationAt(n - i) != ushort.MaxValue)
                {
                    Modification mod = Tables.modificationList[fixedMods.GetModificationAt(n - i)];
                    m += mod.DeltaMass;
                }
                if (varMods.GetModificationAt(n - i) != ushort.MaxValue)
                {
                    Modification mod = Tables.modificationList[varMods.GetModificationAt(n - i)];
                    m += mod.DeltaMass;
                }
                masses[i] = m;
            }
            return(masses);
        }
Exemplo n.º 7
0
        public PeptideModificationState GetFixedAndLabelModifications(string[] fixedModifications, string sequence)
        {
            PeptideModificationState result = labelModifications.Clone();

            Modification[] fixedMods = Tables.ToModifications(fixedModifications);
            result.ApplyFixedModifications(fixedMods, sequence, true, true);
            return(result);
        }
        public PeptideModificationState Clone()
        {
            PeptideModificationState p = new PeptideModificationState();

            p.modifications     = (ushort[])modifications.Clone();
            p.nTermModification = nTermModification;
            p.cTermModification = cTermModification;
            return(p);
        }
Exemplo n.º 9
0
 public MascotPeptide(string[] peptideInfo, int[] proteinIndex, string[] modstrings)
 {
     mass              = Double.Parse(peptideInfo[1]);
     sequence          = peptideInfo[4].ToUpper();
     modifications     = new PeptideModificationState(peptideInfo[6], modstrings);
     mascotScore       = (float)Double.Parse(peptideInfo[7]);
     this.proteinIndex = proteinIndex;
     deltaMass         = (float)Double.Parse(peptideInfo[2]);
 }
Exemplo n.º 10
0
 public static double[] GetASeries(string sequence, PeptideModificationState fixedMods,
                                   PeptideModificationState varMods)
 {
     double[] masses = GetBSeries(sequence, fixedMods, varMods);
     for (int i = 0; i < masses.Length; i++)
     {
         masses[i] += MolUtil.AIonMassOffset - MolUtil.BIonMassOffset;
     }
     return(masses);
 }
Exemplo n.º 11
0
 public static double[] GetXSeries(string sequence, PeptideModificationState fixedMods,
                                   PeptideModificationState varMods)
 {
     double[] masses = GetYSeries(sequence, fixedMods, varMods);
     for (int i = 0; i < masses.Length; i++)
     {
         masses[i] += MolUtil.MassO + MolUtil.MassC;
     }
     return(masses);
 }
Exemplo n.º 12
0
        public static double CalcMonoisotopicMass(string sequence, PeptideModificationState varMod, Modification[] fixMod)
        {
            double result = AminoAcid.CalcMonoisotopicMass(sequence) + varMod.GetDeltaMass();

            foreach (char c in sequence)
            {
                result += GetDeltaFixed(c, fixMod);
            }
            return(result);
        }
        public PeptideModificationState Revert()
        {
            PeptideModificationState result = Clone();

            for (int i = 0; i < modifications.Length; i++)
            {
                result.modifications[i] = modifications[modifications.Length - 1 - i];
            }
            return(result);
        }
        public PeptideModificationState GetFreshCopy(int len)
        {
            PeptideModificationState result = new PeptideModificationState();

            result.SetNTermModification(ushort.MaxValue);
            result.SetCTermModification(ushort.MaxValue);
            result.modifications = new ushort[len];
            for (int i = 0; i < len; i++)
            {
                result.modifications[i] = ushort.MaxValue;
            }
            return(result);
        }
Exemplo n.º 15
0
 public void Dispose()
 {
     if (sequence != null)
     {
         //sequence.Dispose();
         sequence = null;
     }
     if (modifications != null)
     {
         modifications.Dispose();
         modifications = null;
     }
     proteinIndex = null;
 }
        public static PeptideModificationState Read(BinaryReader reader)
        {
            PeptideModificationState result = new PeptideModificationState();

            result.cTermModification = reader.ReadUInt16();
            result.nTermModification = reader.ReadUInt16();
            int len = reader.ReadInt32();

            result.modifications = new ushort[len];
            for (int i = 0; i < result.modifications.Length; i++)
            {
                result.modifications[i] = reader.ReadUInt16();
            }
            return(result);
        }
Exemplo n.º 17
0
        public MascotPeptide(BinaryReader reader)
        {
            mass          = reader.ReadDouble();
            deltaMass     = reader.ReadSingle();
            sequence      = reader.ReadString();
            modifications = PeptideModificationState.Read(reader);
            mascotScore   = reader.ReadSingle();
            altScore      = reader.ReadSingle();
            pep           = reader.ReadDouble();
            int len = reader.ReadInt32();

            proteinIndex = new int[len];
            for (int i = 0; i < len; i++)
            {
                proteinIndex[i] = reader.ReadInt32();
            }
        }
Exemplo n.º 18
0
 public void Dispose()
 {
     labelModifications = null;
     trueModifications  = null;
     description        = null;
     intensities        = null;
     massDiffs          = null;
     if (modProbabilities != null)
     {
         modProbabilities.Clear();
         modProbabilities = null;
     }
     if (modScoreDiffs != null)
     {
         modScoreDiffs.Clear();
         modScoreDiffs = null;
     }
 }
        public PeptideModificationState GetTrueModifications(HashSet <string> labelModificationSet)
        {
            PeptideModificationState result = GetFreshCopy(Length);

            result.SetNTermModification(GetNTermModification());
            result.SetCTermModification(GetCTermModification());
            for (int i = 0; i < Length; i++)
            {
                ushort m = GetModificationAt(i);
                if (m == ushort.MaxValue || labelModificationSet.Contains(Tables.modificationList[m].Title))
                {
                    result.SetModificationAt(i, ushort.MaxValue);
                }
                else
                {
                    result.SetModificationAt(i, GetModificationAt(i));
                }
            }
            return(result);
        }
Exemplo n.º 20
0
        public void Write(BinaryWriter writer)
        {
            writer.Write(mass);
            writer.Write(deltaMass);
            writer.Write(sequence);
            if (modifications == null)
            {
                modifications = new PeptideModificationState(sequence.Length);
            }
            modifications.Write(writer);
            writer.Write(mascotScore);
            writer.Write(altScore);
            writer.Write(pep);
            int len = proteinIndex.Length;

            writer.Write(len);
            for (int i = 0; i < len; i++)
            {
                writer.Write(proteinIndex[i]);
            }
        }
Exemplo n.º 21
0
        public void CalcPtmScore(double ms2Tol, string ms2TolUnit, int topx, string[] fixedModifications, string sequence, double[] specMasses, float[] specIntensities)
        {
            List <string> fixedMods = new List <string>();

            for (int i = 0; i < fixedModifications.Length; i++)
            {
                fixedMods.Add(fixedModifications[i]);
            }
            ushort[] ltypes = labelModifications.ProjectToCounts().ModificationTypes;
            foreach (ushort ltype in ltypes)
            {
                fixedMods.Add(Tables.modificationList[ltype].Title);
            }
            PeptideModificationCounts c = trueModifications.ProjectToCounts();

            ushort[] ttypes  = c.ModificationTypes;
            string[] varMods = new string[ttypes.Length];
            int[]    tcounts = new int[ttypes.Length];
            for (int i = 0; i < ttypes.Length; i++)
            {
                varMods[i] = Tables.modificationList[ttypes[i]].Title;
                tcounts[i] = c.GetModificationCount(ttypes[i]);
            }
            PeptideModificationState modstr;

            ptmScore = Pscore.CalcPtmScore(ms2Tol, ms2TolUnit, topx, sequence, Tables.ToModifications(fixedMods.ToArray()),
                                           Tables.ToModifications(varMods), tcounts, specMasses, specIntensities,
                                           mz, charge, out ptmScoreFinished, out modstr, out ptmScoreCounts,
                                           out deltaPtmScore, out description, out intensities, out massDiffs,
                                           out modProbabilities,
                                           out modScoreDiffs, false);
            ptmScoreFinished = !ptmScoreFinished;
            changed          = false;
            if (!modstr.Equals(trueModifications))
            {
                changed           = true;
                trueModifications = modstr;
            }
        }
Exemplo n.º 22
0
        public static double Score(double[] specMasses, float[] specIntensities, Peptide pep, double tol, string tolUnit, double mz,
                                   int charge, out MsmsPeakAnnotation[] annot, out float[] intensities, out float[] massDiffs,
                                   int topx, PeptideModificationState modifications)
        {
            MsmsPeakAnnotation[] dummy;
            double p   = Math.Min(6.0 / 100.0, 0.5);
            double lnp = Math.Log(p);
            double lnq = Math.Log(1.0 - p);

            double[] masses = GetCidQueryMasses(pep.Sequence, pep.FixedModifications, modifications, mz, charge, out dummy,
                                                false);


            MsmsPeakAnnotation[] annot1;
            float[] intens1;
            float[] dm1;
            double  score1 = Score(masses, dummy, specMasses, specIntensities, tol, tolUnit, out annot1, out intens1, out dm1, lnp, lnq);

            masses = GetCidQueryMasses(pep.Sequence, pep.FixedModifications, modifications, mz, charge, out dummy,
                                       true);

            MsmsPeakAnnotation[] annot2;
            float[] intens2;
            float[] dm2;
            double  score2 = Score(masses, dummy, specMasses, specIntensities, tol, tolUnit, out annot2, out intens2, out dm2, lnp, lnq);

            if (score2 > score1)
            {
                annot       = annot2;
                intensities = intens2;
                massDiffs   = dm2;
                return(score2);
            }
            annot       = annot1;
            intensities = intens1;
            massDiffs   = dm1;
            return(score1);
        }
        public PeptideModificationState GetLabelModifications(ushort[] fixedMods, string sequence,
                                                              HashSet <string> labelModificationSet)
        {
            PeptideModificationState result = GetFreshCopy(Length);

            for (int i = 0; i < Length; i++)
            {
                ushort m = GetModificationAt(i);
                if (m != ushort.MaxValue && labelModificationSet.Contains(Tables.modificationList[m].Title))
                {
                    result.SetModificationAt(i, GetModificationAt(i));
                }
                else
                {
                    result.SetModificationAt(i, ushort.MaxValue);
                }
            }
            foreach (ushort fixMod in fixedMods)
            {
                if (labelModificationSet.Contains(Tables.modificationList[fixMod].Title))
                {
                    Modification mod = Tables.modificationList[fixMod];
                    for (int j = 0; j < mod.AaCount; j++)
                    {
                        char c = mod.GetAaAt(j);
                        for (int i = 0; i < Length; i++)
                        {
                            if (sequence[i] == c)
                            {
                                result.SetModificationAt(i, mod.Index);
                            }
                        }
                    }
                }
            }
            return(result);
        }
        public PeptideModificationState RemoveLabelModifications(HashSet <string> labelModificationSet)
        {
            PeptideModificationState result = Clone();

            if (nTermModification != ushort.MaxValue &&
                Tables.modificationList[nTermModification].IsLabelModification(labelModificationSet))
            {
                result.nTermModification = ushort.MaxValue;
            }
            if (cTermModification != ushort.MaxValue &&
                Tables.modificationList[cTermModification].IsLabelModification(labelModificationSet))
            {
                result.cTermModification = ushort.MaxValue;
            }
            for (int i = 0; i < modifications.Length; i++)
            {
                if (modifications[i] != ushort.MaxValue &&
                    Tables.modificationList[modifications[i]].IsLabelModification(labelModificationSet))
                {
                    result.modifications[i] = ushort.MaxValue;
                }
            }
            return(result);
        }
Exemplo n.º 25
0
        public static double CalcPtmScore(double ms2Tol, string ms2TolUnit, int topx, string sequence, Modification[] fixedModifications,
                                          Modification[] variableModifications, int[] modCount, double[] specMasses, float[] specIntensities, double mz,
                                          int charge, out bool incomplete, out PeptideModificationState outMods, out int counts,
                                          out double delta, out MsmsPeakAnnotation[] description, out float[] intensities,
                                          out float[] massDiffs, out Dictionary <ushort, double[]> modProb,
                                          out Dictionary <ushort, double[]> modScoreDiffs, bool alternative)
        {
            if (!AminoAcid.ValidSequence(sequence))
            {
                incomplete    = true;
                outMods       = null;
                counts        = 0;
                delta         = 0;
                description   = null;
                intensities   = null;
                massDiffs     = null;
                modProb       = null;
                modScoreDiffs = null;
                return(0);
            }
            Peptide p = new Peptide(sequence);

            p.ApplyFixedModifications(fixedModifications);
            PeptideModificationState[] mpeps = p.ApplyVariableModificationsFixedNumbers(variableModifications, modCount, out incomplete);
            counts = mpeps.Length;
            double maxScore  = -double.MaxValue;
            double maxScore2 = -double.MaxValue;
            PeptideModificationState bestPep = null;

            description = null;
            intensities = null;
            massDiffs   = null;
            double sumScore = 0;

            modProb = new Dictionary <ushort, double[]>();
            Dictionary <ushort, double[, ]> scoreDiffs = new Dictionary <ushort, double[, ]>();

            ushort[]         w  = mpeps[0].GetModifications();
            HashSet <ushort> um = new HashSet <ushort>();

            foreach (ushort x in w)
            {
                if (x != ushort.MaxValue && !um.Contains(x))
                {
                    um.Add(x);
                }
            }
            ushort[] uniqueMods = um.ToArray();
            foreach (ushort m in uniqueMods)
            {
                if (!modProb.ContainsKey(m))
                {
                    modProb.Add(m, new double[w.Length]);
                    scoreDiffs.Add(m, new double[2, w.Length]);
                }
            }
            foreach (PeptideModificationState mpep in mpeps)
            {
                MsmsPeakAnnotation[] desc;
                float[] intens;
                float[] dm;
                double  score = Score(specMasses, specIntensities, p, ms2Tol, ms2TolUnit, mz, charge,
                                      out desc, out intens, out dm, topx, mpep);
                ushort[] mm = mpep.GetModifications();
                double   x  = Math.Exp((score - 100) * NumUtil.log10 / 10.0);
                for (int i = 0; i < mm.Length; i++)
                {
                    if (mm[i] != ushort.MaxValue)
                    {
                        modProb[mm[i]][i] += x;
                    }
                    foreach (ushort mod in uniqueMods)
                    {
                        if (mm[i] == mod)
                        {
                            if (score > scoreDiffs[mod][0, i])
                            {
                                scoreDiffs[mod][0, i] = score;
                            }
                        }
                        else
                        {
                            if (score > scoreDiffs[mod][1, i])
                            {
                                scoreDiffs[mod][1, i] = score;
                            }
                        }
                    }
                }
                sumScore += x;
                if (score > maxScore)
                {
                    maxScore2   = maxScore;
                    maxScore    = score;
                    bestPep     = mpep;
                    description = desc;
                    intensities = intens;
                    massDiffs   = dm;
                }
                else if (score > maxScore2)
                {
                    maxScore2 = score;
                }
            }
            modScoreDiffs = new Dictionary <ushort, double[]>();
            foreach (ushort mod in uniqueMods)
            {
                Modification modi = Tables.modificationList[mod];
                modScoreDiffs.Add(mod, new double[w.Length]);
                for (int i = 0; i < sequence.Length; i++)
                {
                    char aa = sequence[i];
                    if (modi.HasAA(aa))
                    {
                        modScoreDiffs[mod][i] = scoreDiffs[mod][0, i] - scoreDiffs[mod][1, i];
                    }
                    else
                    {
                        modScoreDiffs[mod][i] = double.NaN;
                    }
                }
            }
            foreach (double[] y in modProb.Values)
            {
                for (int i = 0; i < y.Length; i++)
                {
                    y[i] /= sumScore;
                }
            }
            if (maxScore2 == -double.MaxValue)
            {
                delta = maxScore;
            }
            else
            {
                delta = maxScore - maxScore2;
            }
            outMods = bestPep;
            return(maxScore);
        }
Exemplo n.º 26
0
        public MsmsHit(MascotPeptide[] peptides, int scanNumber, int fileIndex, MascotQueryType type,
                       int silacIndex, double elutionTime, double mz, double monoisotopicMz, ushort[] fixedMods,
                       HashSet <string> labelModificationSet, SilacType silacType, SilacLabel[] labels1, SilacLabel[] labels2)
        {
            rawFileIndex    = fileIndex;
            this.scanNumber = scanNumber;
            this.silacIndex = silacIndex;
            this.type       = type;
            pep             = peptides[0].Pep;
            score           = peptides[0].MascotScore;
            altScore        = peptides[0].AltScore;
            charge          = (int)Math.Round(peptides[0].Mass / mz);
            massErrorPpm    = peptides[0].MassErrorPpm;
            if (peptides.Length > 1)
            {
                deltaScoreAll = peptides[0].MascotScore - peptides[1].MascotScore;
            }
            else
            {
                deltaScoreAll = peptides[0].MascotScore;
            }
            int ind = -1;

            for (int i = 1; i < peptides.Length; i++)
            {
                if (!peptides[i].Sequence.Equals(peptides[0].Sequence))
                {
                    ind = i;
                    break;
                }
            }
            if (ind != -1)
            {
                deltaScoreDifferentPep = peptides[0].MascotScore - peptides[ind].MascotScore;
            }
            else
            {
                deltaScoreDifferentPep = peptides[0].MascotScore;
            }
            labelModifications =
                peptides[0].Modifications.GetLabelModifications(fixedMods, peptides[0].Sequence, labelModificationSet);
            trueModifications   = peptides[0].Modifications.GetTrueModifications(labelModificationSet);
            this.elutionTime    = elutionTime;
            this.mz             = mz;
            this.monoisotopicMz = monoisotopicMz;
            if (silacType == SilacType.Singlets)
            {
                this.silacIndex = 0;
            }
            else if (type != MascotQueryType.Silac)
            {
                AminoAcid[] allAas     = T07SearchEngineEnhancement.CalcAllAas(silacType, labels1, labels2);
                char[]      allAaLetts = AminoAcid.GetSingleLetters(allAas);
                for (int i = 0; i < allAaLetts.Length; i++)
                {
                    this.silacIndex =
                        CalcSilacIndex(allAaLetts[i], labelModifications, peptides[0].Sequence, silacType, labels1,
                                       labels2);
                    if (this.silacIndex != -1)
                    {
                        break;
                    }
                }
            }
        }
Exemplo n.º 27
0
        public MsmsHit(BinaryReader reader)
        {
            rawFileIndex = reader.ReadInt32();
            scanNumber   = reader.ReadInt32();
            silacIndex   = reader.ReadInt32();
            byte x = reader.ReadByte();

            switch (x)
            {
            case 0:
                type = MascotQueryType.Silac;
                break;

            case 1:
                type = MascotQueryType.Isotope;
                break;

            case 2:
                type = MascotQueryType.Peak;
                break;
            }
            pep                    = reader.ReadDouble();
            score                  = reader.ReadDouble();
            altScore               = reader.ReadDouble();
            deltaScoreAll          = reader.ReadDouble();
            deltaScoreDifferentPep = reader.ReadDouble();
            labelModifications     = PeptideModificationState.Read(reader);
            trueModifications      = PeptideModificationState.Read(reader);
            elutionTime            = reader.ReadDouble();
            id               = reader.ReadInt32();
            mz               = reader.ReadDouble();
            monoisotopicMz   = reader.ReadDouble();
            evidenceId       = reader.ReadInt32();
            ptmScore         = reader.ReadDouble();
            deltaPtmScore    = reader.ReadDouble();
            ptmScoreCounts   = reader.ReadInt32();
            ptmScoreFinished = reader.ReadBoolean();
            massErrorPpm     = reader.ReadDouble();
            changed          = reader.ReadBoolean();
            int len = reader.ReadInt32();

            description = new MsmsPeakAnnotation[len];
            intensities = new float[len];
            massDiffs   = new float[len];
            for (int i = 0; i < len; i++)
            {
                description[i] = new MsmsPeakAnnotation(reader);
                intensities[i] = reader.ReadSingle();
                massDiffs[i]   = reader.ReadSingle();
            }
            charge           = reader.ReadInt32();
            modProbabilities = new Dictionary <ushort, double[]>();
            len = reader.ReadInt32();
            ushort[] keys = new ushort[len];
            for (int i = 0; i < keys.Length; i++)
            {
                keys[i] = reader.ReadUInt16();
            }
            foreach (ushort key in keys)
            {
                len = reader.ReadInt32();
                double[] value = new double[len];
                for (int i = 0; i < value.Length; i++)
                {
                    value[i] = reader.ReadDouble();
                }
                modProbabilities.Add(key, value);
            }
            modScoreDiffs = new Dictionary <ushort, double[]>();
            len           = reader.ReadInt32();
            keys          = new ushort[len];
            for (int i = 0; i < keys.Length; i++)
            {
                keys[i] = reader.ReadUInt16();
            }
            foreach (ushort key in keys)
            {
                len = reader.ReadInt32();
                double[] value = new double[len];
                for (int i = 0; i < value.Length; i++)
                {
                    value[i] = reader.ReadDouble();
                }
                modScoreDiffs.Add(key, value);
            }
        }
Exemplo n.º 28
0
 private static int CalcSilacIndex(char aa, PeptideModificationState labelMods, string sequence, SilacType type,
                                   SilacLabel[] labels1, SilacLabel[] labels2)
 {
     for (int i = 0; i < sequence.Length; i++)
     {
         if (sequence[i] != aa)
         {
             continue;
         }
         ushort m = labelMods.GetModificationAt(i);
         if (type == SilacType.Doublets)
         {
             if (m != ushort.MaxValue)
             {
                 return(1);
             }
             return(0);
         }
         if (type == SilacType.Triplets)
         {
             int ind1 = -1;
             for (int j = 0; j < labels1.Length; j++)
             {
                 if (AminoAcid.GetAminoAcidFromLabel(labels1[j]).Letter == aa)
                 {
                     ind1 = j;
                 }
             }
             int ind2 = -1;
             for (int j = 0; j < labels2.Length; j++)
             {
                 if (AminoAcid.GetAminoAcidFromLabel(labels2[j]).Letter == aa)
                 {
                     ind2 = j;
                 }
             }
             if (ind1 == -1 && ind2 == -1)
             {
                 return(-1);
             }
             if (ind1 == -1)
             {
                 if (m != ushort.MaxValue)
                 {
                     return(2);
                 }
                 return(-1);
             }
             if (ind2 == -1)
             {
                 if (m != ushort.MaxValue)
                 {
                     return(1);
                 }
                 return(-1);
             }
             SilacLabel l1 = labels1[ind1];
             SilacLabel l2 = labels2[ind2];
             if (l1 == l2)
             {
                 if (m == ushort.MaxValue)
                 {
                     return(0);
                 }
                 return(-1);
             }
             if (m == ushort.MaxValue)
             {
                 return(0);
             }
             if (Tables.modifications[AminoAcid.GetMascotModificationStringForLabel(l1)].Index == m)
             {
                 return(1);
             }
             if (Tables.modifications[AminoAcid.GetMascotModificationStringForLabel(l2)].Index == m)
             {
                 return(2);
             }
             throw new Exception("Never get here.");
         }
         throw new Exception("Should never happen.");
     }
     return(-1);
 }
Exemplo n.º 29
0
        public static double[] GetCidQueryMasses(string sequence, PeptideModificationState fixedMods,
                                                 PeptideModificationState varMods, double mz, int charge,
                                                 out MsmsPeakAnnotation[] description, bool includeNeutralLoss)
        {
            List <double>             masses       = new List <double>();
            List <MsmsPeakAnnotation> descriptions = new List <MsmsPeakAnnotation>();

            double[] y = GetYSeries(sequence, fixedMods, varMods);
            for (int i = 0; i < y.Length; i++)
            {
                double yval = y[i];
                masses.Add(yval);
                descriptions.Add(new MsmsPeakAnnotation(MsmsSeriesType.Y, i + 1, 1, false));
            }
            if (includeNeutralLoss)
            {
                double[] yn = GetNeutralLossYSeries(sequence, fixedMods, varMods);
                for (int i = 1; i < yn.Length; i++)
                {
                    if (yn[i] > 0)
                    {
                        masses.Add(yn[i]);
                        descriptions.Add(new MsmsPeakAnnotation(MsmsSeriesType.Y, i + 1, 1, true));
                    }
                }
            }
            if (charge > 2)
            {
                for (int i = 0; i < y.Length; i++)
                {
                    if (y[i] > 700)
                    {
                        double yval = y[i];
                        double y2   = (yval + MolUtil.MassProton) / 2;
                        masses.Add(y2);
                        descriptions.Add(new MsmsPeakAnnotation(MsmsSeriesType.Y, i + 1, 2, false));
                    }
                }
            }
            MsmsPeakAnnotation[] dx;
            double[]             x = GetPhosphoXSeries(sequence, fixedMods, varMods, out dx, includeNeutralLoss);
            for (int i = 0; i < x.Length; i++)
            {
                masses.Add(x[i]);
                descriptions.Add(dx[i]);
            }
            double[] a = GetASeries(sequence, fixedMods, varMods);
            if (a.Length > 1)
            {
                masses.Add(a[1]);
                descriptions.Add(new MsmsPeakAnnotation(MsmsSeriesType.A, 2, 1, false));
            }
            double[] b = GetBSeries(sequence, fixedMods, varMods);
            for (int i = 1; i < b.Length; i++)
            {
                masses.Add(b[i]);
                descriptions.Add(new MsmsPeakAnnotation(MsmsSeriesType.B, i + 1, 1, false));
            }
            if (includeNeutralLoss)
            {
                double[] bn = GetNeutralLossBSeries(sequence, fixedMods, varMods);
                for (int i = 1; i < bn.Length; i++)
                {
                    if (bn[i] > 0)
                    {
                        masses.Add(bn[i]);
                        descriptions.Add(new MsmsPeakAnnotation(MsmsSeriesType.B, i + 1, 1, true));
                    }
                }
            }
            description = descriptions.ToArray();
            return(masses.ToArray());
        }