示例#1
0
        public void NewFromData(string subdir)
        {
            var siformat = Directory.GetFiles(subdir, "*.siformat");

            TextFileDefinition prefile = new TextFileDefinition();

            if (siformat.Length > 0)
            {
                prefile.ReadFromFile(siformat[0]);

                bool bFound = false;
                prefile.ForEach(m =>
                {
                    if (m.PropertyName.Equals("TumorStage"))
                    {
                        m.PropertyName = "TumorStatus";
                        bFound         = true;
                    }

                    if (m.PropertyName.Equals("Metastasis"))
                    {
                        m.PropertyName = "MetastasisStatus";
                        bFound         = true;
                    }
                });

                if (bFound)
                {
                    prefile.WriteToFile(siformat[0]);
                }
            }

            var map = new RawSampleInfoReader().ReadDescriptionFromDirectory(subdir);

            lastDirectory = subdir;
            lastFile      = String.Empty;

            var files = new HashSet <string>(from f in CelFile.GetCelFiles(subdir, false)
                                             select GeoUtils.GetGsmName(f));

            Dictionary <string, HashSet <string> > headers = new Dictionary <string, HashSet <string> >();

            foreach (var m in map)
            {
                var gsm = m.Key.ToLower();

                if (!files.Contains(gsm))
                {
                    continue;
                }

                var curmap = m.Value;

                foreach (var entry in curmap)
                {
                    if (!headers.ContainsKey(entry.Key))
                    {
                        headers[entry.Key] = new HashSet <string>();
                    }
                    headers[entry.Key].UnionWith(entry.Value);
                }
            }

            ClearDataSource();

            items.Clear();
            foreach (var part in headers)
            {
                items.Add(new FileDefinitionItem()
                {
                    AnnotationName = part.Key,
                    Example        = (from v in part.Value
                                      orderby v
                                      select v).Merge(";")
                });
            }

            foreach (var olditem in prefile)
            {
                if (!string.IsNullOrEmpty(olditem.PropertyName))
                {
                    var newitem = items.Find(m => m.AnnotationName.Equals(olditem.AnnotationName));
                    if (newitem != null)
                    {
                        newitem.PropertyName = olditem.PropertyName;
                    }
                }
            }

            items.DefaultValues.Clear();
            foreach (var olddv in prefile.DefaultValues)
            {
                if (propertyNames.Contains(olddv.PropertyName))
                {
                    items.DefaultValues.Add(new DefaultValue()
                    {
                        PropertyName = olddv.PropertyName,
                        Value        = olddv.Value
                    });
                }
            }

            items.Sort((m1, m2) => m1.AnnotationName.CompareTo(m2.AnnotationName));

            UpdateDataSource();

            this.Text = title + " - " + Path.GetFileName(subdir);
        }
示例#2
0
        public void NewFromData(string subdir)
        {
            try
            {
                var siformat = Directory.GetFiles(subdir, "*.siformat");

                TextFileDefinition prefile = new TextFileDefinition();
                if (siformat.Length > 0)
                {
                    prefile.ReadFromFile(siformat[0]);
                }

                var map = new RawSampleInfoReader().ReadDescriptionFromDirectory(subdir);

                LastDirectory = subdir;
                lastFile      = String.Empty;

                var files = new HashSet <string>(from f in CelFile.GetCelFiles(subdir, false)
                                                 select GeoUtils.GetGsmName(f));

                Dictionary <string, HashSet <string> > headers = new Dictionary <string, HashSet <string> >();
                foreach (var m in map)
                {
                    var gsm = m.Key.ToUpper();

                    if (!files.Contains(gsm))
                    {
                        continue;
                    }

                    var curmap = m.Value;

                    foreach (var entry in curmap)
                    {
                        if (!headers.ContainsKey(entry.Key))
                        {
                            headers[entry.Key] = new HashSet <string>();
                        }
                        headers[entry.Key].UnionWith(entry.Value);
                    }
                }

                ClearDataSource();

                items.Clear();
                foreach (var part in headers)
                {
                    items.Add(new FileDefinitionItem()
                    {
                        AnnotationName = part.Key,
                        Example        = (from v in part.Value
                                          orderby v
                                          select v).Merge(";")
                    });
                }

                foreach (var olditem in prefile)
                {
                    if (!string.IsNullOrEmpty(olditem.PropertyName))
                    {
                        var newitem = items.Find(m => m.AnnotationName.Equals(olditem.AnnotationName));
                        if (newitem != null)
                        {
                            newitem.PropertyName = olditem.PropertyName;
                        }
                    }
                }

                items.DefaultValues.Clear();

                items.Sort((m1, m2) => m1.AnnotationName.CompareTo(m2.AnnotationName));

                UpdateDataSource();

                label1.Text = "Annotation/property mapping - " + Path.GetFileName(subdir);

                dlgOpenDirectory.SelectedPath = subdir;
                dlgSaveFormatFile.FileName    = Path.Combine(subdir, Path.GetFileName(subdir) + ".siformat");
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }