Пример #1
0
        public void Load(XElement parentNode)
        {
            XElement xml = parentNode.Element("FalseDiscoveryRate");

            FilterByFdr     = Convert.ToBoolean(xml.Element("Filtered").Value);
            FdrLevel        = (FalseDiscoveryRateLevel)Enum.Parse(FalseDiscoveryRateLevel.Peptide.GetType(), xml.GetChildValue("Level", FalseDiscoveryRateLevel.Peptide.ToString()));
            MaxPeptideFdr   = MyConvert.ToDouble(xml.Element("MaxPeptideFdr").Value);
            FdrPeptideCount = Convert.ToInt32(xml.Element("FdrPeptideCount").Value);
            FdrType         = (FalseDiscoveryRateType)Enum.Parse(FalseDiscoveryRateType.Total.GetType(), xml.GetChildValue("Type", FalseDiscoveryRateType.Total.ToString()));
            FdrValue        = MyConvert.ToDouble(xml.Element("Value").Value);
            if (xml.Element("TargetDecoyConflictType") != null)
            {
                TargetDecoyConflictType = ResolveTargetDecoyConflictTypeFactory.Find(xml.Element("TargetDecoyConflictType").Value);
            }
            if (xml.Element("FilterOneHitWonder") != null)
            {
                FilterOneHitWonder = bool.Parse(xml.Element("FilterOneHitWonder").Value);
            }
            else
            {
                FilterOneHitWonder = false;
            }

            if (xml.Element("MinOneHitWonderPeptideCount") != null)
            {
                MinOneHitWonderPeptideCount = int.Parse(xml.Element("MinOneHitWonderPeptideCount").Value);
            }
            else
            {
                MinOneHitWonderPeptideCount = 2;
            }
            if (xml.Element("ByDecoySpectra") != null)
            {
                ByDecoySpectra = bool.Parse(xml.Element("ByDecoySpectra").Value);
            }
            else
            {
                ByDecoySpectra = false;
            }
            if (xml.Element("MinDecoyScan") != null)
            {
                MinDecoyScan = int.Parse(xml.Element("MinDecoyScan").Value);
            }
            else
            {
                MinDecoyScan = MascotGenericFormatShiftPrecursorProcessorOptions.DEFAULT_ShiftScan;
            }
            if (xml.Element("MinTargetDecoySpectraRatio") != null)
            {
                MinTargetDecoySpectraRatio = double.Parse(xml.Element("MinTargetDecoySpectraRatio").Value);
            }
            else
            {
                MinTargetDecoySpectraRatio = 2.0;
            }
        }
        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();
        }
        public virtual void LoadFromFile(string fileName)
        {
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException("Parameter file not found", fileName);
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(fileName);
            XmlNode docRoot = doc.DocumentElement;

            var xmlHelper = new XmlHelper(doc);

            this.ApplicationTitle = xmlHelper.GetChildValue(docRoot, "Version");
            this.SearchEngine     = xmlHelper.GetChildValue(docRoot, "SearchEngine");

            XmlNode fdrXml = xmlHelper.GetValidChild(docRoot, "FalseDiscoveryRate");

            if (null != fdrXml)
            {
                this.FilterByFdr   = bool.Parse(xmlHelper.GetChildValue(fdrXml, "Filtered"));
                this.FdrLevel      = (FalseDiscoveryRateLevel)Enum.Parse(FalseDiscoveryRateLevel.Peptide.GetType(), xmlHelper.GetChildValue(fdrXml, "Level"), true);
                this.FdrType       = (FalseDiscoveryRateType)Enum.Parse(FalseDiscoveryRateType.Target.GetType(), xmlHelper.GetChildValue(fdrXml, "Type"), true);
                this.FdrValue      = MyConvert.ToDouble(xmlHelper.GetChildValue(fdrXml, "Value"));
                this.MaxPeptideFdr = MyConvert.ToDouble(xmlHelper.GetChildValue(fdrXml, "MaxPeptideFdr", "0.01"));

                if (xmlHelper.HasChild(fdrXml, "FdrPeptideCount"))
                {
                    this.FdrPeptideCount = Convert.ToInt32(xmlHelper.GetChildValue(fdrXml, "FdrPeptideCount"));
                }

                this.FdrScoreType                 = xmlHelper.GetChildValue(fdrXml, "ScoreType");
                this.ClassifyByCharge             = bool.Parse(xmlHelper.GetChildValue(fdrXml, "ClassifyByCharge"));
                this.ClassifyByMissCleavage       = bool.Parse(xmlHelper.GetChildValue(fdrXml, "ClassifyByMissCleavage"));
                this.ClassifyByModification       = bool.Parse(xmlHelper.GetChildValue(fdrXml, "ClassifyByModification"));
                this.ClassifyByNumProteaseTermini = bool.Parse(xmlHelper.GetChildValue(fdrXml, "ClassifyByNumProteaseTermini", true.ToString()));
                this.ModifiedAminoacids           = xmlHelper.GetChildValue(fdrXml, "ModifiedAminoacid");

                this.ClassifyByProteinTag = bool.Parse(xmlHelper.GetChildValue(fdrXml, "ClassifyByProteinTag", false.ToString()));
                this.ProteinTag           = xmlHelper.GetChildValue(fdrXml, "ProteinTag", string.Empty);

                this.TargetDecoyConflictType = ResolveTargetDecoyConflictTypeFactory.Find(xmlHelper.GetChildValue(fdrXml, "TargetDecoyConflictType", ResolveTargetDecoyConflictTypeFactory.Decoy.Name));
            }

            XmlNode peptideFilterXml = xmlHelper.GetValidChild(docRoot, "PeptideFilter");

            if (null != peptideFilterXml)
            {
                LoadPeptideFilter(peptideFilterXml);
            }

            XmlNode databaseXml = xmlHelper.GetValidChild(docRoot, "Database");

            this.Database.Location            = xmlHelper.GetChildValue(databaseXml, "Location");
            this.Database.AccessNumberPattern = xmlHelper.GetChildValue(databaseXml, "AccessNumberPattern").Replace("&gt;", ">");
            this.Database.DecoyPattern        = xmlHelper.GetChildValue(databaseXml, "DecoyPattern").Replace("&gt;", ">");
            if (xmlHelper.HasChild(databaseXml, "ContaminationPattern"))
            {
                this.Database.ContaminationNamePattern = xmlHelper.GetChildValue(databaseXml, "ContaminationPattern").Replace("&gt;", ">");
            }

            this.Database.RemovePeptideFromDecoyDB = bool.Parse(xmlHelper.GetChildValue(databaseXml, "RemovePeptideFromDecoyDB"));

            LoadSpecialDefinition(docRoot);

            XmlNode filesXml = xmlHelper.GetValidChild(docRoot, "PathNames");

            if (null == filesXml)
            {
                throw new ArgumentException(MyConvert.Format("There is no PathNames section in parameter file {0}", fileName));
            }

            this.pathNameBin.Clear();
            XmlNode pathNameXml = filesXml.FirstChild;

            while (null != pathNameXml)
            {
                string bin = pathNameXml.Attributes["Bin"].Value;
                this.pathNameBin[pathNameXml.InnerText] = bin;
                pathNameXml = pathNameXml.NextSibling;
            }
        }