private static void WriteCvParam(XmlTextWriter w, string accession, string name)
 {
     w.WriteStartElement("cvParam");
     w.WriteAttribute("accession", accession);
     w.WriteAttribute("name", name);
     w.WriteAttribute("cvRef", "PSI-MS");
     w.WriteEndElement();
 }
 private static void StartDocument(XmlTextWriter w)
 {
     w.WriteStartDocument();
     w.WriteStartElement("MzIdentML");
     w.WriteAttribute("id", 1);
     w.WriteAttribute("version", "1.1.0");
     w.WriteAttribute("xmlns", "http://psidev.info/psi/pi/mzIdentML/1.1");
     w.WriteAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
     w.WriteAttribute("xsi:schemaLocation", "http://www.psidev.info/files/mzIdentML1.1.0.xsd");
     w.WriteAttributeFormat("creationDate", "{0:s}", DateTime.Now);
 }
Exemple #3
0
 public static void StartWriteDocument(XmlTextWriter w, String mode)
 {
     w.Formatting = Formatting.Indented;
     w.WriteStartDocument();
     w.WriteStartElement("ITraqResult");
     w.WriteAttribute("Mode", mode);
 }
        public void StartWriteDocument(XmlTextWriter w, IsobaricResult ir)
        {
            w.Formatting = Formatting.Indented;
            w.WriteStartDocument();
            w.WriteStartElement("IsobaricResult");
            w.WriteAttribute("IsobaricType", ir.PlexType.ToString());

            //Write used channels
            if (ir.UsedChannels != null && ir.UsedChannels.Count > 0)
            {
                w.WriteAttribute("HasUsedChannel", true.ToString());
                w.WriteStartElement("UsedChannels");
                foreach (var channel in ir.UsedChannels)
                {
                    w.WriteStartElement("UsedChannel");
                    w.WriteAttribute("Index", channel.Index);
                    w.WriteAttribute("Name", channel.Name);
                    w.WriteAttribute("Mz", channel.Mz);
                    w.WriteEndElement();
                }
                w.WriteEndElement();
            }

            //Write comments, including parameters
            w.WriteStartElement("Comments");
            foreach (var comment in ir.Comments)
            {
                w.WriteStartElement("Comment");
                w.WriteAttribute("Key", comment.Key);
                w.WriteAttribute("Value", comment.Value);
                w.WriteEndElement();
            }
            w.WriteEndElement();
        }
        private void WriteSoftwareList(XmlTextWriter w, IIdentifiedResult t, Dictionary <string, string> engineMap)
        {
            w.WriteStartElement("AnalysisSoftwareList");

            var engines = (from g in t
                           from p in g
                           from pep in p.Peptides
                           select pep.Spectrum.Engine).Distinct().ToList();

            Dictionary <string, string> map = new Dictionary <string, string>();

            engines.ForEach(m => map[m] = "unknown");
            map[softname] = softversion;

            foreach (var item in map)
            {
                var name    = item.Key;
                var version = item.Value;

                var id = name.Replace(' ', '_').Replace('\t', '_');
                engineMap[name] = id;

                w.WriteStartElement("AnalysisSoftware");
                w.WriteAttribute("id", id);
                w.WriteAttribute("name", name);
                w.WriteAttribute("version", version);

                w.WriteStartElement("SoftwareName");
                WriteCvParam(w, GetAccessionOfSoftware(name), name);
                w.WriteEndElement();

                w.WriteEndElement();
            }

            w.WriteEndElement();
        }
        private static void WriteCvList(XmlTextWriter w)
        {
            w.WriteStartElement("cvList");
            w.WriteAttribute("xmlns", "http://psidev.info/psi/pi/mzIdentML/1.1");

            w.WriteStartElement("cv");
            w.WriteAttribute("id", "PSI-MS");
            w.WriteAttribute("uri", "http://psidev.cvs.sourceforge.net/viewvc/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo");
            w.WriteAttribute("version", "2.25.0");
            w.WriteAttribute("fullName", "PSI-MS");
            w.WriteEndElement();

            w.WriteStartElement("cv");
            w.WriteAttribute("id", "UNIMOD");
            w.WriteAttribute("uri", "http://www.unimod.org/obo/unimod.obo");
            w.WriteAttribute("fullName", "UNIMOD");
            w.WriteEndElement();

            w.WriteEndElement();
        }
Exemple #7
0
        private XmlTextWriter CreateWriter(string path, IChat chat)
        {
            XmlTextWriter writer = new XmlTextWriter(
                storage.GetWriter(path + ".xml"))
            {
                Formatting  = Formatting.Indented,
                Indentation = 4,
                IndentChar  = ' '
            };

            writer.WriteStartDocument();
            writer.WriteStartElement("Chat");
            writer.WriteAttribute("ExportStartTime", DateTime.Now);
            writer.WriteAttribute("SkypeHistorianVersion", App.Version);
            Action action =
                delegate
            {
                writer.WriteAttribute("Description", chat.Description);
                writer.WriteAttribute("FriendlyName", chat.FriendlyName);
                writer.WriteAttribute("MyRole", chat.MyRole);
                writer.WriteAttribute("MyStatus", chat.MyStatus);
                writer.WriteAttribute("Name", chat.Name);
                writer.WriteAttribute("Topic", chat.Topic);
                writer.WriteAttribute("Type", chat.Type);
                writer.WriteStartElement("Members");
                foreach (IUser user in chat.Members)
                {
                    writer.WriteStartElement("Member");
                    writer.WriteAttribute("Handle", user.Handle);
                    writer.WriteAttribute("FullName", user.FullName);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            };

            if (!SafeInvoker.Invoke(action))
            {
                Logger.Error("Couldn't store chat properties.");
                return(null);
            }
            writer.WriteStartElement("Messages");
            return(writer);
        }
        public override void WriteToFile(string fileName, List <FeatureItemGroup> groups)
        {
            UTF8Encoding utf8 = new UTF8Encoding(false);

            Progress.SetMessage("Creating xml writer ... ");
            using (XmlTextWriter xw = new XmlTextWriter(fileName, utf8))
            {
                xw.Formatting = Formatting.Indented;
                Progress.SetMessage("Start writing ... ");
                xw.WriteStartDocument();

                xw.WriteStartElement("root");

                Progress.SetMessage("Getting queries ... ");
                var queries = groups.GetQueries();

                Progress.SetMessage("Writing {0} queries ...", queries.Count);
                SAMAlignedItemUtils.WriteTo(xw, queries);

                Progress.SetMessage("Writing {0} subjects ...", groups.Count);
                xw.WriteStartElement("subjectResult");
                foreach (var itemgroup in groups)
                {
                    xw.WriteStartElement("subjectGroup");
                    foreach (var item in itemgroup)
                    {
                        xw.WriteStartElement("subject");
                        xw.WriteAttribute("name", item.Name);
                        foreach (var region in item.Locations)
                        {
                            xw.WriteStartElement("region");
                            xw.WriteAttribute("seqname", region.Seqname);
                            xw.WriteAttribute("start", region.Start);
                            xw.WriteAttribute("end", region.End);
                            xw.WriteAttribute("strand", region.Strand);
                            xw.WriteAttribute("sequence", XmlUtils.ToXml(region.Sequence));
                            if (this.exportPValue)
                            {
                                xw.WriteAttribute("query_count_before_filter", region.QueryCountBeforeFilter);
                                xw.WriteAttribute("query_count", region.QueryCount);
                                xw.WriteAttribute("pvalue", region.PValue);
                            }
                            xw.WriteAttribute("size", region.Length);
                            foreach (var sl in region.SamLocations)
                            {
                                var loc = sl.SamLocation;
                                xw.WriteStartElement("query");
                                xw.WriteAttribute("qname", loc.Parent.Qname);
                                xw.WriteAttribute("loc", loc.GetLocation());
                                xw.WriteAttribute("overlap", string.Format("{0:0.##}", sl.OverlapPercentage));
                                xw.WriteAttribute("offset", sl.Offset);
                                xw.WriteAttribute("query_count", loc.Parent.QueryCount);
                                xw.WriteAttribute("seq_len", loc.Parent.Sequence.Length);
                                xw.WriteAttribute("nmi", loc.NumberOfMismatch);
                                xw.WriteAttribute("nnpm", loc.NumberOfNoPenaltyMutation);
                                xw.WriteEndElement();
                            }
                            xw.WriteEndElement();
                        }
                        xw.WriteEndElement();
                    }
                    xw.WriteEndElement();
                }
                xw.WriteEndElement();
                xw.WriteEndElement();

                xw.WriteEndDocument();

                Progress.SetMessage("Writing xml file finished.");
            }
        }