Example #1
0
        public static void SetPep(Identifications identifications, BayesianInversion2D bi)
        {
            int n = identifications.Count;

            for (int i = 0; i < n; i++)
            {
                MascotPeptide p = identifications.GetPeptidesAt(i)[0];
                p.Pep = bi.GetValue(p.AltScore, Math.Log(p.Sequence.Length));
            }
            identifications.Write();
        }
Example #2
0
        public static void CollectSequences(Identifications identifications, double peptidePep,
                                            HashSet <string> sequences)
        {
            int n = identifications.Count;

            for (int i = 0; i < n; i++)
            {
                MascotPeptide p = identifications.GetPeptidesAt(i)[0];
                if ((p.Pep <= peptidePep) || (double.IsNaN(p.Pep) && double.IsNaN(peptidePep)))
                {
                    sequences.Add(p.Sequence);
                }
            }
        }
Example #3
0
 private static void LimitPep(string[] rawFiles, MascotQueryType type, IIdentificationProvider ip)
 {
     for (int i = 0; i < rawFiles.Length; i++)
     {
         Identifications ident = ip.GetIdentifications(rawFiles[i], type);
         int             n     = ident.Count;
         for (int j = 0; j < n; j++)
         {
             MascotPeptide p = ident.GetPeptidesAt(j)[0];
             p.Pep = Math.Min(p.Pep, 1);
         }
         ident.Write();
         ip.Dispose();
     }
 }
Example #4
0
        public static void ApplyReverseHitThreshold(Identifications identifications, double pepThreshold)
        {
            int        n = identifications.Count;
            List <int> o = new List <int>();

            for (int i = 0; i < n; i++)
            {
                MascotPeptide p = identifications.GetPeptidesAt(i)[0];
                if (p.Pep <= pepThreshold)
                {
                    o.Add(i);
                }
            }
            identifications.Extract(o.ToArray());
            identifications.Write();
        }
Example #5
0
        public static void FilterBySequence(Identifications identifications, HashSet <string> sequences)
        {
            int        n  = identifications.Count;
            List <int> oo = new List <int>();

            for (int i = 0; i < n; i++)
            {
                MascotPeptide p = identifications.GetPeptidesAt(i)[0];
                if (sequences.Contains(p.Sequence))
                {
                    oo.Add(i);
                }
            }
            identifications.Extract(oo.ToArray());
            identifications.Write();
        }
Example #6
0
        public static double FindReverseHitThresholdValue(Identifications identifications, double totalPeptideFDR,
                                                          string reverseStr, IProteinSet proteinSet)
        {
            int n = identifications.Count;

            if (n == 0)
            {
                return(1);
            }
            double[] peps    = new double[n];
            bool[]   correct = new bool[n];
            for (int i = 0; i < n; i++)
            {
                MascotPeptide p = identifications.GetPeptidesAt(i)[0];
                peps[i]    = p.Pep;
                correct[i] = !p.HasOnlyReverseHits(reverseStr, proteinSet);
            }
            int[]         o            = ArrayUtil.Order(peps);
            double        forwardCount = 0;
            List <double> validPeps    = new List <double>();

            for (int i = 0; i < n; i++)
            {
                int index = o[i];
                if (correct[index])
                {
                    forwardCount++;
                }
                double reverseCount = (i + 1) - forwardCount;
                if (reverseCount / forwardCount <= totalPeptideFDR)
                {
                    validPeps.Add(peps[index]);
                }
            }
            if (validPeps.Count > 0)
            {
                return(ArrayUtil.Max(validPeps.ToArray()));
            }
            return(0);
        }