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 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(">", ">"); this.Database.DecoyPattern = xmlHelper.GetChildValue(databaseXml, "DecoyPattern").Replace(">", ">"); if (xmlHelper.HasChild(databaseXml, "ContaminationPattern")) { this.Database.ContaminationNamePattern = xmlHelper.GetChildValue(databaseXml, "ContaminationPattern").Replace(">", ">"); } 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; } }