public override void ReadXml(XmlReader reader) { // Read tag attributes base.ReadXml(reader); ColinearWarning = reader.GetBoolAttribute(ATTR.colinear_warning); // Earlier versions always used decoys only UsesDecoys = reader.GetBoolAttribute(ATTR.uses_decoys, true); UsesSecondBest = reader.GetBoolAttribute(ATTR.uses_false_targets); double bias = reader.GetDoubleAttribute(ATTR.bias); // Consume tag reader.Read(); // Read calculators var calculators = new List <FeatureCalculator>(); reader.ReadElements(calculators); var peakFeatureCalculators = new List <IPeakFeatureCalculator>(calculators.Count); var weights = new double[calculators.Count]; for (int i = 0; i < calculators.Count; i++) { weights[i] = calculators[i].Weight; peakFeatureCalculators.Add(PeakFeatureCalculator.GetCalculator(calculators[i].Type)); } SetPeakFeatureCalculators(peakFeatureCalculators); Parameters = new LinearModelParams(weights, bias); reader.ReadEndElement(); DoValidate(); }
public override void ReadXml(XmlReader reader) { // Read tag attributes base.ReadXml(reader); // Earlier versions always used decoys only UsesDecoys = reader.GetBoolAttribute(ATTR.uses_decoys, true); UsesSecondBest = reader.GetBoolAttribute(ATTR.uses_false_targets, false); double bias = reader.GetDoubleAttribute(ATTR.bias); bool isEmpty = reader.IsEmptyElement; // Consume tag reader.Read(); if (!isEmpty) { // Read calculators var calculators = new List <FeatureCalculator>(); reader.ReadElements(calculators); var weights = new double[calculators.Count]; for (int i = 0; i < calculators.Count; i++) { if (calculators[i].Type != PeakFeatureCalculators[i].GetType()) { throw new InvalidDataException(Resources.LegacyScoringModel_ReadXml_Invalid_legacy_model_); } weights[i] = calculators[i].Weight; } Parameters = new LinearModelParams(weights, bias); reader.ReadEndElement(); } DoValidate(); }
public override void ReadXml(XmlReader reader) { base.ReadXml(reader); ControlAnnotation = reader.GetAttribute(ATTR.control_annotation); ControlValue = reader.GetAttribute(ATTR.control_value); CaseValue = reader.GetAttribute(ATTR.case_value); IdentityAnnotation = reader.GetAttribute(ATTR.identity_annotation); AverageTechnicalReplicates = reader.GetBoolAttribute(ATTR.avg_tech_replicates, true); NormalizationMethod = NormalizationMethod.FromName(reader.GetAttribute(ATTR.normalization_method)); IncludeInteractionTransitions = reader.GetBoolAttribute(ATTR.include_interaction_transitions, false); SummarizationMethod = SummarizationMethod.FromName(reader.GetAttribute(ATTR.summarization_method)); ConfidenceLevelTimes100 = reader.GetDoubleAttribute(ATTR.confidence_level, 95); PerProtein = reader.GetBoolAttribute(ATTR.per_protein, false); UseZeroForMissingPeaks = reader.GetBoolAttribute(ATTR.use_zero_for_missing_peaks, false); QValueCutoff = reader.GetNullableDoubleAttribute(ATTR.q_value_cutoff); var colorRows = new List <MatchRgbHexColor>(); reader.Read(); while (reader.IsStartElement(MatchRgbHexColor.XML_ROOT)) { var row = new MatchRgbHexColor(); row.ReadXml(reader); colorRows.Add(row); } if (colorRows.Any()) { reader.Read(); } ColorRows = ImmutableList <MatchRgbHexColor> .ValueOf(colorRows); }
public override void ReadXml(XmlReader reader) { // Read tag attributes base.ReadXml(reader); PeakArea = reader.GetDoubleAttribute(ATTR.peak_area); // Consume tag reader.Read(); }
public static CircleShape Load(XmlReader reader) { CircleShape circle = new CircleShape(); circle.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position")); circle.Radius = reader.GetDoubleAttribute("radius"); return(circle); }
public static BearingObservation Load(XmlReader reader, Dictionary <Observation, string> observers) { BearingObservation shape = new BearingObservation(); LoadPositionalData(shape, reader); shape.Bearing = reader.GetDoubleAttribute("bearing"); observers.Add(shape, reader.GetAttribute("observer")); return(shape); }
protected virtual void ReadAttributes(XmlReader reader) { Formula = reader.GetAttribute(ATTR.formula); if (!string.IsNullOrEmpty(Formula)) { Formula = BioMassCalc.AddH(Formula); // Update this old style formula to current by adding the hydrogen we formerly left out due to assuming protonation } else { Formula = reader.GetAttribute(ATTR.ion_formula); } if (string.IsNullOrEmpty(Formula)) { AverageMass = reader.GetDoubleAttribute(ATTR.mass_average); MonoisotopicMass = reader.GetDoubleAttribute(ATTR.mass_monoisotopic); } Validate(); }
public static new UnitShape Load(XmlReader reader, Dictionary <Observation, string> observers, Dictionary <string, UnitShape> unitsById) { UnitShape shape = new UnitShape(); shape.Name = reader.GetAttribute("name"); shape.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position")); shape.Direction = reader.GetDoubleAttribute("course"); shape.Speed = reader.GetDoubleAttribute("speed"); shape.Type = Utility.ParseEnum <UnitShapeType>(reader.GetStringAttribute("type", "unknown"), true); string id = reader.GetAttribute("id"); if (!string.IsNullOrEmpty(id)) { unitsById.Add(id, shape); } if (!reader.IsEmptyElement) { reader.Read(); while (reader.NodeType == XmlNodeType.Element) { if (reader.LocalName == "tmaSolution") { shape.TMASolution = TMASolution.Load(reader); } else if (reader.LocalName == "children" && !reader.IsEmptyElement) { reader.Read(); // move to either the first child or the end element while (reader.NodeType == XmlNodeType.Element) { shape.Children.Add(Shape.Load(reader, observers, unitsById)); } reader.ReadEndElement(); } else { throw new InvalidDataException("Expected element " + reader.LocalName); } } } return(shape); }
public void ReadXml(XmlReader reader) { // Read tag attributes Start = reader.GetDoubleAttribute(ATTR.start); End = reader.GetDoubleAttribute(ATTR.end); Target = reader.GetNullableDoubleAttribute(ATTR.target); StartMargin = reader.GetNullableDoubleAttribute(ATTR.margin); if (StartMargin == null) { StartMargin = reader.GetNullableDoubleAttribute(ATTR.margin_left); EndMargin = reader.GetNullableDoubleAttribute(ATTR.margin_right); } CERange = reader.GetNullableDoubleAttribute(ATTR.ce_range); // Consume tag reader.Read(); DoValidate(); }
public TypedMass ReadMonoisotopicMass(XmlReader reader) { var mass = reader.GetNullableDoubleAttribute(ATTR.mass_monoisotopic); // Pre-3.62 we wrote out massH for custom ions but not for reporter ions if (mass.HasValue) { return(new TypedMass(mass.Value, (this is SettingsCustomIon) ? MassType.Monoisotopic : MassType.MonoisotopicMassH)); } return(new TypedMass(reader.GetDoubleAttribute(ATTR.neutral_mass_monoisotopic), MassType.Monoisotopic)); }
public void ReadXml(XmlReader reader) { // Read tag attributes Type = reader.GetTypeAttribute(ATTR2.type); Weight = reader.GetDoubleAttribute(ATTR2.weight); // Consume tag reader.Read(); Validate(); }
public override void ReadXml(XmlReader reader) { base.ReadXml(reader); ControlAnnotation = reader.GetAttribute(ATTR.control_annotation); ControlValue = reader.GetAttribute(ATTR.control_value); CaseValue = reader.GetAttribute(ATTR.case_value); IdentityAnnotation = reader.GetAttribute(ATTR.identity_annotation); AverageTechnicalReplicates = reader.GetBoolAttribute(ATTR.avg_tech_replicates, true); SumTransitions = reader.GetBoolAttribute(ATTR.sum_transitions, true); NormalizationMethod = NormalizationMethod.FromName(reader.GetAttribute(ATTR.normalization_method)); IncludeInteractionTransitions = reader.GetBoolAttribute(ATTR.include_interaction_transitions, false); SummarizationMethod = SummarizationMethod.FromName(reader.GetAttribute(ATTR.summarization_method)); ConfidenceLevelTimes100 = reader.GetDoubleAttribute(ATTR.confidence_level, 95); PerProtein = reader.GetBoolAttribute(ATTR.per_protein, false); reader.Read(); }
public void ReadXml(XmlReader reader) { LogIndex = Interlocked.Increment(ref _logIndexCounter); FormatVersion = new DocumentFormat(reader.GetDoubleAttribute(ATTR.format_version)); var time = DateTime.Parse(reader.GetAttribute(ATTR.time_stamp), CultureInfo.InvariantCulture); TimeStamp = DateTime.SpecifyKind(time, DateTimeKind.Utc).ToLocalTime(); User = reader.GetAttribute(ATTR.user); InsertUndoRedoIntoAllInfo = reader.GetBoolAttribute(ATTR.insert_undo_redo); var countType = reader.GetAttribute(ATTR.count_type); if (countType == null) { CountEntryType = null; } else { CountEntryType = (MessageType)Enum.Parse(typeof(MessageType), countType); } reader.ReadStartElement(); Reason = reader.IsStartElement(EL.reason) ? reader.ReadElementString() : string.Empty; ExtraInfo = reader.IsStartElement(EL.extra_info) ? reader.ReadElementString().UnescapeNonPrintableChars() : string.Empty; UndoRedo = reader.DeserializeElement <LogMessage>(); Summary = reader.DeserializeElement <LogMessage>(); var list = new List <LogMessage>(); while (reader.IsStartElement(EL.message)) { list.Add(reader.DeserializeElement <LogMessage>()); } AllInfo = list; reader.ReadEndElement(); }
/// <summary> /// Reads in an engine.xml file and turns it into a CaptionList, SpeakerSet and engine /// Settings. /// </summary> /// <param name="path">The Path to the engine.xml file.</param> /// <returns>A 3-Tuple containing a CaptionList, a SpeakerSet, and a Settings /// object in that specific order.</returns> public static Tuple <List <Caption>, Dictionary <string, Speaker>, SettingsXml> ParseEngineXml(string path) { var captionList = new List <Caption>(); var speakerSet = new Dictionary <string, Speaker>(); var settings = new SettingsXml(); XmlReaderSettings readerSettings = new XmlReaderSettings { IgnoreWhitespace = true, IgnoreComments = true }; using (XmlReader r = XmlReader.Create(path, readerSettings)) { while (r.Read()) { //Look for start elements only. if (!r.IsStartElement()) { continue; } // Get element name and switch on it. switch (r.Name) { case XmlElements.Enact: break; case XmlElements.Settings: r.Read(); r.AssertNode(XmlElements.Meta); settings.Base = r.GetNonNullAttribute(XmlAttributes.Base); settings.Spacing = r.GetNonNullAttribute(XmlAttributes.WordSpacing); settings.SeparateEmotionWords = r.GetNonNullAttribute(XmlAttributes.SeparateEmotionWords); r.Read(); r.AssertNode(XmlElements.Playback); settings.Playback.AutoPlay = r.GetBoolAttribute(XmlAttributes.AutoPlay); settings.Playback.AutoRewind = r.GetBoolAttribute(XmlAttributes.AutoRewind); settings.Playback.Seek = r.GetNonNullAttribute(XmlAttributes.Seek); settings.Playback.AutoSize = r.GetBoolAttribute(XmlAttributes.AutoSize); settings.Playback.Scale = r.GetIntAttribute(XmlAttributes.Scale); settings.Playback.Volume = r.GetIntAttribute(XmlAttributes.Volume); settings.Playback.ShowCaptions = r.GetBoolAttribute(XmlAttributes.ShowCaptions); r.Read(); r.AssertNode(XmlElements.Skin); settings.Skin.Source = r.GetNonNullAttribute(XmlAttributes.Source); settings.Skin.AutoHide = r.GetBoolAttribute(XmlAttributes.AutoHide); settings.Skin.FadeTime = r.GetIntAttribute(XmlAttributes.FadeTime); settings.Skin.BackGroundAlpha = r.GetIntAttribute(XmlAttributes.BackgroundAlpha); settings.Skin.BackgroundColour = r.GetNonNullAttribute(XmlAttributes.BackgroundColour); r.Read(); r.AssertNode(XmlElements.Video); settings.VideoSource = r.GetNonNullAttribute(XmlAttributes.Source); r.Read(); r.AssertNode(XmlElements.Emotions); r.Read(); r.AssertNode(XmlElements.Happy); settings.Happy.Fps = r.GetNonNullAttribute(XmlAttributes.FPS); settings.Happy.Duration = r.GetNonNullAttribute(XmlAttributes.Duration); settings.Happy.AlphaBegin = r.GetNonNullAttribute(XmlAttributes.AlphaBegin); settings.Happy.AlphaFinish = r.GetNonNullAttribute(XmlAttributes.AlphaFinish); settings.Happy.ScaleBegin = r.GetNonNullAttribute(XmlAttributes.ScaleBegin); settings.Happy.ScaleFinish = r.GetNonNullAttribute(XmlAttributes.ScaleFinish); settings.Happy.YFinish = r.GetNonNullAttribute(XmlAttributes.YFinish); r.Read(); r.AssertNode(XmlElements.Sad); settings.Sad.Fps = r.GetNonNullAttribute(XmlAttributes.FPS); settings.Sad.Duration = r.GetNonNullAttribute(XmlAttributes.Duration); settings.Sad.AlphaBegin = r.GetNonNullAttribute(XmlAttributes.AlphaBegin); settings.Sad.AlphaFinish = r.GetNonNullAttribute(XmlAttributes.AlphaFinish); settings.Sad.ScaleBegin = r.GetNonNullAttribute(XmlAttributes.ScaleBegin); settings.Sad.ScaleFinish = r.GetNonNullAttribute(XmlAttributes.ScaleFinish); settings.Sad.YFinish = r.GetNonNullAttribute(XmlAttributes.YFinish); r.Read(); r.AssertNode(XmlElements.Fear); settings.Fear.Fps = r.GetNonNullAttribute(XmlAttributes.FPS); settings.Fear.Duration = r.GetNonNullAttribute(XmlAttributes.Duration); settings.Fear.ScaleBegin = r.GetNonNullAttribute(XmlAttributes.ScaleBegin); settings.Fear.ScaleFinish = r.GetNonNullAttribute(XmlAttributes.ScaleFinish); settings.Fear.VibrateX = r.GetNonNullAttribute(XmlAttributes.VibrateX); settings.Fear.VibrateY = r.GetNonNullAttribute(XmlAttributes.VibrateY); r.Read(); r.AssertNode(XmlElements.Anger); settings.Anger.Fps = r.GetNonNullAttribute(XmlAttributes.FPS); settings.Anger.Duration = r.GetNonNullAttribute(XmlAttributes.Duration); settings.Anger.ScaleBegin = r.GetNonNullAttribute(XmlAttributes.ScaleBegin); settings.Anger.ScaleFinish = r.GetNonNullAttribute(XmlAttributes.ScaleFinish); settings.Anger.VibrateX = r.GetNonNullAttribute(XmlAttributes.VibrateX); settings.Anger.VibrateY = r.GetNonNullAttribute(XmlAttributes.VibrateY); break; case XmlElements.Speakers: break; //Do Nothing case XmlElements.Speaker: r.AssertNode(XmlElements.Speaker); string name = r.GetNonNullAttribute(XmlAttributes.Name); Speaker s = new Speaker(name); r.Read(); r.AssertNode(XmlElements.Background); //Create background colour based on xml paramaters bool visible = r.GetBoolAttribute(XmlAttributes.Visible); double alphaD = r.GetDoubleAttribute(XmlAttributes.Alpha); int colourCode = r.GetHexAttribute(XmlAttributes.Colour); int alpha = (int)((visible) ? alphaD * 0xFF : 0x00); // Bitshift alpha to the most significant byte of the integer s.Font.BackgroundColour = Color.FromArgb(alpha << 24 | colourCode); r.Read(); r.AssertNode(XmlElements.Font); s.Font.Family = r.GetNonNullAttribute(XmlAttributes.Name); s.Font.Size = r.GetIntAttribute(XmlAttributes.Size); s.Font.ForegroundColour = Color.FromArgb(SpeakerFont.ForegroundAlphaValue << 24 | r.GetHexAttribute(XmlAttributes.Colour)); s.Font.Bold = r.GetIntAttribute(XmlAttributes.Bold); r.ReadStartElement(XmlElements.Font); //Add to speakerSet speakerSet[s.Name] = s; break; case XmlElements.Captions: break; //Do Nothing case XmlElements.Caption: r.AssertNode(XmlElements.Caption); Caption c = new Caption { Begin = r.GetNonNullAttribute(XmlAttributes.Begin), End = r.GetNonNullAttribute(XmlAttributes.End), Speaker = speakerSet[r.GetNonNullAttribute(XmlAttributes.Speaker)], Location = (ScreenLocation)r.GetIntAttribute(XmlAttributes.Location), Alignment = (Alignment)r.GetIntAttribute(XmlAttributes.Align) }; List <CaptionWord> wordList = new List <CaptionWord>(); while (r.Read()) { //If the Node is an end element, then the reader has parsed //through all of this caption's words. if (r.NodeType == XmlNodeType.EndElement && r.Name.Equals(XmlElements.Caption)) { break; } if (r.NodeType == XmlNodeType.Element && r.Name.Equals(XmlElements.Word)) { r.AssertNode(XmlElements.Word); //Doublecheck, it's the only way to be sure. Emotion e = (Emotion)r.GetIntAttribute(XmlAttributes.Emotion); Intensity i = (Intensity)r.GetIntAttribute(XmlAttributes.Intensity); //Get word from node and add it to the list CaptionWord word = new CaptionWord(e, i, r.ReadString(), 0); wordList.Add(word); } } c.Words.SetWordList(wordList); captionList.Add(c); break; default: throw new ArgumentException("Value '" + r.Name + "' is not a valid node", r.Name); } }//Enact } return(Tuple.Create(captionList, speakerSet, settings)); }
public override void ReadXml(XmlReader reader) { // Read tag attributes base.ReadXml(reader); // Earlier versions always used decoys only UsesDecoys = reader.GetBoolAttribute(ATTR.uses_decoys, true); UsesSecondBest = reader.GetBoolAttribute(ATTR.uses_false_targets, false); double bias = reader.GetDoubleAttribute(ATTR.bias); bool isEmpty = reader.IsEmptyElement; // Consume tag reader.Read(); if (!isEmpty) { // Read calculators var calculators = new List<FeatureCalculator>(); reader.ReadElements(calculators); var weights = new double[calculators.Count]; for (int i = 0; i < calculators.Count; i++) { if (calculators[i].Type != PeakFeatureCalculators[i].GetType()) throw new InvalidDataException(Resources.LegacyScoringModel_ReadXml_Invalid_legacy_model_); weights[i] = calculators[i].Weight; } Parameters = new LinearModelParams(weights, bias); reader.ReadEndElement(); } DoValidate(); }
public override void ReadXml(XmlReader reader) { // Read tag attributes base.ReadXml(reader); ColinearWarning = reader.GetBoolAttribute(ATTR.colinear_warning); // Earlier versions always used decoys only UsesDecoys = reader.GetBoolAttribute(ATTR.uses_decoys, true); UsesSecondBest = reader.GetBoolAttribute(ATTR.uses_false_targets); double bias = reader.GetDoubleAttribute(ATTR.bias); // Consume tag reader.Read(); // Read calculators var calculators = new List<FeatureCalculator>(); reader.ReadElements(calculators); var peakFeatureCalculators = new List<IPeakFeatureCalculator>(calculators.Count); var weights = new double[calculators.Count]; for (int i = 0; i < calculators.Count; i++) { weights[i] = calculators[i].Weight; peakFeatureCalculators.Add(PeakFeatureCalculator.GetCalculator(calculators[i].Type)); } SetPeakFeatureCalculators(peakFeatureCalculators); Parameters = new LinearModelParams(weights, bias); reader.ReadEndElement(); DoValidate(); }
public static double GetDoubleAttribute(this XmlReader reader, string name) { return(reader.GetDoubleAttribute(name, 0.0)); }