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();
        }
Example #3
0
        public void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            Type = reader.GetTypeAttribute(ATTR2.type);
            Weight = reader.GetDoubleAttribute(ATTR2.weight);

            // Consume tag
            reader.Read();

            Validate();
        }
Example #4
0
 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();
 }
Example #5
0
        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();
        }