public void TestBuild()
        {
            List <IIdentifiedSpectrum> spectra = new SequestPeptideTextFormat().ReadFromFile(TestContext.CurrentContext.TestDirectory + "/../../../data/TestBuilder.peptides");

            Assert.AreEqual(4, spectra.Count);

            IAccessNumberParser parser = AccessNumberParserFactory.FindOrCreateParser(@"(IPI\d+)", "IPI");

            List <IIdentifiedProtein> proteins = new IdentifiedProteinBuilder().Build(spectra);

            Assert.AreEqual(4, proteins.Count);

            List <IIdentifiedProteinGroup> groups = new IdentifiedProteinGroupBuilder().Build(proteins);

            Assert.AreEqual(2, groups.Count);

            Assert.AreEqual(1, groups[0].Count);
            Assert.AreEqual("IPI:IPI00784154.1|SW", groups[0][0].Name);

            Assert.AreEqual(2, groups[1].Count);
            Assert.AreEqual("REVERSED_00000001", groups[1][0].Name);
            Assert.AreEqual("REVERSED_00000002", groups[1][1].Name);

            IIdentifiedResult result = new IdentifiedResultBuilder(parser, "").Build(groups);
        }
Esempio n. 2
0
        public ITraqUniquePeptideStatisticBuilderUI()
        {
            InitializeComponent();

            base.SetFileArgument("PeptidesFile", new OpenFileArgument("Peptides", "peptides"));

            fastaFile.FileArgument = new OpenFileArgument("Database", "fasta");
            parsers = new RcpaComboBox <IAccessNumberParser>(cbAccessNumberParser, "AccessNumberParser", AccessNumberParserFactory.GetParsers().ToArray(), 0);
            AddComponent(parsers);

            this.Text = Constants.GetSQHTitle(title, version);
        }
    public ProteinLabelFreeQuantificationBuilderUI()
    {
      InitializeComponent();

      SetFileArgument("ProteinFile", new OpenFileArgument("Protein", new string[] { "noredundant", "unduplicated" }));

      calculators = new RcpaComboBox<IProteinLabelfreeQuantificationCalculator>(
        cbFilterType,
        "LabelfreeQuantificationCalculator",
        new IProteinLabelfreeQuantificationCalculator[] { 
          new NSAFProteinLabelfreeQuantificationCalculator(),
          new SInProteinLabelfreeQuantificationCalculator()
        },
        0);
      AddComponent(calculators);

      this.parsers = new RcpaComboBox<IAccessNumberParser>(cbAccessNumberParser, "Parser", AccessNumberParserFactory.GetParsers().ToArray(), 0);
      AddComponent(this.parsers);

      AddComponent(pnlClassification);

      this.Text = Constants.GetSQHTitle(title, version);
    }
Esempio n. 4
0
        protected override IEnumerable <string> DoProcess(string filename, List <string> result, Dictionary <IFilter <IIdentifiedSpectrum>, SpectrumEntry> map)
        {
            string database = filename + ".fasta";

            if (!File.Exists(database))
            {
                throw new Exception("Fasta file not exists : " + database);
            }

            IAccessNumberParser           acParser = AccessNumberParserFactory.GuessParser(database);
            Dictionary <string, Sequence> seqMap   = DatabaseUtils.GetAccessNumberMap(database, acParser);

            try
            {
                using (IdentifiedProteinGroupEnumerator iter = new IdentifiedProteinGroupEnumerator(filename))
                {
                    foreach (IFilter <IIdentifiedSpectrum> filter in map.Keys)
                    {
                        SpectrumEntry entry = map[filter];
                        entry.ResultWriter.WriteLine(iter.ProteinFormat.GetHeader());
                        entry.ResultWriter.WriteLine(iter.PeptideFormat.GetHeader());
                    }

                    while (iter.MoveNext())
                    {
                        IIdentifiedProteinGroup group = iter.Current;

                        List <IIdentifiedSpectrum> spectra = group[0].GetSpectra();

                        foreach (IFilter <IIdentifiedSpectrum> filter in map.Keys)
                        {
                            SpectrumEntry entry = map[filter];
                            entry.Spectra.Clear();

                            foreach (IIdentifiedSpectrum spectrum in spectra)
                            {
                                if (filter.Accept(spectrum))
                                {
                                    entry.Spectra.Add(spectrum);
                                }
                            }

                            if (entry.Spectra.Count > 0)
                            {
                                for (int i = 0; i < group.Count; i++)
                                {
                                    entry.ResultWriter.WriteLine("${0}-{1}{2}", group.Index, i + 1, iter.ProteinFormat.GetString(group[i]));

                                    string   ac  = acParser.GetValue(group[i].Name);
                                    Sequence seq = seqMap[ac];
                                    entry.FastaWriter.WriteLine(">" + seq.Reference);
                                    entry.FastaWriter.WriteLine(seq.SeqString);
                                }

                                foreach (IIdentifiedSpectrum spectrum in entry.Spectra)
                                {
                                    entry.ResultWriter.WriteLine(iter.PeptideFormat.GetString(spectrum));
                                }
                            }
                        }
                    }

                    return(result);
                }
            }
            finally
            {
                foreach (SpectrumEntry entry in map.Values)
                {
                    entry.Dispose();
                }
            }
        }
        public UniformSummaryBuilderUI()
        {
            InitializeComponent();

            Option = new BuildSummaryOptions();

            InsertButton(2, btnNew);

            InsertButton(3, this.btnLoadParam);

            InsertButton(4, this.btnSaveParam);

            this.minDecoyScan.DefaultValue = MascotGenericFormatShiftPrecursorProcessorOptions.DEFAULT_ShiftScan.ToString();

            this.decoyPattern = new RcpaTextField(this.txtDecoyPattern, "DecoyPattern", "Decoy Database Pattern", "^REVERSED_", false);
            AddComponent(this.decoyPattern);

            this.removeContamination = new RcpaCheckBox(cbRemoveContamination, "RemoveContamination", false);
            AddComponent(this.removeContamination);

            this.contaminationNamePattern = new RcpaTextField(this.txtContaminantString, "ContaminationNamePattern", "Contaminant Name Pattern", "CON_", false);
            AddComponent(this.contaminationNamePattern);

            this.contaminationDescriptionPattern = new RcpaTextField(this.txtContaminantDescriptionPattern, "ContaminantDescriptionPattern", "Contaminant Description Pattern", "KERATIN", false);
            AddComponent(this.contaminationDescriptionPattern);

            this.filterByFdr = new RcpaCheckBox(this.cbFilterByFDR, "FilterByFDR", true);
            AddComponent(this.filterByFdr);

            this.maxFdr = new RcpaDoubleField(this.txtMaxFdr, "MaxFdr", "Max False Discovery Rate", 0.01, true);
            AddComponent(this.maxFdr);

            this.maxPeptideFdr = new RcpaDoubleField(this.txtMaxPeptideFdr, "MaxPeptideFdr", "Max Peptide FDR", 0.01, true);
            AddComponent(this.maxPeptideFdr);

            this.filterProteinByPeptideCount = new RcpaCheckBox(this.cbPeptideCount, "FilterProteinByPeptideCount", false);
            AddComponent(this.filterProteinByPeptideCount);

            this.fdrLevel = new RcpaComboBox <FalseDiscoveryRateLevel>(this.cbFdrLevel, "FdrLevel",
                                                                       new[]
            {
                FalseDiscoveryRateLevel.Peptide,
                FalseDiscoveryRateLevel.Protein,
                FalseDiscoveryRateLevel.SimpleProtein,
                FalseDiscoveryRateLevel.UniquePeptide
            }, 1);
            AddComponent(this.fdrLevel);

            this.peptideRetrieval = new RcpaCheckBox(this.cbPeptideRetrieval, "PeptideRetrieval", true);
            AddComponent(this.peptideRetrieval);

            this.fdrType = new RcpaComboBox <FalseDiscoveryRateType>(this.cbFdrType, "FdrType",
                                                                     new[]
            {
                FalseDiscoveryRateType.Target,
                FalseDiscoveryRateType.Total
            },
                                                                     new[]
            {
                "Target : N(decoy) / N(target)",
                "Global : N(decoy) * 2 / (N(decoy) + N(target))"
            }, 0);
            AddComponent(this.fdrType);

            this.classifyByCharge = new RcpaCheckBox(this.cbClassifyByCharge, "ClassifyByCharge", ClassificationOptions.DEFAULT_ClassifyByCharge);
            AddComponent(this.classifyByCharge);

            this.classifyByMissCleavage = new RcpaCheckBox(this.cbClassifyByMissCleavage, "ClassifyByMissCleavage", ClassificationOptions.DEFAULT_ClassifyByMissCleavage);
            AddComponent(this.classifyByMissCleavage);

            this.classifyByNumberOfProteaseTermini = new RcpaCheckBox(this.cbClassifyByPreteaseTermini, "ClassifyByNumberOfProteaseTermini", ClassificationOptions.DEFAULT_ClassifyByNumProteaseTermini);
            AddComponent(this.classifyByNumberOfProteaseTermini);

            this.classifyByModification = new RcpaCheckBox(this.cbClassifyByModification, "ClassifyByModification", ClassificationOptions.DEFAULT_ClassifyByModification);
            AddComponent(this.classifyByModification);

            this.modifiedAminoacids = new RcpaTextField(this.txtFdrModifiedAminoacids, "ModifiedAminoacids", "Modified Aminoacids", "STY", true);
            this.modifiedAminoacids.PreCondition = this.cbClassifyByModification;
            AddComponent(this.modifiedAminoacids);

            this.classifyByProteinTag = new RcpaCheckBox(this.cbClassifyByProteinTag, "ClassifyByProteinTag", ClassificationOptions.DEFAULT_ClassifyByProteinTag);
            AddComponent(this.classifyByProteinTag);

            this.proteinTag = new RcpaTextField(this.txtProteinTag, "ProteinTag", "Protein Tag", "", false);
            this.proteinTag.PreCondition = this.cbClassifyByProteinTag;
            AddComponent(this.proteinTag);

            this.minimumSpectraPerGroup = new RcpaIntegerField(this.txtMinimumSpectraPerGroup, "MinimumSpectraPerGroup", "MinimumSpectraPerGroup", ClassificationOptions.DEFAULT_MinimumSpectraPerGroup, true);
            AddComponent(this.minimumSpectraPerGroup);

            this.filterSequenceLength = new RcpaCheckBox(this.cbSequenceLength, "FilterSequenceLength", false);
            AddComponent(this.filterSequenceLength);

            this.minSequenceLength = new RcpaIntegerField(this.txtMinSequenceLength, "MinSequenceLength", "Minmum Sequence Length", PeptideFilterOptions.DEFAULT_MinSequenceLength, false);
            this.minSequenceLength.PreCondition = cbSequenceLength;
            AddComponent(this.minSequenceLength);

            this.filterMaxMissCleavage = new RcpaCheckBox(this.cbMaxMissCleavage, "FilterMaxMisscleavage", false);
            AddComponent(this.filterMaxMissCleavage);

            this.maxMissCleagage = new RcpaIntegerField(this.txtMaxMissCleavage, "MaxMissCleavage", "Maximum Number of Internal Missed Cleavage", PeptideFilterOptions.DEFAULT_MaxMissCleavage, false);
            this.maxMissCleagage.PreCondition = cbMaxMissCleavage;
            AddComponent(this.maxMissCleagage);

            this.removeDecoyEntry = new RcpaCheckBox(this.cbRemoveDecoyEntry, "RemovePeptideFromDecoyDB", false);
            AddComponent(this.removeDecoyEntry);

            this.database = new RcpaFileField(btnDatabase, txtDatabase, "Database", new OpenFileArgument("Protein Database", "fasta"), "", true);
            AddComponent(this.database);

            this.acParsers = new RcpaComboBox <IAccessNumberParser>(this.cbAccessNumberPattern, "AccessNumberPattern", AccessNumberParserFactory.GetParsers().ToArray(), 0);
            AddComponent(this.acParsers);

            this.seConflictType = new RcpaComboBox <IResolveSearchEngineConflictType>(cbConflict, "ConflictType", ResolveSearchEngineConflictTypeFactory.GetTypes(), 1);
            AddComponent(this.seConflictType);

            this.conflictAsDecoy = new RcpaComboBox <ITargetDecoyConflictType>(cbConflictAsDecoy, "ConflictAsDecoy", ResolveTargetDecoyConflictTypeFactory.GetTypes(), 0);
            AddComponent(this.conflictAsDecoy);

            this.minAgreeCount = new RcpaIntegerField(txtMinAgreeCount, "MinAgreeCount", "Minimum agree count of engines", 1, true);
            AddComponent(this.minAgreeCount);

            minOneHitWonderPeptideCount = new RcpaIntegerField(txtMinOneHitWonderPeptideCount, "MinOneHitWonderPeptideCount", "minimum one-hit-wonder peptide count", 2, false);
            AddComponent(minOneHitWonderPeptideCount);
            minOneHitWonderPeptideCount.PreCondition = FilterOneHitWonder;

            this.AfterLoadOption += DoAfterLoadOption;

            Text = Constants.GetSQHTitle(title, version);

            var engines = EnumUtils.EnumToArray <SearchEngineType>().OrderByDescending(m => m.ToString()).ToArray();

            foreach (var engine in engines)
            {
                if (engine.HasFactory())
                {
                    var button = new Button();
                    pnlAdd.Controls.Add(button);
                    button.Dock = System.Windows.Forms.DockStyle.Top;
                    button.UseVisualStyleBackColor = true;
                    button.Text   = "Add " + engine.ToString();
                    button.Name   = "btnAdd" + engine.ToString();
                    button.Tag    = engine;
                    button.Click += button_Click;
                }
            }
            pnlAdd.Update();
        }
Esempio n. 6
0
        public PNovoSAPValidatorUI()
        {
            InitializeComponent();

            this.Text = Constants.GetSQHTitle(title, version);

            pNovoFiles.FileArgument = new OpenFileArgument("pNovo Result", "txt");
            AddComponent(this.pNovoFiles);

            this.minScore = new RcpaDoubleField(txtMinScore, "MinScore", "Minmum score", 0.65, true);
            AddComponent(this.minScore);

            this.threadCount = new RcpaIntegerField(txtThreadCount, "ThreadCount", "Thread count", Environment.ProcessorCount - 1, true);
            AddComponent(this.threadCount);

            toolTip1.SetToolTip(txtThreadCount, MyConvert.Format("Suggest max value = {0}", Environment.ProcessorCount + 1));

            this.titleParsers = new RcpaComboBox <ITitleParser>(cbTitleFormat, "TitleFormat", TitleParserUtils.GetTitleParsers().ToArray(), -1);
            AddComponent(this.titleParsers);

            fastaFile.FileArgument = new OpenFileArgument("Fasta To Find Mutation", "fasta");

            databaseFile.FileArgument = new OpenFileArgument("Fasta To Merge Mutated Peptide", "fasta");

            this.acParsers = new RcpaComboBox <IAccessNumberParser>(cbAccessNumberPattern, "AccessNumberParser", AccessNumberParserFactory.GetParsers().ToArray(), -1);
            AddComponent(this.acParsers);

            this.proteases = new RcpaComboBox <string>(cbProtease, "Protease", ProteaseManager.GetNames().ToArray(), -1);
            AddComponent(this.proteases);

            this.minLength = new RcpaIntegerField(txtMinLength, "MinLength", "Minimum Peptide Length", 6, true);
            AddComponent(this.minLength);
        }
Esempio n. 7
0
        protected override void InitializeFromOption(string optionFile)
        {
            base.InitializeFromOption(optionFile);

            parser = AccessNumberParserFactory.GetAutoParser();
        }
Esempio n. 8
0
        public static void FillSequenceFromFasta(string fastaFilename, IIdentifiedResult t, IProgressCallback progress)
        {
            IAccessNumberParser acParser = AccessNumberParserFactory.GuessParser(fastaFilename);

            FillSequenceFromFasta(acParser, fastaFilename, t, progress);
        }
        public ExtractFastaByAccessNumberProcessorUI()
        {
            InitializeComponent();

            SetFileArgument("AccessNumberFile", new OpenFileArgument("Access Number", "txt"));

            fastaFile = new RcpaFileField(btnFastaFile, textBox1, "FastaFile", new OpenFileArgument("Database", "fasta"), true);
            AddComponent(fastaFile);

            replaceName = new RcpaCheckBox(cbReplaceName, "ReplaceName", false);
            AddComponent(replaceName);

            parsers = new RcpaComboBox <IAccessNumberParser>(cbAccessNumberParser, "AccessNumberParser", AccessNumberParserFactory.GetParsers().ToArray(), 0);
            AddComponent(parsers);

            this.Text = Constants.GetSQHTitle(title, version);
        }
Esempio n. 10
0
        public MascotSAPValidatorUI()
        {
            InitializeComponent();

            base.SetFileArgument("PeptideFile", new OpenFileArgument("Peptides", "peptides"));

            this.Text = Constants.GetSQHTitle(title, version);

            this.mutationPattern = new RcpaTextField(txtPattern, "MutationPattern", "Mutation pattern", "MUL_", true);
            AddComponent(this.mutationPattern);

            this.fastaFile = new RcpaFileField(btnFastaFile, txtFastaFile, "FastaFile", new OpenFileArgument("Protein Fasta", "fasta"), true);
            AddComponent(this.fastaFile);

            this.acParsers = new RcpaComboBox <IAccessNumberParser>(cbAccessNumberPattern, "AccessNumberParser", AccessNumberParserFactory.GetParsers().ToArray(), -1);
            AddComponent(this.acParsers);

            dbFile = new RcpaFileField(btnBrowse, txtDBFile, "DBFile", new OpenFileArgument("Uniprot Xml Database", "xml"), false);
            //dbFile.PreCondition = cbAnnotatedByDB;
            AddComponent(dbFile);

            pnovoFile = new RcpaFileField(btnPnovoPeptide, txtPnovoPeptide, "PNovoPeptide", new OpenFileArgument("PNovo Peptides", "peptides"), true);
            AddComponent(pnovoFile);

            AddComponent(pnlClassification);
        }
 public IAccessNumberParser GetAccessNumberParser()
 {
   return AccessNumberParserFactory.FindOrCreateParser(AccessNumberPattern, AccessNumberPattern);
 }