Beispiel #1
0
        /// <summary>
        /// Create the image.
        /// </summary>
        /// <param name="directory">The directory the image should be saved to.</param>
        /// <param name="result">The result the image should be created from.</param>
        private void CreateImage(string directory, KeyValuePair <QuantResult, KeyValuePair <MsSpectrum, MsSpectrum> > result)
        {
            KeyValuePair <MsSpectrum, MsSpectrum> spectraData = result.Value;
            // Get the filename
            string baseFilename = string.Format("{0}_{1}_{2}", result.Key.Protein.Split('|')[0], result.Key.Sequence, result.Key.ValidationBy);
            string filename     = FileReader.GenerateFileName(directory, baseFilename, "tiff");

            // Append the file to the annotation writer
            if (_createAnnotationFile)
            {
                _annotationWriter.AppendLine($"** {filename.Split(new string[] { @"\" }, System.StringSplitOptions.None).Last() } **");
            }

            // From the validation type, create the graph
            if (result.Key.ValidationBy == "Lone")
            {
                ValidationUIUtilities.CreateLoneCitMs2Chart(chartMS2, spectraData.Key);
                ValidationUIUtilities.AnnotateSingleSpectra(chartMS2, spectraData.Key, HelperUtilities.CreateAAArray(result.Key.Sequence), true, _createAnnotationFile, _annotationWriter);
            }
            else
            {
                ValidationUIUtilities.CreatePairedMs2Chart(chartMS2, spectraData.Key, spectraData.Value);
                ValidationUIUtilities.AnnotatePairedSpectra(chartMS2, spectraData.Key, spectraData.Value, HelperUtilities.CreateAAArray(result.Key.Sequence), _createAnnotationFile, _annotationWriter);
            }

            // Clear the old titles
            chartMS2.Titles.Clear();
            // And add a new one
            chartMS2.Titles.Add(string.Format("{0}_{1}_{2}", result.Key.Protein.Split('|')[0], result.Key.Sequence, result.Key.ValidationBy));
            chartMS2.Titles[0].Font = new Font(chartMS2.Titles[0].Font.FontFamily, 13F);
            chartMS2.Titles[0].IsDockedInsideChartArea = false;
            chartMS2.Titles[0].Docking       = Docking.Top;
            chartMS2.Titles[0].DockingOffset = 10;

            chartMS2.SaveImage(filename, ChartImageFormat.Tiff);
            ValidationUIUtilities.ClearChart(chartMS2);
            chartMS2.Annotations.Clear();
        }