Ejemplo n.º 1
0
 public Queries(DBOptions dbOptions)
     : base()
 {
     MaxMZ = double.MinValue;
     MinMZ = double.MaxValue;
     MaxRt = double.MinValue;
     MinRt = double.MaxValue;
     //this.sample = sample;
     this.dbOptions = dbOptions;
     Precursors     = new Precursors();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor used for Unit tests
 /// </summary>
 /// <param name="masses"></param>
 public Queries(DBOptions options, double[] masses)
 {
     Precursors = new Precursors();
     foreach (double mass in masses)
     {
         Precursor precursor = new Precursor();
         precursor.Mass = mass;
         Add(new Query(options, null, null, precursor));
         Precursors.Add(precursor);
     }
 }
Ejemplo n.º 3
0
 public Result()
 {
     queries           = new Queries();
     precursors        = new Precursors();
     matchedPrecursors = new Precursors();
     clusters          = new GraphML_List <Cluster>();
     peptides          = new PeptideMatches(new PeptideMatch[0]);
     peptideSequences  = new PeptideMatches(new PeptideMatch[0]);
     proteins          = new ProteinGroupMatches();
     dbOptions         = new DBOptions("");
     samples           = new Samples();
 }
Ejemplo n.º 4
0
        public long SetPrecursors(Precursors precursors)
        {
            this.precursors        = precursors;
            this.matchedPrecursors = new Precursors();
            long nbTargets = 0;

            foreach (Precursor precursor in precursors)
            {
                if (precursor.psms != null && precursor.psms.Count > 0)
                {
                    if (precursor.Target)
                    {
                        nbTargets++;
                    }
                    matchedPrecursors.Add(precursor);
                }
            }
            return(nbTargets);
        }
Ejemplo n.º 5
0
        public GraphML_List <Cluster> Search(Precursors precursors, bool runCluster)
        {
            options.ConSole.WriteLine("Grouping precursors based on common features...");
            precursors.Sort(Precursor.CompareProbabilityScore);

            GraphML_List <Cluster> clusters = new GraphML_List <Cluster>();

            bool[] done = new bool[precursors.Count];
            for (int i = 0; i < done.Length; i++)
            {
                done[i] = false;
            }

            //Step 1 : Regroup psms based on mz/rt/intensity/Sequence proximity score (ProteoProfile Code)
            for (int i = 0; i < precursors.Count; i++)
            {
                if (!done[i])
                {
                    Cluster group = new Cluster(samples);
                    group.Add(precursors[i]);
                    if (runCluster)
                    {
                        for (int j = i + 1; j < precursors.Count; j++)
                        {
                            if (!done[j] && precursors[i].sample != precursors[j].sample)
                            {
                                double score = Score(precursors[i], precursors[j]);
                                //TODO Implement ProteoProfile Clustering algorithm, or anything on the litterature, as long as its backed by the scoring function
                                if (score > 0.75)//TODO Should we put a threshold here? Can it be computed dynamically?
                                {
                                    group.Add(precursors[j]);
                                    done[j] = true;
                                }
                            }
                        }
                    }
                    clusters.Add(group);
                }
            }
            options.ConSole.WriteLine("Created " + clusters.Count + " clusters");
            return(clusters);
            //TODO I should not use psms in more than one cluster...
        }
Ejemplo n.º 6
0
        public void Export(double fdr, string keyword = "", bool onlyPrecursors = false)
        {
            dbOptions.ConSole.WriteLine("Exporting at " + (fdr * 100) + "% FDR (Decoy/Target)...");

            List <Precursor> prec = null;

            if (precursors != null)
            {
                if (matchedPrecursors == null)
                {
                    this.matchedPrecursors = new Precursors();
                    foreach (Precursor precursor in precursors)
                    {
                        if (precursor.psms.Count > 0)
                        {
                            matchedPrecursors.Add(precursor);
                        }
                    }
                }/*
                  * List<Precursor> prec = FDR.PrecursorsV2(precursors, fdr, 1);
                  * Sol.CONSOLE.OutputLine(">   " + prec.Count + " Precursors");
                  * MSSearcher.Export(dbOptions.outputFolder + keyword + "precursors.csv", prec);//*/
                 /*
                  * prec = Optimizer.PrecursorOptimizer(matchedPrecursors, fdr);
                  * Sol.CONSOLE.OutputLine(">   " + prec.Count + " Optimized Precursors");
                  * MSSearcher.Export(dbOptions.outputFolder + keyword + "Optimized_precursors.csv", prec);//*/

                prec = matchedPrecursors.ComputeAtFDR(fdr);
                dbOptions.ConSole.WriteLine(">   " + prec.Count + " Uptimized V5 Precursors");
                MSSearcher.Export(dbOptions.OutputFolder + keyword + "UptimizedV5_precursors.csv", prec);
            }

            if (!onlyPrecursors)
            {
                if (queries != null)
                {
                    List <Query> qs = queries.ComputeAtFDR(fdr);
                    dbOptions.ConSole.WriteLine(">   " + qs.Count + " PSMs (Top 10)");
                    MSSearcher.Export(dbOptions.OutputFolder + keyword + "queries.csv", qs);
                }
                if (clusters != null)
                {
                    //List<PeptideSpectrumMatch> psms = FDR.PSMs(clusters, fdr, 1, 10);
                    //dbOptions.ConSole.WriteLine(">   " + psms.Count + " PSMs (Top 10)");
                    //MSSearcher.Export(dbOptions.outputFolder + keyword + "psms_Top10.csv", psms);

                    //psms = FDR.PSMs(clusters, fdr, 1, 1);
                    //dbOptions.ConSole.WriteLine(">   " + psms.Count + " PSMs");
                    //MSSearcher.Export(dbOptions.outputFolder + keyword + "psms_Best.csv", psms);
                }

                if (peptides != null)
                {
                    List <PeptideMatch> pep = peptideSequences.ComputeAtFDR(fdr);
                    dbOptions.ConSole.WriteLine(">   " + pep.Count + " Peptides Sequences (Version 5)");
                    PeptideSearcher.Export(dbOptions.OutputFolder + keyword + "peptideSequencesV5_.csv", pep);

                    PeptideSearcher sr   = new PeptideSearcher(dbOptions);
                    PeptideMatches  seqs = sr.Search(clusters, prec, false);
                    pep = seqs.ComputeAtFDR(fdr);
                    dbOptions.ConSole.WriteLine(">   " + pep.Count + " Peptides Sequences (Version 5b)");
                    PeptideSearcher.Export(dbOptions.OutputFolder + keyword + "peptideSequencesV5b_PrecursorFDRed.csv", pep);

                    pep = peptides.ComputeAtFDR(fdr);
                    dbOptions.ConSole.WriteLine(">   " + pep.Count + " Peptides (Version 5)");
                    PeptideSearcher.Export(dbOptions.OutputFolder + keyword + "peptidesV5_.csv", pep);
                }
                if (proteins != null)
                {
                    List <ProteinGroupMatch> prots = proteins.ComputeAtFDR(fdr);
                    dbOptions.ConSole.WriteLine(">   " + prots.Count + " Proteins");
                    ProteinSearcher.Export(dbOptions.OutputFolder + keyword + "proteins_.csv", prots);
                }
            }
        }
Ejemplo n.º 7
0
 public Queries()
 {
     Precursors = new Precursors();
 }