Exemplo n.º 1
0
        private void Run()
        {
            richTextBox1.Clear();
            string rawFolder = txtRawFolder.Text;

            List <string>       csvFilepaths       = new List <string>(lstOmssaCsvFiles.Items.Cast <string>());
            List <Modification> fixedModifications = new List <Modification>(from ListViewItem checkedItem in lstSelectedFixedModifications.Items select(Modification) checkedItem.Tag);

            double            maxFalseDiscoveryRate = (double)numMaximumFalseDiscoveryRate.Value;
            double            maxPPM            = (double)maximumPPMUD.Value;
            bool              isBatched         = checkBox1.Checked;
            bool              is2DFDR           = twoDCB.Checked;
            bool              includeFixedMods  = checkBox2.Checked;
            UniquePeptideType uniquePeptideType = (UniquePeptideType)comboBox1.SelectedValue;
            string            outputFolder      = txtOutputFolder.Text;

            if (string.IsNullOrEmpty(outputFolder))
            {
                MessageBox.Show("Output folder must be specified");
                return;
            }

            Directory.CreateDirectory(outputFolder);

            FdrOptimizer fdrOptimizer = new FdrOptimizer(csvFilepaths, rawFolder,
                                                         fixedModifications,
                                                         maxFalseDiscoveryRate, maxPPM, uniquePeptideType,
                                                         outputFolder, isBatched, is2DFDR, includeFixedMods);

            fdrOptimizer.UpdateProgress += HandleUpdateProgress;
            fdrOptimizer.Finished       += fdrOptimizer_Finished;
            fdrOptimizer.UpdateLog      += fdrOptimizer_UpdateLog;

            prgProgress.Value = prgProgress.Minimum;

            btnOK.Enabled = false;
            Thread thread = new Thread(fdrOptimizer.Optimize)
            {
                IsBackground = true
            };

            thread.Start();
        }
Exemplo n.º 2
0
 public FdrOptimizer(IList<string> csvFilepaths, string rawFolder,
     IList<Modification> fixedModifications,
     double maximumFalseDiscoveryRate,
     double maximumPPMError,           
     UniquePeptideType uniquePeptideType,
     string outputFolder, bool isBatched = false, bool is2DFDR = true, bool includeFixedMods = false,  double evalueThresholdForPPMError = 1e-2)
 {
     _csvFilepaths = csvFilepaths;
     _rawFolder = rawFolder;
     _fixedModifications = fixedModifications;
     _maximumFalseDiscoveryRate = maximumFalseDiscoveryRate/100.0;
     _maximumPPMError = maximumPPMError;
     _uniquePeptideType = uniquePeptideType;
     _outputFolder = outputFolder;
     _outputPsmFolder = Path.Combine(outputFolder, "psms");
     _outputPeptideFolder = Path.Combine(outputFolder, "peptides");
     _outputScansFolder = Path.Combine(outputFolder, "scans");
     _isBatched = isBatched;
     _is2DFDR = is2DFDR;
     _includeFixedMods = includeFixedMods;
     _evalueThresholdPPMError = evalueThresholdForPPMError;
 }
Exemplo n.º 3
0
 public FdrOptimizer(IList <string> csvFilepaths, string rawFolder,
                     IList <Modification> fixedModifications,
                     double maximumFalseDiscoveryRate,
                     double maximumPPMError,
                     UniquePeptideType uniquePeptideType,
                     string outputFolder, bool isBatched = false, bool is2DFDR = true, bool includeFixedMods = false, double evalueThresholdForPPMError = 1e-2)
 {
     _csvFilepaths              = csvFilepaths;
     _rawFolder                 = rawFolder;
     _fixedModifications        = fixedModifications;
     _maximumFalseDiscoveryRate = maximumFalseDiscoveryRate / 100.0;
     _maximumPPMError           = maximumPPMError;
     _uniquePeptideType         = uniquePeptideType;
     _outputFolder              = outputFolder;
     _outputPsmFolder           = Path.Combine(outputFolder, "psms");
     _outputPeptideFolder       = Path.Combine(outputFolder, "peptides");
     _outputScansFolder         = Path.Combine(outputFolder, "scans");
     _isBatched                 = isBatched;
     _is2DFDR                 = is2DFDR;
     _includeFixedMods        = includeFixedMods;
     _evalueThresholdPPMError = evalueThresholdForPPMError;
 }
Exemplo n.º 4
0
        private void ReducePsms(IList<InputFile> csvFiles, UniquePeptideType uniquePeptideType, bool isBatched = false)
        {
            string msg = "Converting PSMs into unique peptides based ";
            IEqualityComparer<Peptide> comparer;
            switch (uniquePeptideType)
            {
                default:
                    msg += "on sequence only";
                    comparer = new SequenceComparer();
                    break;
                case UniquePeptideType.Mass:
                    msg += "on mass";
                    comparer = new MassComparer();
                    break;
                case UniquePeptideType.SequenceAndModifications:
                    msg += "on sequence and positional modifications";
                    comparer = new SequenceModComparer();
                    break;
                case UniquePeptideType.SequenceAndModLocations:
                    msg += "on sequence and modification locations";
                    comparer = new SequenceAndModPositionComparer();
                    break;
                case UniquePeptideType.SequenceAndMass:
                    msg += "on sequence and mass";
                    comparer = new SequenceMassComparer();
                    break;
                case UniquePeptideType.Nothing:
                    msg += "on nothing (no reduction)";
                    comparer = new IdentityComparer<Peptide>();
                    break;
            }
            Log(msg);

            foreach (InputFile csvFile in csvFiles)
            {
                csvFile.ReducePsms(comparer);
                Log(string.Format("{0:N0} unique peptides remain from {1:N0} PSMs from {2}", csvFile.Peptides.Count, csvFile.PeptideSpectralMatches.Count, csvFile.Name));
            }

            if (!isBatched)
                return;

            Dictionary<Peptide, Peptide> peptideDictionary = new Dictionary<Peptide, Peptide>(comparer);
            foreach (Peptide peptide in csvFiles.SelectMany(csvFile => csvFile.Peptides))
            {
                Peptide realPeptide;
                if (peptideDictionary.TryGetValue(peptide, out realPeptide))
                {
                    foreach (PSM psm in peptide.PSMs)
                    {
                        realPeptide.AddPsm(psm);
                    }
                }
                else
                {
                    Peptide newPeptide = new Peptide(peptide);
                    peptideDictionary.Add(newPeptide, newPeptide);
                }
            }
            _allPeptides = peptideDictionary.Values.ToList();
            Log(string.Format("{0:N0} unique peptides from all files [Batched]", _allPeptides.Count));
        }
Exemplo n.º 5
0
        private void ReducePsms(IList <InputFile> csvFiles, UniquePeptideType uniquePeptideType, bool isBatched = false)
        {
            string msg = "Converting PSMs into unique peptides based ";
            IEqualityComparer <Peptide> comparer;

            switch (uniquePeptideType)
            {
            default:
                msg     += "on sequence only";
                comparer = new SequenceComparer();
                break;

            case UniquePeptideType.Mass:
                msg     += "on mass";
                comparer = new MassComparer();
                break;

            case UniquePeptideType.SequenceAndModifications:
                msg     += "on sequence and positional modifications";
                comparer = new SequenceModComparer();
                break;

            case UniquePeptideType.SequenceAndModLocations:
                msg     += "on sequence and modification locations";
                comparer = new SequenceAndModPositionComparer();
                break;

            case UniquePeptideType.SequenceAndMass:
                msg     += "on sequence and mass";
                comparer = new SequenceMassComparer();
                break;

            case UniquePeptideType.Nothing:
                msg     += "on nothing (no reduction)";
                comparer = new IdentityComparer <Peptide>();
                break;
            }
            Log(msg);

            foreach (InputFile csvFile in csvFiles)
            {
                csvFile.ReducePsms(comparer);
                Log(string.Format("{0:N0} unique peptides remain from {1:N0} PSMs from {2}", csvFile.Peptides.Count, csvFile.PeptideSpectralMatches.Count, csvFile.Name));
            }

            if (!isBatched)
            {
                return;
            }

            Dictionary <Peptide, Peptide> peptideDictionary = new Dictionary <Peptide, Peptide>(comparer);

            foreach (Peptide peptide in csvFiles.SelectMany(csvFile => csvFile.Peptides))
            {
                Peptide realPeptide;
                if (peptideDictionary.TryGetValue(peptide, out realPeptide))
                {
                    foreach (PSM psm in peptide.PSMs)
                    {
                        realPeptide.AddPsm(psm);
                    }
                }
                else
                {
                    Peptide newPeptide = new Peptide(peptide);
                    peptideDictionary.Add(newPeptide, newPeptide);
                }
            }
            _allPeptides = peptideDictionary.Values.ToList();
            Log(string.Format("{0:N0} unique peptides from all files [Batched]", _allPeptides.Count));
        }