Example #1
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            UseForRetentionTimeFilter = reader.GetBoolAttribute(ATTR.use_for_retention_time_prediction, false);
            AnalyteConcentration = reader.GetNullableDoubleAttribute(ATTR.analyte_concentration);
            SampleType = SampleType.FromName(reader.GetAttribute(ATTR.sample_type));
            // Consume tag
            reader.Read();

            // Check if there is an optimization function element, and read
            // if if there is.
            IXmlElementHelper<OptimizableRegression> helper =
                reader.FindHelper(OPTIMIZATION_HELPERS);
            if (helper != null)
                OptimizationFunction = helper.Deserialize(reader);

            var msDataFilePaths = new List<MsDataFileUri>();
            var fileLoadIds = new List<string>();
            while (reader.IsStartElement(EL.sample_file) ||
                    reader.IsStartElement(EL.replicate_file) ||
                    reader.IsStartElement(EL.chromatogram_file))
            {
                // Note that the file path is actually be a URI that encodes things like lockmass correction as well as filename
                msDataFilePaths.Add(MsDataFileUri.Parse(reader.GetAttribute(ATTR.file_path)));
                string id = reader.GetAttribute(ATTR.id) ?? GetOrdinalSaveId(fileLoadIds.Count);
                fileLoadIds.Add(id);
                reader.Read();
                if (reader.IsStartElement(EL.instrument_info_list))
                {
                    reader.Skip();
                    reader.Read();
                }
            }
            Annotations = SrmDocument.ReadAnnotations(reader);

            MSDataFileInfos = msDataFilePaths.ConvertAll(path => new ChromFileInfo(path));
            _fileLoadIds = fileLoadIds.ToArray();

            // Consume end tag
            reader.ReadEndElement();
        }
        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();
        }
Example #3
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            Regex = reader.GetAttribute(ATTR.regex);
            IsIncludeMatch = reader.GetBoolAttribute(ATTR.include);
            IsMatchMod = reader.GetBoolAttribute(ATTR.match_mod_sequence);
            // Consume tag
            reader.Read();

            Validate();
        }
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 void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            MaxMissedCleavages = reader.GetIntAttribute(ATTR.max_missed_cleavages);
            ExcludeRaggedEnds = reader.GetBoolAttribute(ATTR.exclude_ragged_ends);
            // Consume tag
            reader.Read();

            Validate();
        }
        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 #7
0
        public void ReadXml(XmlReader reader)
        {
            // Read start tag attributes
            ExcludeNTermAAs = reader.GetIntAttribute(ATTR.start);
            MinPeptideLength = reader.GetIntAttribute(ATTR.min_length);
            MaxPeptideLength = reader.GetIntAttribute(ATTR.max_length);
            AutoSelect = reader.GetBoolAttribute(ATTR.auto_select);

            var list = new List<PeptideExcludeRegex>();

            // Consume tag
            if (reader.IsEmptyElement)
                reader.Read();
            else
            {
                reader.ReadStartElement();
                // Read child elements
                reader.ReadElementList(EL.peptide_exclusions, list);
                reader.ReadEndElement();
            }

            Exclusions = list;

            DoValidate();
        }
Example #8
0
        public void ReadXml(XmlReader reader)
        {
            Pick = reader.GetEnumAttribute(ATTR.pick, PeptidePick.library);
            PeptideCount = reader.GetNullableIntAttribute(ATTR.peptide_count);
            HasDocumentLibrary = reader.GetBoolAttribute(ATTR.document_library);

            _rankIdName = reader.GetAttribute(ATTR.rank_type);

            var list = new List<XmlNamedElement>();

            // Consume tag
            if (reader.IsEmptyElement)
                reader.Read();
            else
            {
                reader.ReadStartElement();
                // Read child elements
                IXmlElementHelper<Library> helperLib;
                IXmlElementHelper<LibrarySpec> helperSpec = null;
                while ((helperLib = reader.FindHelper(LIBRARY_HELPERS)) != null ||
                        (helperSpec = reader.FindHelper(LIBRARY_SPEC_HELPERS)) != null)
                {
                    if (helperLib != null)
                        list.Add(helperLib.Deserialize(reader));
                    else
                        list.Add(helperSpec.Deserialize(reader));

                }
                reader.ReadEndElement();
            }

            var libraries = new Library[list.Count];
            var librarySpecs = new LibrarySpec[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                var library = list[i] as Library;
                if (library != null)
                    libraries[i] = library;
                else
                    librarySpecs[i] = (LibrarySpec) list[i];
            }
            Libraries = libraries;
            LibrarySpecs = librarySpecs;

            DoValidate();
        }
Example #9
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            Fragment = reader.GetAttribute(ATTR.cut);
            if (IsFragment)
            {
                Restrict = reader.GetAttribute(ATTR.no_cut);
                Terminus = reader.GetAttribute(ATTR.sense, ToSeqTerminus);
                MinFragmentLength = reader.GetNullableIntAttribute(ATTR.min_length) ??
                    DEFAULT_MIN_FRAGMENT_LENGTH;
            }
            else
            {
                var charges = TextUtil.ParseInts(reader.GetAttribute(ATTR.charges)); // Old version?
                if (charges.Count() > 1)
                    throw new InvalidDataException(Resources.MeasuredIon_ReadXml_Multiple_charge_states_for_custom_ions_are_no_longer_supported_);
                SettingsCustomIon = SettingsCustomIon.Deserialize(reader);
                if (charges.Any())  // Old style - fix it up a little for our revised ideas about custom ion ionization
                {
                    Charge = charges[0];
                    if (string.IsNullOrEmpty(SettingsCustomIon.Formula)) // Adjust the user-supplied masses
                    {
                        SettingsCustomIon = new SettingsCustomIon(SettingsCustomIon.Formula,
                            Math.Round(SettingsCustomIon.MonoisotopicMass + BioMassCalc.MONOISOTOPIC.GetMass(BioMassCalc.H), SequenceMassCalc.MassPrecision), // Assume user provided neutral mass.  Round new value easiest XML roundtripping.
                            Math.Round(SettingsCustomIon.AverageMass + BioMassCalc.AVERAGE.GetMass(BioMassCalc.H), SequenceMassCalc.MassPrecision), // Assume user provided neutral mass.  Round new value easiest XML roundtripping.
                            SettingsCustomIon.Name);
                    }
                }
                else
                {
                    Charge = reader.GetIntAttribute(ATTR.charge);
                }
                IsOptional = reader.GetBoolAttribute(ATTR.optional);
            }
            // Consume tag
            reader.Read();

            Validate();
        }