private List <ITCGATechnology> GetSelectedTechnologies()
        {
            var result = new List <ITCGATechnology>();

            foreach (string obj in lbDataTypes.SelectedItems)
            {
                result.Add(TCGATechnology.Parse(obj));
            }
            return(result);
        }
Пример #2
0
        public TCGADatatableBuilderUI()
        {
            InitializeComponent();

            rootDir.SetDirectoryArgument("TCGARoot", "TCGA Data Root");

            targetFile.FileArgument = new SaveFileArgument("Target Data", "tsv");

            lbDataTypes.Items.AddRange(TCGATechnology.GetTechnologyNames().ToArray());

            lbSampleTypes.Items.AddRange(TCGASampleCode.GetSampleCodes().OrderBy(m => m.Code).ToList().ConvertAll(m => string.Format("{0}, {1}", m.ShortLetterCode, m.Definition)).ToArray());

            this.Text = Constants.GetSQHTitle(title, version);
        }
Пример #3
0
        private void FillPlatform()
        {
            lbPlatforms.BeginUpdate();
            try
            {
                var oldplatforms = GetSelectedPlatforms();

                lbPlatforms.Items.Clear();

                if (lbDataTypes.SelectedItem == null || !Directory.Exists(rootDir.FullName) || lbTumors.SelectedItem == null)
                {
                    return;
                }

                var technology = TCGATechnology.Parse(lbDataTypes.SelectedItem as string);
                var tumors     = GetSelectedTumors();

                var platforms = (from tumor in tumors
                                 let dir = rootDir.FullName + "/" + tumor
                                           let plats = Directory.GetDirectories(technology.GetTechnologyDirectory(dir))
                                                       from plat in plats
                                                       select Path.GetFileName(plat)).Distinct().OrderBy(m => m).ToList();

                platforms.ForEach(m => lbPlatforms.Items.Add(m));
                if (platforms.Count == 1)
                {
                    lbPlatforms.SelectedIndex = 0;
                }
                else
                {
                    if (oldplatforms.Count > 0)
                    {
                        for (int i = 0; i < lbPlatforms.Items.Count; i++)
                        {
                            if (oldplatforms.Contains(lbPlatforms.Items[i]))
                            {
                                lbPlatforms.SetSelected(i, true);
                            }
                        }
                    }
                }
            }
            finally
            {
                lbPlatforms.EndUpdate();
            }
        }
Пример #4
0
        private void FillTumor()
        {
            var map = TCGAUtils.GetTumorDescriptionMap();

            object[] curitems;
            if (lbDataTypes.SelectedItem != null && Directory.Exists(rootDir.FullName))
            {
                var tecname  = lbDataTypes.SelectedItem as string;
                var selected = TCGATechnology.Parse(tecname);
                curitems = (from tumor in this.tumors
                            let dir = rootDir.FullName + "/" + tumor
                                      where Directory.Exists(selected.GetTechnologyDirectory(dir))
                                      select tumor).ToArray();
            }
            else
            {
                curitems = this.tumors.ToArray();
            }

            lbTumors.BeginUpdate();
            try
            {
                var selected = new HashSet <string>(GetSelectedTumors().ConvertAll(m => m as string));
                lbTumors.Items.Clear();
                foreach (string item in curitems)
                {
                    var name = map.ContainsKey(item.ToUpper()) ? item + ", " + map[item.ToUpper()] : item;
                    lbTumors.Items.Add(name);
                }
                if (selected.Count > 0)
                {
                    for (int i = 0; i < lbTumors.Items.Count; i++)
                    {
                        var name = curitems[i] as string;
                        if (selected.Contains(name))
                        {
                            lbTumors.SetSelected(i, true);
                        }
                    }
                }
            }
            finally
            {
                lbTumors.EndUpdate();
            }
        }
Пример #5
0
        public static void ExtractData(string tcgaDir, string targetDir, string prefix, string[] tumors, string datatype, string[] platforms, TCGASampleCode[] sampleCodes = null, bool outputCountDataOnly = false)
        {
            var tec           = TCGATechnology.Parse(datatype);
            var platforms_str = (from p in platforms select p.StringBefore("_")).Merge("_");

            var counts = outputCountDataOnly ? new[] { true } : new[] { true, false };

            foreach (var count in counts)
            {
                string resultFile;
                if (tec.HasCountData)
                {
                    resultFile = string.Format(@"{0}\{1}_{2}_{3}_{4}.tsv", targetDir, prefix, datatype, platforms_str, count ? "Count" : tec.ValueName);
                }
                else
                {
                    resultFile = string.Format(@"{0}\{1}_{2}_{3}.tsv", targetDir, prefix, datatype, platforms_str);
                }

                var options = new TCGADatatableBuilderOptions();
                options.DataType                    = datatype;
                options.TCGADirectory               = tcgaDir;
                options.TumorTypes                  = tumors.ToList();
                options.Platforms                   = platforms;
                options.IsCount                     = count;
                options.OutputFile                  = resultFile;
                options.TCGASampleCodeStrings       = sampleCodes == null ? new List <string>() : sampleCodes.ToList().ConvertAll(m => m.ShortLetterCode).ToList();
                options.WithClinicalInformationOnly = true;

                if (!options.PrepareOptions())
                {
                    throw new Exception("Error:\n" + options.ParsingErrors.Merge("\n"));
                }

                new TCGADatatableBuilder(options).Process();

                if (!tec.HasCountData)
                {
                    break;
                }
            }
        }
        public TCGADataDownloaderUI()
        {
            InitializeComponent();

            targetDir.SetDirectoryArgument("DataDirectory", "TCGA Data Target");
            xmlFile.FileArgument = new OpenFileArgument("TCGA Tree Xml Format", "xml");

            if (!SystemUtils.IsLinux)
            {
                zip7File.Visible      = true;
                zip7File.Required     = true;
                zip7File.FileArgument = new OpenFileArgument("7zip execute", "exe");
            }
            else
            {
                zip7File.Visible  = false;
                zip7File.Required = false;
            }

            lbDataTypes.Items.AddRange(TCGATechnology.GetTechnologyNames().ToArray());

            this.Text = Constants.GetSQHTitle(Title, Version);
        }
Пример #7
0
 public ITCGATechnology GetTechnology()
 {
     return(TCGATechnology.Parse(this.DataType));
 }
Пример #8
0
        public override bool PrepareOptions()
        {
            if (!Directory.Exists(this.TCGADirectory))
            {
                ParsingErrors.Add(string.Format("Directory not exists {0}.", this.TCGADirectory));
                return(false);
            }

            try
            {
                TCGATechnology.Parse(this.DataType);
            }
            catch (Exception ex)
            {
                ParsingErrors.Add(ex.Message);
                return(false);
            }

            foreach (var tumor in this.TumorTypes)
            {
                var tumordir = this.TCGADirectory + "/" + tumor;
                if (!Directory.Exists(tumordir))
                {
                    ParsingErrors.Add(string.Format("Directory not exists {0}.", tumordir));
                    return(false);
                }
            }

            if (TCGASampleCodeStrings == null || TCGASampleCodeStrings.Count == 0)
            {
                TCGASampleCodeStrings = (from v in TCGASampleCode.GetSampleCodes()
                                         select v.ShortLetterCode).ToList();
            }
            else
            {
                try
                {
                    GetTCGASampleCodes();
                }
                catch (Exception ex)
                {
                    ParsingErrors.Add(ex.Message);
                    return(false);
                }
            }

            try
            {
                GetTechnology();
            }
            catch (Exception ex)
            {
                ParsingErrors.Add(ex.Message);
                return(false);
            }

            if (this.Platforms == null || this.Platforms.Count == 0)
            {
                var tec = GetTechnology();
                this.Platforms = (from tumor in TumorTypes
                                  let dir = Path.Combine(this.TCGADirectory, tumor)
                                            let tecdir = tec.GetTechnologyDirectory(dir)
                                                         from subdir in Directory.GetDirectories(tecdir)
                                                         select Path.GetFileName(subdir)).Distinct().OrderBy(m => m).ToList();
            }

            return(true);
        }