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);

            // Consume tag
            reader.ReadStartElement();

            var list = new List<IsotopeEnrichmentItem>();
            reader.ReadElements(list);
            _isotopeEnrichments = MakeReadOnly(list);

            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 #4
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            string aas = reader.GetAttribute(ATTR.aminoacid);
            if (!string.IsNullOrEmpty(aas))
            {
                AAs = aas;
                // Support v0.1 format.
                if (AAs[0] == '\0') // Not L10N
                    AAs = null;
            }

            Terminus = reader.GetAttribute(ATTR.terminus, ToModTerminus);
            IsVariable = IsExplicit = reader.GetBoolAttribute(ATTR.variable);
            Formula = reader.GetAttribute(ATTR.formula);
            if (reader.GetBoolAttribute(ATTR.label_13C))
                LabelAtoms |= LabelAtoms.C13;
            if (reader.GetBoolAttribute(ATTR.label_15N))
                LabelAtoms |= LabelAtoms.N15;
            if (reader.GetBoolAttribute(ATTR.label_18O))
                LabelAtoms |= LabelAtoms.O18;
            if (reader.GetBoolAttribute(ATTR.label_2H))
                LabelAtoms |= LabelAtoms.H2;
            RelativeRT = reader.GetEnumAttribute(ATTR.relative_rt, RelativeRT.Matching);

            // Allow specific masses always, but they will generate an error,
            // in Validate() if there is already a formula.
            MonoisotopicMass = reader.GetNullableDoubleAttribute(ATTR.massdiff_monoisotopic);
            AverageMass = reader.GetNullableDoubleAttribute(ATTR.massdiff_average);

            if (!IsVariable)
                IsExplicit = reader.GetBoolAttribute(ATTR.explicit_decl);

            UnimodId = reader.GetNullableIntAttribute(ATTR.unimod_id);
            // Backward compatibility with early code that assigned -1 to some custom modifications
            if (UnimodId.HasValue && UnimodId.Value == -1)
                UnimodId = null;

            ShortName = reader.GetAttribute(ATTR.short_name);

            // Consume tag
            reader.Read();

            var listLosses = new List<FragmentLoss>();
            reader.ReadElements(listLosses);
            if (listLosses.Count > 0)
            {
                Losses = listLosses.ToArray();
                reader.ReadEndElement();
            }

            Validate();
        }
Example #5
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes.
            SpecialHandling = reader.GetAttribute(ATTR.special_handling) ?? SpecialHandlingType.NONE;
            // Backward compatibility with v1.3: force all ions name to all ions (may be MSe)
            if (!SpecialHandlingType.IsAllIons(SpecialHandling))
                base.ReadXml(reader);
            else
            {
                ReadXmlName(SpecialHandlingType.ALL_IONS);
                SpecialHandling = SpecialHandlingType.ALL_IONS;
            }

            PrecursorFilter = reader.GetNullableDoubleAttribute(ATTR.precursor_filter);
            if (!PrecursorFilter.HasValue)
            {
                PrecursorFilter = reader.GetNullableDoubleAttribute(ATTR.precursor_left_filter);
                PrecursorRightFilter = reader.GetNullableDoubleAttribute(ATTR.precursor_right_filter);
            }

            WindowsPerScan = reader.GetNullableIntAttribute(ATTR.windows_per_scan);

            if (reader.IsEmptyElement)
                reader.Read();
            else
            {
                // Consume tag
                reader.ReadStartElement();

                var list = new List<IsolationWindow>();
                reader.ReadElements(list);
                PrespecifiedIsolationWindows = list;

                reader.ReadEndElement();
            }
            DoValidate();
        }