Example #1
0
 public override void ReadXml(XmlReader reader)
 {
     RevisionIndex = reader.GetIntAttribute(Attr.revision);
     base.ReadXml(reader);
     AddDefaults();
 }
Example #2
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();
        }
Example #3
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 #4
0
        public void ReadXml(XmlReader reader)
        {
            var list = new List<TypedModifications>();
            var internalStandardTypes = new[] {IsotopeLabelType.heavy};

            MaxVariableMods = reader.GetIntAttribute(ATTR.max_variable_mods, DEFAULT_MAX_VARIABLE_MODS);
            MaxNeutralLosses = reader.GetIntAttribute(ATTR.max_neutral_losses, DEFAULT_MAX_NEUTRAL_LOSSES);

            // Consume tag
            if (reader.IsEmptyElement)
            {
                list.Add(new TypedModifications(IsotopeLabelType.light, new StaticMod[0]));
                reader.Read();
            }
            else
            {
                var internalStandardNames = new List<string>();
                string internalStandardName = reader.GetAttribute(ATTR.internal_standard);

                reader.ReadStartElement();

                if (internalStandardName != null)
                {
                    if (internalStandardName == IsotopeLabelType.NONE_NAME)
                        internalStandardTypes = new IsotopeLabelType[0];
                    else
                        internalStandardNames.Add(internalStandardName);
                }
                else
                {
                    while (reader.IsStartElement(EL.internal_standard))
                    {
                        internalStandardNames.Add(reader.GetAttribute(ATTR.name));
                        reader.Read();
                    }
                }

                if (internalStandardNames.Count > 0)
                    internalStandardTypes = new IsotopeLabelType[internalStandardNames.Count];

                SetInternalStandardType(IsotopeLabelType.light, internalStandardNames, internalStandardTypes);

                // Read child elements
                var listMods = new List<StaticMod>();
                reader.ReadElementList(EL.static_modifications, listMods);
                list.Add(new TypedModifications(IsotopeLabelType.light, listMods));
                int typeOrder = IsotopeLabelType.FirstHeavy;
                while (reader.IsStartElement(EL.heavy_modifications))
                {
                    // If first heavy tag has no isotope_label attribute, use the default heavy type
                    var labelType = IsotopeLabelType.heavy;
                    string typeName = reader.GetAttribute(ATTR.isotope_label);
                    if (!string.IsNullOrEmpty(typeName))
                    {
                        labelType = new IsotopeLabelType(typeName, typeOrder);
                        if (Equals(labelType, IsotopeLabelType.heavy))
                            labelType = IsotopeLabelType.heavy;
                        // If the created label type is going to be used and there are serialization
                        // context modifications, try to use the label types from the context.
                        else if (_serializationContext != null)
                        {
                            var modsContext = _serializationContext.GetModificationsByName(typeName);
                            if (modsContext != null)
                            {
                                // CONSIDER: Should this require full equality, including order?
                                labelType = modsContext.LabelType;
                            }
                        }
                    }
                    else if (typeOrder > IsotopeLabelType.FirstHeavy)
                    {
                        throw new InvalidDataException(
                            string.Format(Resources.PeptideModifications_ReadXml_Heavy_modifications_found_without__0__attribute,
                                          ATTR.isotope_label));
                    }
                    typeOrder++;

                    SetInternalStandardType(labelType, internalStandardNames, internalStandardTypes);

                    // If no internal standard type was given, use the first heavy type.
                    if (internalStandardNames.Count == 0 && internalStandardTypes.Length != 0)
                    {
                        internalStandardNames.Add(labelType.Name);
                        internalStandardTypes = new[] {labelType};
                    }
                    listMods = new List<StaticMod>();
                    reader.ReadElementList(EL.heavy_modifications, listMods);

                    list.Add(new TypedModifications(labelType, listMods));
                }
                int iMissingType = internalStandardTypes.IndexOf(labelType => labelType == null);
                if (iMissingType != -1)
                {
                    throw new InvalidDataException(string.Format(Resources.PeptideModifications_ReadXml_Internal_standard_type__0__not_found,
                                                                 internalStandardNames[iMissingType]));
                }
                reader.ReadEndElement();
            }

            if (list.Count < 2)
                list.Add(new TypedModifications(IsotopeLabelType.heavy, new StaticMod[0]));

            _modifications = MakeReadOnly(list.ToArray());
            InternalStandardTypes = internalStandardTypes;

            DoValidate();
        }
Example #5
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();
        }
Example #6
0
 public override void ReadXml(XmlReader reader)
 {
     // Read tag attributes
     base.ReadXml(reader);
     SpectrumCount = reader.GetIntAttribute(ATTR.count_measured);
     // Consume tag
     reader.Read();
 }