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();
        }
Example #2
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 #3
0
        public void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            MonoisotopicMass = reader.GetNullableDoubleAttribute(ATTR.massdiff_monoisotopic) ?? 0;
            AverageMass = reader.GetNullableDoubleAttribute(ATTR.massdiff_average) ?? 0;
            Formula = reader.GetAttribute(ATTR.formula);
            Inclusion = reader.GetEnumAttribute(ATTR.inclusion, LossInclusion.Library);

            // Consume tag
            reader.Read();

            Validate();
        }
Example #4
0
        public void ReadXml(XmlReader reader)
        {
            bool? useMeasuredRTs = reader.GetNullableBoolAttribute(ATTR.use_measured_rts);
            MeasuredRTWindow = reader.GetNullableDoubleAttribute(ATTR.measured_rt_window);
            bool? useLibraryDriftTimes = reader.GetNullableBoolAttribute(ATTR.use_spectral_library_drift_times);
            LibraryDriftTimesResolvingPower = reader.GetNullableDoubleAttribute(ATTR.spectral_library_drift_times_resolving_power);
            // Keep XML values, if written by v0.5 or later
            if (useMeasuredRTs.HasValue)
                UseMeasuredRTs = useMeasuredRTs.Value;
            // Use reasonable defaults for documents saved prior to v0.5
            else
            {
                UseMeasuredRTs = true;
                if (!MeasuredRTWindow.HasValue)
                    MeasuredRTWindow = DEFAULT_MEASURED_RT_WINDOW;
            }

            if (useLibraryDriftTimes.HasValue)
                UseLibraryDriftTimes = useLibraryDriftTimes.Value;
            else
            {
                UseLibraryDriftTimes = false;
                LibraryDriftTimesResolvingPower = null;
            }

            // Consume tag
            if (reader.IsEmptyElement)
                reader.Read();
            else
            {
                reader.ReadStartElement();
                // Read child elements
                RetentionTime = reader.DeserializeElement<RetentionTimeRegression>();
                DriftTimePredictor = reader.DeserializeElement<DriftTimePredictor>();
                reader.ReadEndElement();
            }

            DoValidate();
        }
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();
        }
Example #6
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();
        }