예제 #1
0
        private List <Tuple <string, string, string> > GetPossibleRatios()
        {
            IReport reportPeptideRatios = _toolClient.GetReport("BLR Peptide Ratios");
            var     PeptideList         = reportPeptideRatios.Cells.Where(p => p[3] != null).Select(p => p[3]).Distinct();
            var     PossibleRatios      = from peptideN in PeptideList
                                          from peptideD in PeptideList
                                          where peptideN != peptideD
                                          select Tuple.Create(Peptide.GetPeptideShortName(peptideN),
                                                              Peptide.GetPeptideShortName(peptideD),
                                                              String.Format("{0}/{1}", Peptide.GetPeptideShortName(peptideN), Peptide.GetPeptideShortName(peptideD)));

            return(PossibleRatios.ToList());
        }
예제 #2
0
        private static void SelectLink(string row, int linkColumn)
        {
            if (string.IsNullOrEmpty(row))
            {
                _toolClient.SetDocumentLocation(null);
                return;
            }

            var report = _toolClient.GetReport("Peak Area");
            var link   = report.Cells[int.Parse(row)][linkColumn];

            _toolClient.SetDocumentLocation(DocumentLocation.Parse(link));
        }
예제 #3
0
파일: MainForm.cs 프로젝트: zrolfs/pwiz
        /// <summary>
        /// Create bar graph showing peak areas.
        /// </summary>
        private void CreateGraph()
        {
            if (_toolClient == null)
            {
                return;
            }

            // Retrieve the current report.
            IReport report = _toolClient.GetReport("Peak Area"); // Not L10N

            // Get the same report, more dynamically.
            var reportStream = typeof(MainForm).Assembly.GetManifestResourceStream("ExampleInteractiveTool.tool_inf.ExampleTool_report.skyr"); // Not L10N

            if (reportStream == null)
            {
                return;
            }
            var     reader  = new StreamReader(reportStream);
            IReport report2 = _toolClient.GetReportFromDefinition(reader.ReadToEnd());

            AssertReportsEquals(report, report2);

            _peptides       = new List <string>();
            _peptideLinks   = new List <string>();
            _replicateLinks = new List <string>();
            var replicates   = new List <string>();
            var peptideAreas = new Dictionary <string, double>();

            foreach (var row in report.Cells)
            {
                // Get report fields.
                var peptideName       = row[0];
                var peakArea          = row[1];
                var peptideLocation   = row[2];
                var replicateName     = row[3];
                var replicateLocation = row[4];

                // Get the name of this peptide.
                double area;
                if (string.IsNullOrWhiteSpace(peptideName) || !double.TryParse(peakArea, out area))
                {
                    continue;
                }

                if (_selectedReplicate == replicateName || _selectedReplicate == "All") // Not L10N
                {
                    // Add area to sum that was previously created.
                    if (peptideAreas.ContainsKey(peptideName))
                    {
                        peptideAreas[peptideName] += area;
                    }

                    // Create a sum for a new peptide.
                    else
                    {
                        _peptides.Add(peptideName);
                        _peptideLinks.Add(peptideLocation);
                        _replicateLinks.Add(replicateLocation);
                        peptideAreas[peptideName] = area;
                    }
                }

                // Record unique replicate names.
                if (!replicates.Contains(replicateName))
                {
                    replicates.Add(replicateName);
                }
            }

            // Rebuild Replicates menu.
            var items = replicatesToolStripMenuItem.DropDownItems;

            items.Clear();
            items.Add("All"); // Not L10N
            items.Add("-");   // Not L10N
            replicates.Sort();
            foreach (var replicate in replicates)
            {
                items.Add(replicate);
            }

            // Put a check on the selected replicate.
            if (!replicates.Contains(_selectedReplicate))
            {
                _selectedReplicate = "All"; // Not L10N
            }
            SelectReplicate(_selectedReplicate);

            // Create array of peak areas in same order as peptide names.
            var areas = new double[_peptides.Count];

            for (int i = 0; i < areas.Length; i++)
            {
                areas[i] = peptideAreas[_peptides[i]];
            }

            // Generate unique prefixes for each peptide name.
            var prefixGenerator = new UniquePrefixGenerator(_peptides, 3);

            // Create bar graph showing summed peak area for each peptide.
            _graph.CreateBars(_peptides.Select(prefixGenerator.GetUniquePrefix).ToArray(), areas);
        }