コード例 #1
0
        public static IsobaricType ReadIsobaricType(XElement iso)
        {
            var item = new IsobaricType();

            item.Name = iso.FindElement("name").Value;
            foreach (var tag in iso.FindElements("tag_mz"))
            {
                item.TagMassH.Add(double.Parse(tag.Value));
            }

            var channels = iso.FindElements("channel");

            for (int index = 0; index < channels.Count; index++)
            {
                var channel = channels[index];
                var cha     = new IsobaricChannel();
                cha.Index      = index;
                cha.Name       = channel.FindAttribute("name").Value;
                cha.Mz         = double.Parse(channel.FindAttribute("mz").Value);
                cha.Percentage = double.Parse(channel.FindAttribute("percentage").Value);
                item.Channels.Add(cha);

                foreach (var isotopic in channel.FindElements("isotopic"))
                {
                    var isot = new IsobaricIsotope();
                    isot.Name       = isotopic.FindAttribute("name").Value;
                    isot.Percentage = double.Parse(isotopic.FindAttribute("percentage").Value);
                    cha.Isotopics.Add(isot);
                }
            }

            item.Initialize();
            return(item);
        }
コード例 #2
0
        public static List <UsedChannel> GetUsedChannels(string fileName, IsobaricType isobaricType)
        {
            using (var stream = new FileStream(fileName, FileMode.Open))
            {
                using (var reader = XmlReader.Create(stream))
                {
                    if (reader.MoveToElement("IsobaricResult"))
                    {
                        if (reader.HasAttributes)
                        {
                            var hasUsedChannel = reader.GetAttribute("HasUsedChannel");
                            if (!string.IsNullOrEmpty(hasUsedChannel) && hasUsedChannel.Equals(true.ToString()))
                            {
                                reader.MoveToElement("UsedChannels");
                                XElement el = XNode.ReadFrom(reader) as XElement;

                                List <UsedChannel> result = new List <UsedChannel>();
                                foreach (var ele in el.FindElements("UsedChannel"))
                                {
                                    var item = new UsedChannel();
                                    item.Index = int.Parse(ele.Attribute("Index").Value);
                                    item.Name  = ele.Attribute("Name").Value;
                                    item.Mz    = double.Parse(ele.Attribute("Mz").Value);
                                    result.Add(item);
                                }

                                return(result);
                            }
                        }
                    }
                }
            }

            return(null);
        }
コード例 #3
0
 public IsobaricPurityCorrectionRCalculator(IsobaricType plexType, List <UsedChannel> used, string rExecute, bool performPurityCorrection, bool performGraph)
 {
     this.plexType = plexType;
     this.used     = used;
     this.rExecute = rExecute;
     if (this.rExecute == null)
     {
         throw new Exception("Define R location first!");
     }
     this.performPurityCorrection = performPurityCorrection;
     this.performGraph            = performGraph;
 }
コード例 #4
0
        public object Clone()
        {
            var result = new IsobaricType();

            result.Name = Name;

            result.TagMassH = TagMassH;

            result.Channels = (from channel in Channels
                               select channel.Clone() as IsobaricChannel).ToList();

            result.IsotopicTable = IsotopicTable;

            result.NameIndexMap = NameIndexMap;

            return(result);
        }
コード例 #5
0
        public static void WriteIsobaricType(XElement iso, IsobaricType item)
        {
            iso.Add(new XElement("name", item.Name));
            foreach (var tag in item.TagMassH)
            {
                iso.Add(new XElement("tag_mass", tag));
            }

            foreach (var channel in item.Channels)
            {
                iso.Add(new XElement("channel",
                                     new XAttribute("name", channel.Name),
                                     new XAttribute("mz", channel.Mz),
                                     new XAttribute("percentage", channel.Percentage),
                                     (from isotopic in channel.Isotopics
                                      select new XElement("isotopic",
                                                          new XAttribute("name", isotopic.Name),
                                                          new XAttribute("percentage", isotopic.Percentage)))));
            }
        }
コード例 #6
0
 public IsobaricPurityCorrectionRCalculator(IsobaricType plexType, List <UsedChannel> used, bool performPurityCorrection, bool performGraph)
     : this(plexType, used, ExternalProgramConfig.GetExternalProgram("R"), performPurityCorrection, performGraph)
 {
 }