//<SnippetHandler>
        private void OnAnnotationsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var listBox = sender as ListBox;

            if (listBox == null)
            {
                return;
            }

            var comment = listBox.SelectedItem as Annotation;

            if (comment == null)
            {
                return;
            }

            // IAnchorInfo info;
            // service is an AnnotationService object
            // comment is an Annotation object
            _info = AnnotationHelper.GetAnchorInfo(_service, comment);
            var resolvedAnchor = _info.ResolvedAnchor as TextAnchor;

            if (resolvedAnchor != null)
            {
                var textPointer = resolvedAnchor.BoundingStart as TextPointer;
                if (textPointer != null && textPointer.Paragraph != null)
                {
                    textPointer.Paragraph.BringIntoView();
                }
            }
        }
예제 #2
0
        public void SetGroupIndex(int index)
        {
            if (index == 0)
            {
                Program.MainWindow.SetAreaCVAnnotation(null, false);
                var results = _graphSummary.DocumentUIContainer.DocumentUI.MeasuredResults;
                toolStripNumericDetections.NumericUpDownControl.Maximum =
                    results != null ? results.Chromatograms.Count : 0;
            }
            else
            {
                Program.MainWindow.SetAreaCVAnnotation(toolStripComboGroup.Items[index], false);
                var document     = _graphSummary.DocumentUIContainer.DocumentUI;
                var groupByGroup =
                    ReplicateValue.FromPersistedString(document.Settings, AreaGraphController.GroupByGroup);
                toolStripNumericDetections.NumericUpDownControl.Maximum = AnnotationHelper
                                                                          .GetReplicateIndices(document, groupByGroup, AreaGraphController.GroupByAnnotation).Length;
            }

            if (IsCurrentDataCached())
            {
                _graphSummary.UpdateUIWithoutToolbar();
                return;
            }

            _timer.Stop();
            _timer.Start();
        }
예제 #3
0
        //This method is called when the 'Add Highlight' context menu is
        //clicked by the user on either of the two document viewer controls.
        private void DocumentViewer_AddHighlight(object sender,
                                                 RoutedEventArgs e)
        {
            //Work out which document viewer we are dealing with
            //and get the appropriate store.
            string tag = ((MenuItem)sender).Tag.ToString();

            AnnotationService annotationService =
                tag == "fixed"
                ? fixedAnnotationService
                : flowAnnotationService;

            //Get the current user's name as the author
            string userName = System.Environment.UserName;

            try
            {
                //Creates a yellow highlight
                AnnotationHelper.CreateHighlightForSelection(
                    annotationService, userName, Brushes.Yellow);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Please select some text to highlight.");
            }
        }
        protected void AddNote_Click(object sender, EventArgs e)
        {
            var regardingContact = Permit.GetAttributeValue <EntityReference>(RegardingContactFieldName);

            if (regardingContact == null || Contact == null || regardingContact.Id != Contact.Id)
            {
                throw new InvalidOperationException("Unable to retrieve the order.");
            }

            if (!string.IsNullOrEmpty(NewNoteText.Text) || (NewNoteAttachment.PostedFile != null && NewNoteAttachment.PostedFile.ContentLength > 0))
            {
                var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(
                    requestContext: Request.RequestContext, portalName: PortalName);

                var dataAdapter = new AnnotationDataAdapter(dataAdapterDependencies);

                var annotation = new Annotation
                {
                    NoteText  = string.Format("{0}{1}", AnnotationHelper.WebAnnotationPrefix, NewNoteText.Text),
                    Subject   = AnnotationHelper.BuildNoteSubject(dataAdapterDependencies),
                    Regarding = Permit.ToEntityReference()
                };
                if (NewNoteAttachment.PostedFile != null && NewNoteAttachment.PostedFile.ContentLength > 0)
                {
                    annotation.FileAttachment = AnnotationDataAdapter.CreateFileAttachment(new HttpPostedFileWrapper(NewNoteAttachment.PostedFile));
                }
                dataAdapter.CreateAnnotation(annotation);
            }

            Response.Redirect(Request.Url.PathAndQuery);
        }
예제 #5
0
        private void cmdShowAllAnotations_Click(object sender, RoutedEventArgs e)
        {
            IList <Annotation> annotations = service.Store.GetAnnotations();

            foreach (Annotation annotation in annotations)
            {
                // Check for text information.
                if (annotation.Cargos.Count > 1)
                {
                    // Decode the note text.
                    string base64Text = annotation.Cargos[1].Contents[0].InnerText;
                    byte[] decoded    = Convert.FromBase64String(base64Text);

                    // Write the decoded text to a stream.
                    MemoryStream m = new MemoryStream(decoded);

                    // Get the inner text.
                    //Section section = (Section)XamlReader.Load(m);
                    //TextRange range = new TextRange(section.ContentStart, section.ContentEnd);
                    //string annotationText = range.Text;
                    //m.Position = 0;

                    // Read the full XML.
                    StreamReader r = new StreamReader(m);
                    string       annotationXaml = r.ReadToEnd();
                    r.Close();
                    MessageBox.Show(annotationXaml);

                    // Get the annotated text.
                    IAnchorInfo anchorInfo     = AnnotationHelper.GetAnchorInfo(service, annotation);
                    TextAnchor  resolvedAnchor = anchorInfo.ResolvedAnchor as TextAnchor;
                    if (resolvedAnchor != null)
                    {
                        TextPointer startPointer = (TextPointer)resolvedAnchor.BoundingStart;
                        TextPointer endPointer   = (TextPointer)resolvedAnchor.BoundingEnd;

                        TextRange range = new TextRange(startPointer, endPointer);
                        MessageBox.Show(range.Text);
                    }
                }
            }

            // Code to print annotations.
            //PrintDialog dialog = new PrintDialog();
            //bool? result = dialog.ShowDialog();
            //if (result != null && result.Value)
            //{
            //    System.Windows.Xps.XpsDocumentWriter writer = System.Printing.PrintQueue.CreateXpsDocumentWriter(dialog.PrintQueue);

            //    AnnotationDocumentPaginator adp = new AnnotationDocumentPaginator(
            //                            ((IDocumentPaginatorSource)docReader.Document).DocumentPaginator,
            //                            service.Store);
            //    writer.Write(adp);
            //}
        }
예제 #6
0
        internal static void HighlightText(this FlowDocumentScrollViewer viewer, AnnotationService service, int offset, int length)
        {
            var brush    = new SolidColorBrush(Color.FromArgb(127, (byte)random.Next(200), (byte)random.Next(200), (byte)random.Next(200)));
            var startPos = viewer.Document.ContentStart.GetOffsetTextPointer(offset);
            var endPos   = startPos.GetOffsetTextPointer(length);

            viewer.Selection.Select(startPos, endPos);

            AnnotationHelper.CreateHighlightForSelection(service, String.Empty, brush);
            //textRange.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
        }
예제 #7
0
		// Function to create an ink note
		private void CreateInkNote(object sender, RoutedEventArgs e)
		{
			try
			{
				AnnotationHelper.CreateInkStickyNoteForSelection(currentAnnotService,
					"Vista user");
			}
			catch (InvalidOperationException)
			{
				// If someone tries to highlight without actually selecting text, do nothing.
			}
		}
        private void OnShowAllAnotations(object sender, RoutedEventArgs e)
        {
            var annotations = _service.Store.GetAnnotations();

            foreach (var annotation in annotations)
            {
                if (annotation.Cargos.Count > 1)
                {
                    // Decode the note text.
                    var base64Text = annotation.Cargos[1].Contents[0].InnerText;
                    var decoded    = Convert.FromBase64String(base64Text);

                    // Write the decoded text to a stream.
                    string annotationXaml;
                    using (var stream = new MemoryStream(decoded))
                        using (var reader = new StreamReader(stream))
                        {
                            annotationXaml = reader.ReadToEnd();
                        }

                    MessageBox.Show(annotationXaml);

                    // Get the annotated text.
                    var anchorInfo     = AnnotationHelper.GetAnchorInfo(_service, annotation);
                    var resolvedAnchor = anchorInfo.ResolvedAnchor as TextAnchor;
                    if (resolvedAnchor != null)
                    {
                        var startPointer = (TextPointer)resolvedAnchor.BoundingStart;
                        var endPointer   = (TextPointer)resolvedAnchor.BoundingEnd;
                        var range        = new TextRange(startPointer, endPointer);
                        MessageBox.Show(range.Text);
                    }
                }
            }

            #region Code to print annotations

            //PrintDialog dialog = new PrintDialog();
            //bool? result = dialog.ShowDialog();
            //if (result != null && result.Value)
            //{
            //    System.Windows.Xps.XpsDocumentWriter writer = System.Printing.PrintQueue.CreateXpsDocumentWriter(dialog.PrintQueue);

            //    AnnotationDocumentPaginator adp = new AnnotationDocumentPaginator(
            //                            ((IDocumentPaginatorSource)docReader.Document).DocumentPaginator,
            //                            service.Store);
            //    writer.Write(adp);
            //}

            #endregion
        }
예제 #9
0
        //<SnippetHandler>
        void annotationsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Annotation comment = (sender as ListBox).SelectedItem as Annotation;

            if (comment != null)
            {
                // IAnchorInfo info;
                // service is an AnnotationService object
                // comment is an Annotation object
                info = AnnotationHelper.GetAnchorInfo(this.service, comment);
                TextAnchor  resolvedAnchor = info.ResolvedAnchor as TextAnchor;
                TextPointer textPointer    = (TextPointer)resolvedAnchor.BoundingStart;
                textPointer.Paragraph.BringIntoView();
            }
        }
예제 #10
0
 // ------------------------ OnAddBookmark() ---------------------------
 void OnAddBookmark(object sender, RoutedEventArgs args)
 {
     try
     {
         System.Windows.Media.Color col     = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#A6FFFF00");
         System.Windows.Media.Brush myBrush = new SolidColorBrush(col);
         string userName = System.Windows.Forms.SystemInformation.UserName;
         AnnotationHelper.CreateHighlightForSelection(
             _annServ, userName, myBrush);
     }
     catch (InvalidOperationException)
     {
         return;
     }
     //AddBookmarkOrComment(BookmarkList);
 }
예제 #11
0
        private void  DocumentViewer_AddComment(object sender, RoutedEventArgs e)
        {
            //Get the current user's name as the author
            string userName = System.Environment.UserName;

            //The AnnotationHelper.CreateTextStickyNoteForSelection method
            //will throw an exception if no text is selected.
            try
            {
                AnnotationHelper.CreateTextStickyNoteForSelection(fixedAnnotationService, userName);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Please select some text to annotate.");
            }
        }
예제 #12
0
        private string GetAnnotationText(Annotation annotation)
        {
            var anchorInfo     = AnnotationHelper.GetAnchorInfo(service, annotation);
            var resolvedAnchor = anchorInfo.ResolvedAnchor as TextAnchor;

            if (resolvedAnchor != null)
            {
                var startPointer = (TextPointer)resolvedAnchor.BoundingStart;
                var endPointer   = (TextPointer)resolvedAnchor.BoundingEnd;
                var range        = new TextRange(startPointer, endPointer);

                return(range.Text);
            }

            return(null);
        }
            protected void SetPropertyValues(IAnnotation annotation, DataAdapterDependencies dataAdapterDependencies)
            {
                CreatedOn        = annotation.CreatedOn;
                CreatedOnDisplay = CreatedOn.ToString(DateTimeClientFormat);
                var text = annotation.NoteText;

                Text            = AnnotationHelper.FormatNoteText(text).ToString();
                UnformattedText = text.Replace(AnnotationHelper.WebAnnotationPrefix, string.Empty);
                if (annotation.FileAttachment != null)
                {
                    AttachmentFileName    = annotation.FileAttachment.FileName;
                    HasAttachment         = annotation.FileAttachment != null;
                    AttachmentContentType = annotation.FileAttachment.MimeType;
                    AttachmentUrl         = HasAttachment
                                                ? annotation.Entity.GetFileAttachmentUrl(dataAdapterDependencies.GetWebsite())
                                                : string.Empty;
                    AttachmentSize        = annotation.FileAttachment.FileSize;
                    AttachmentSizeDisplay = AttachmentSize.ToString();
                    AttachmentIsImage     = HasAttachment &&
                                            (new List <string> {
                        "image/jpeg", "image/gif", "image/png"
                    }).Contains(AttachmentContentType);
                }
                var subject = annotation.Subject;

                Subject   = subject;
                IsPrivate = AnnotationHelper.GetNotePrivacy(annotation);
                var noteContact = AnnotationHelper.GetNoteContact(subject);
                var user        = dataAdapterDependencies.GetPortalUser();

                IsPostedByCurrentUser = noteContact != null && user != null && noteContact.Id == user.Id;
                PostedByName          = noteContact == null?AnnotationHelper.GetNoteCreatedByName(annotation) : noteContact.Name;

                if (CanWrite)
                {
                    CanWrite = IsPostedByCurrentUser;
                }
                if (CanDelete)
                {
                    CanDelete = IsPostedByCurrentUser;
                }
                DisplayToolbar = CanWrite || CanDelete;
            }
예제 #14
0
        /// <summary>
        /// Gets existing views for pages from start to end. Scans only existing view to
        /// avoid loading of unloaded pages.
        /// </summary>
        /// <param name="idp">IDocumentPaginatorSource</param>
        /// <param name="startPageNumber">start page number</param>
        /// <param name="endPageNumber">end page number</param>
        /// <returns>returns a list of text views</returns>
        private static List <ITextView> ProcessMultiplePages(IDocumentPaginatorSource idp, int startPageNumber, int endPageNumber)
        {
            Invariant.Assert(idp != null, "IDocumentPaginatorSource is null");

            //now get available views
            DocumentViewerBase viewer = PathNode.GetParent(idp as DependencyObject) as DocumentViewerBase;

            Invariant.Assert(viewer != null, "DocumentViewer not found");

            // If the pages for the text segment are reversed (possibly a floater where the floater
            // reflow on to a page that comes after its anchor) we just swap them
            if (endPageNumber < startPageNumber)
            {
                int temp = endPageNumber;
                endPageNumber   = startPageNumber;
                startPageNumber = temp;
            }

            List <ITextView> res = null;

            if (idp != null && startPageNumber >= 0 && endPageNumber >= startPageNumber)
            {
                res = new List <ITextView>(endPageNumber - startPageNumber + 1);
                for (int pageNb = startPageNumber; pageNb <= endPageNumber; pageNb++)
                {
                    DocumentPageView view = AnnotationHelper.FindView(viewer, pageNb);
                    if (view != null)
                    {
                        IServiceProvider serviceProvider = view.DocumentPage as IServiceProvider;
                        if (serviceProvider != null)
                        {
                            ITextView textView = serviceProvider.GetService(typeof(ITextView)) as ITextView;
                            if (textView != null)
                            {
                                res.Add(textView);
                            }
                        }
                    }
                }
            }

            return(res);
        }
예제 #15
0
        // -------------------------- OnAddComment ----------------------------
        void OnAddComment(object sender, RoutedEventArgs args)
        {
            try
            {
                string userName = System.Windows.Forms.SystemInformation.UserName;
                AnnotationHelper.CreateTextStickyNoteForSelection(
                    _annServ, userName);
            }
            catch (InvalidOperationException)
            {
                return;
            }

            //AddBookmarkOrComment(CommentsList);
            //Annotation ann1 = _annStore.GetAnnotations()[0];
            //ColorConverter converter = new ColorConverter();
            //Nullable<Color> color = ((SolidColorBrush)Brushes.Yellow).Color;
            //ann1.Cargos[0].Contents[0].Attributes[0].Value =
            //    converter.ConvertToInvariantString(color.Value);
        }
예제 #16
0
            protected void SetPropertyValues(Entity annotation, DataAdapterDependencies dataAdapterDependencies)
            {
                var website = dataAdapterDependencies.GetWebsite();

                CreatedOn        = annotation.GetAttributeValue <DateTime?>("createdon").GetValueOrDefault();
                CreatedOnDisplay = CreatedOn.ToString(DateTimeClientFormat);
                var text = annotation.GetAttributeValue <string>("notetext");

                Text                  = AnnotationHelper.FormatNoteText(text).ToString();
                UnformattedText       = text.Replace(AnnotationHelper.WebAnnotationPrefix, string.Empty);
                AttachmentFileName    = annotation.GetAttributeValue <string>("filename");
                HasAttachment         = !string.IsNullOrEmpty(AttachmentFileName);
                AttachmentContentType = annotation.GetAttributeValue <string>("mimetype");
                AttachmentUrl         = HasAttachment ? annotation.GetFileAttachmentUrl(website) : string.Empty;
                var filesize = annotation.GetAttributeValue <int?>("filesize").GetValueOrDefault(0);

                AttachmentSize        = new FileSize(Convert.ToUInt64(filesize < 0 ? 0 : filesize));
                AttachmentSizeDisplay = AttachmentSize.ToString();
                AttachmentIsImage     = HasAttachment && (new List <string> {
                    "image/jpeg", "image/gif", "image/png"
                }).Contains(AttachmentContentType);
                var subject = annotation.GetAttributeValue <string>("subject");

                Subject   = subject;
                IsPrivate = AnnotationHelper.GetNotePrivacy(annotation);
                var noteContact = AnnotationHelper.GetNoteContact(subject);
                var user        = dataAdapterDependencies.GetPortalUser();

                IsPostedByCurrentUser = noteContact != null && user != null && noteContact.Id == user.Id;
                PostedByName          = noteContact == null?AnnotationHelper.GetNoteCreatedByName(annotation) : noteContact.Name;

                if (CanWrite)
                {
                    CanWrite = IsPostedByCurrentUser;
                }
                if (CanDelete)
                {
                    CanDelete = IsPostedByCurrentUser;
                }
                DisplayToolbar = CanWrite || CanDelete;
            }
예제 #17
0
            private IEnumerable <GraphDataProperties> GetPropertyVariants(AreaCVGraphSettings graphSettings)
            {
                SrmDocument document;

                lock (_cacheInfo)
                {
                    document = _cacheInfo.Document;
                }

                var annotationsArray = AnnotationHelper.GetPossibleAnnotations(document, graphSettings.Group);

                // Add an entry for All
                var annotations = annotationsArray.Concat(new string[] { null }).ToList();

                var normalizationMethods = new List <NormalizeOption>(NormalizeOption.AvailableNormalizeOptions(document).Prepend(NormalizeOption.NONE));

                // First cache the histograms for the current annotation
                if (annotations.Remove(graphSettings.Annotation))
                {
                    annotations.Insert(0, graphSettings.Annotation);
                }

                foreach (var n in normalizationMethods)
                {
                    if (n.IsRatioToLabel && !document.Settings.PeptideSettings.Modifications.HasHeavyModifications)
                    {
                        continue;
                    }

                    foreach (var a in annotations)
                    {
                        var minDetections = GetMinDetectionsForAnnotation(document, graphSettings, a);

                        for (var i = 2; i <= minDetections; ++i)
                        {
                            yield return(new GraphDataProperties(graphSettings.Group, n, a, i));
                        }
                    }
                }
            }
        protected void Application_Start()
        {
            HttpRuntimeSetting.SameAppDomainAppId();

            UnityConfig.RegisterComponents();

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            ViewEngingSetting.Config();
            DisplayModelSetting.Config();

            DependencyResolver.Current.GetService <ILog>().Config();

            AnnotationHelper.AutoMap();
            ModelBinders.Binders.DefaultBinder = new SmartModelBinder();
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(DataTypeAttribute), typeof(DataTypeValidator));
            //AppFabric Caching
            //DataCache m_cache = CacheUtil.GetCache();
        }
예제 #19
0
        private void DocumentViewer_ClearHighlight(object sender, RoutedEventArgs e)
        {
            //Work out which document viewer we are dealing with
            //and get the appropriate store.
            string tag = ((MenuItem)sender).Tag.ToString();

            AnnotationService annotationService =
                tag == "fixed"
                ? fixedAnnotationService
                : flowAnnotationService;

            try
            {
                //Clear the selected text of any highlights.
                AnnotationHelper.ClearHighlightsForSelection(
                    annotationService);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Please select some text to clear.");
            }
        }
예제 #20
0
        // Token: 0x06007C3F RID: 31807 RVA: 0x0022F168 File Offset: 0x0022D368
        private static List <ITextView> ProcessMultiplePages(IDocumentPaginatorSource idp, int startPageNumber, int endPageNumber)
        {
            Invariant.Assert(idp != null, "IDocumentPaginatorSource is null");
            DocumentViewerBase documentViewerBase = PathNode.GetParent(idp as DependencyObject) as DocumentViewerBase;

            Invariant.Assert(documentViewerBase != null, "DocumentViewer not found");
            if (endPageNumber < startPageNumber)
            {
                int num = endPageNumber;
                endPageNumber   = startPageNumber;
                startPageNumber = num;
            }
            List <ITextView> list = null;

            if (idp != null && startPageNumber >= 0 && endPageNumber >= startPageNumber)
            {
                list = new List <ITextView>(endPageNumber - startPageNumber + 1);
                for (int i = startPageNumber; i <= endPageNumber; i++)
                {
                    DocumentPageView documentPageView = AnnotationHelper.FindView(documentViewerBase, i);
                    if (documentPageView != null)
                    {
                        IServiceProvider serviceProvider = documentPageView.DocumentPage as IServiceProvider;
                        if (serviceProvider != null)
                        {
                            ITextView textView = serviceProvider.GetService(typeof(ITextView)) as ITextView;
                            if (textView != null)
                            {
                                list.Add(textView);
                            }
                        }
                    }
                }
            }
            return(list);
        }
예제 #21
0
        public void OnDocumentChanged(SrmDocument oldDocument, SrmDocument newDocument)
        {
            var settingsNew = newDocument.Settings;
            var settingsOld = oldDocument.Settings;

            if (GraphSummary.Type == GraphTypeSummary.histogram || GraphSummary.Type == GraphTypeSummary.histogram2d)
            {
                if (GroupByGroup != null && !ReferenceEquals(settingsNew.DataSettings.AnnotationDefs, settingsOld.DataSettings.AnnotationDefs))
                {
                    var groups = AnnotationHelper.FindGroupsByTarget(settingsNew, AnnotationDef.AnnotationTarget.replicate);
                    // The group we were grouping by has been removed
                    if (!groups.Contains(GroupByGroup))
                    {
                        GroupByGroup = GroupByAnnotation = null;
                    }
                }

                if (GroupByAnnotation != null && settingsNew.HasResults && settingsOld.HasResults &&
                    !ReferenceEquals(settingsNew.MeasuredResults.Chromatograms, settingsOld.MeasuredResults.Chromatograms))
                {
                    var annotations = AnnotationHelper.GetPossibleAnnotations(settingsNew, GroupByGroup, AnnotationDef.AnnotationTarget.replicate);

                    // The annotation we were grouping by has been removed
                    if (!annotations.Contains(GroupByAnnotation))
                    {
                        GroupByAnnotation = null;
                    }

                    var paneInfo = GraphSummary.GraphPanes.FirstOrDefault() as IAreaCVHistogramInfo;
                    if (paneInfo != null)
                    {
                        paneInfo.Cache.Cancel();
                    }
                }
            }
        }
 public virtual void AddNote(string text, string fileName = null, string contentType = null, byte[] fileContent = null, EntityReference ownerId = null)
 {
     try
     {
         var da         = new AnnotationDataAdapter(Dependencies);
         var annotation = new Annotation
         {
             Subject   = AnnotationHelper.BuildNoteSubject(Dependencies),
             NoteText  = string.Format("{0}{1}", AnnotationHelper.WebAnnotationPrefix, text),
             Regarding = Incident,
             Owner     = ownerId
         };
         if (fileContent != null && fileContent.Length > 0 && !string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(contentType))
         {
             annotation.FileAttachment = AnnotationDataAdapter.CreateFileAttachment(EnsureValidFileName(fileName), contentType, fileContent);
         }
         da.CreateAnnotation(annotation);
     }
     catch (Exception e)
     {
         WebEventSource.Log.GenericErrorException(new Exception("Create annotation error", e));
         throw;
     }
 }
예제 #23
0
        public AreaCVGraphData(SrmDocument document, AreaCVGraphSettings graphSettings, CancellationToken?token = null)
        {
            _graphSettings = graphSettings;

            if (document == null || !document.Settings.HasResults)
            {
                IsValid = false;
                return;
            }

            var annotations = AnnotationHelper.GetPossibleAnnotations(document.Settings, graphSettings.Group, AnnotationDef.AnnotationTarget.replicate);

            if (!annotations.Any() && AreaGraphController.GroupByGroup == null)
            {
                annotations = new string[] { null }
            }
            ;

            var    data         = new List <InternalData>();
            double?qvalueCutoff = null;

            if (AreaGraphController.ShouldUseQValues(document))
            {
                qvalueCutoff = _graphSettings.QValueCutoff;
            }
            var hasHeavyMods       = document.Settings.PeptideSettings.Modifications.HasHeavyModifications;
            var hasGlobalStandards = document.Settings.HasGlobalStandardArea;

            var ms1  = _graphSettings.MsLevel == AreaCVMsLevel.precursors;
            var best = _graphSettings.Transitions == AreaCVTransitions.best;

            var replicates = document.MeasuredResults.Chromatograms.Count;
            var areas      = new List <AreaInfo>(replicates);

            MedianInfo medianInfo = null;

            if (graphSettings.NormalizationMethod == AreaCVNormalizationMethod.medians)
            {
                medianInfo = CalculateMedianAreas(document);
            }

            foreach (var peptideGroup in document.MoleculeGroups)
            {
                foreach (var peptide in peptideGroup.Molecules)
                {
                    foreach (var transitionGroupDocNode in peptide.TransitionGroups)
                    {
                        if (graphSettings.PointsType == PointsTypePeakArea.decoys != transitionGroupDocNode.IsDecoy)
                        {
                            continue;
                        }

                        foreach (var a in annotations)
                        {
                            areas.Clear();

                            if (a != _graphSettings.Annotation && (_graphSettings.Group == null || _graphSettings.Annotation != null))
                            {
                                continue;
                            }

                            foreach (var i in AnnotationHelper.GetReplicateIndices(document.Settings, _graphSettings.Group, a))
                            {
                                if (token.HasValue && token.Value.IsCancellationRequested)
                                {
                                    IsValid = false;
                                    return;
                                }

                                var groupChromInfo = transitionGroupDocNode.GetSafeChromInfo(i)
                                                     .FirstOrDefault(c => c.OptimizationStep == 0);

                                if (qvalueCutoff.HasValue)
                                {
                                    if (!(groupChromInfo.QValue.HasValue && groupChromInfo.QValue.Value < qvalueCutoff.Value))
                                    {
                                        continue;
                                    }
                                }

                                var index   = i;
                                var sumArea = transitionGroupDocNode.Transitions.Where(t =>
                                {
                                    if (ms1 != t.IsMs1 || !t.ExplicitQuantitative)
                                    {
                                        return(false);
                                    }

                                    var chromInfo = t.GetSafeChromInfo(index).FirstOrDefault(c => c.OptimizationStep == 0);
                                    return(chromInfo != null && (!best || chromInfo.RankByLevel == 1));
                                    // ReSharper disable once PossibleNullReferenceException
                                }).Sum(t => (double)t.GetSafeChromInfo(index).FirstOrDefault(c => c.OptimizationStep == 0).Area);

                                if (!groupChromInfo.Area.HasValue)
                                {
                                    continue;
                                }

                                double area           = sumArea;
                                var    normalizedArea = area;
                                if (graphSettings.NormalizationMethod == AreaCVNormalizationMethod.medians)
                                {
                                    normalizedArea /= medianInfo.Medians[i] / medianInfo.MedianMedian;
                                }
                                else if (graphSettings.NormalizationMethod == AreaCVNormalizationMethod.global_standards && hasGlobalStandards)
                                {
                                    normalizedArea = NormalizeToGlobalStandard(document, transitionGroupDocNode, i, area);
                                }
                                else if (graphSettings.NormalizationMethod == AreaCVNormalizationMethod.ratio && hasHeavyMods && graphSettings.RatioIndex >= 0)
                                {
                                    var ci = transitionGroupDocNode.GetSafeChromInfo(i).FirstOrDefault(c => c.OptimizationStep == 0);
                                    if (ci != null)
                                    {
                                        var ratioValue = ci.GetRatio(_graphSettings.RatioIndex);
                                        if (ratioValue != null)
                                        {
                                            normalizedArea /= ratioValue.Ratio;
                                        }
                                    }
                                }

                                areas.Add(new AreaInfo(area, normalizedArea));
                            }

                            if (qvalueCutoff.HasValue && areas.Count < graphSettings.MinimumDetections)
                            {
                                continue;
                            }

                            AddToInternalData(data, areas, peptideGroup, peptide, transitionGroupDocNode, a);
                        }
                    }
                }
            }

            Data = ImmutableList <CVData> .ValueOf(data.GroupBy(i => i, (key, grouped) =>
            {
                var groupedArray = grouped.ToArray();
                return(new CVData(
                           groupedArray.Select(idata => new PeptideAnnotationPair(idata.PeptideGroup, idata.Peptide, idata.TransitionGroup, idata.Annotation, idata.CV)),
                           key.CVBucketed, key.Area, groupedArray.Length));
            }).OrderBy(d => d.CV));

            CalculateStats();

            if (IsValid)
            {
                MedianCV = new Statistics(data.Select(d => d.CV)).Median();
            }
        }
        public ActionResult AddNote(string regardingEntityLogicalName, string regardingEntityId, string text, bool isPrivate = false, HttpPostedFileBase file = null, string attachmentSettings = null)
        {
            if (string.IsNullOrWhiteSpace(text) || string.IsNullOrWhiteSpace(StringHelper.StripHtml(text)))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.ExpectationFailed, ResourceManager.GetString("Required_Field_Error").FormatWith(ResourceManager.GetString("Note_DefaultText"))));
            }

            Guid regardingId;

            Guid.TryParse(regardingEntityId, out regardingId);
            var    regarding           = new EntityReference(regardingEntityLogicalName, regardingId);
            string portalName          = null;
            var    portalContext       = PortalCrmConfigurationManager.CreatePortalContext();
            var    languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

            if (!string.IsNullOrWhiteSpace(languageCodeSetting))
            {
                int languageCode;
                if (int.TryParse(languageCodeSetting, out languageCode))
                {
                    portalName = languageCode.ToString(CultureInfo.InvariantCulture);
                }
            }

            var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
            var serviceContext          = dataAdapterDependencies.GetServiceContext();
            var user = Request.GetOwinContext().GetUser();

            var dataAdapter = new AnnotationDataAdapter(dataAdapterDependencies);
            var settings    = GetAnnotationSettings(serviceContext, attachmentSettings);

            var annotation = new Annotation
            {
                NoteText  = string.Format("{0}{1}", AnnotationHelper.WebAnnotationPrefix, text),
                Subject   = AnnotationHelper.BuildNoteSubject(serviceContext, user.ContactId, isPrivate),
                Regarding = regarding
            };

            if (file != null && file.ContentLength > 0)
            {
                annotation.FileAttachment = AnnotationDataAdapter.CreateFileAttachment(file, settings.StorageLocation);
            }

            var result = (AnnotationCreateResult)dataAdapter.CreateAnnotation(annotation, settings);

            if (!result.PermissionsExist)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, ResourceManager.GetString("Entity_Permissions_Have_Not_Been_Defined_Message")));
            }

            if (!result.CanCreate)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Entity_Permissions"), "create notes")));
            }

            if (!result.CanAppendTo)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Entity_Permissions"), "append to record")));
            }

            if (!result.CanAppend)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, string.Format(ResourceManager.GetString("No_Entity_Permissions"), "append notes")));
            }

            return(new HttpStatusCodeResult(HttpStatusCode.Created));
        }
예제 #25
0
        public override void UpdateUI()
        {
            var document = _graphSummary.DocumentUIContainer.DocumentUI;

            var groupsVisible = AreaGraphController.GroupByGroup != null;

            toolStripLabel1.Visible = toolStripComboGroup.Visible = groupsVisible;

            var detectionsVisiblePrev = toolStripLabel2.Visible && toolStripNumericDetections.Visible && toolStripLabel3.Visible;
            var detectionsVisible     = AreaGraphController.ShouldUseQValues(document);

            toolStripLabel2.Visible = toolStripNumericDetections.Visible = toolStripLabel3.Visible = detectionsVisible;

            if (detectionsVisible)
            {
                toolStripNumericDetections.NumericUpDownControl.Minimum = 2;

                if (AreaGraphController.GroupByGroup == null || AreaGraphController.GroupByAnnotation == null)
                {
                    toolStripNumericDetections.NumericUpDownControl.Maximum = document.MeasuredResults.Chromatograms.Count;
                }
                else
                {
                    toolStripNumericDetections.NumericUpDownControl.Maximum = AnnotationHelper.GetReplicateIndices(document.Settings, AreaGraphController.GroupByGroup, AreaGraphController.GroupByAnnotation).Length;
                }

                if (!detectionsVisiblePrev)
                {
                    toolStripNumericDetections.NumericUpDownControl.Value = 2;
                }
            }

            if (groupsVisible)
            {
                var annotations = new[] { Resources.GraphSummary_UpdateToolbar_All }.Concat(AnnotationHelper.GetPossibleAnnotations(document.Settings, AreaGraphController.GroupByGroup, AnnotationDef.AnnotationTarget.replicate)).ToArray();

                toolStripComboGroup.Items.Clear();
                // ReSharper disable once CoVariantArrayConversion
                toolStripComboGroup.Items.AddRange(annotations);

                if (AreaGraphController.GroupByAnnotation != null)
                {
                    toolStripComboGroup.SelectedItem = AreaGraphController.GroupByAnnotation;
                }
                else
                {
                    toolStripComboGroup.SelectedIndex = 0;
                }
            }

            var mods          = _graphSummary.DocumentUIContainer.DocumentUI.Settings.PeptideSettings.Modifications;
            var standardTypes = mods.RatioInternalStandardTypes;

            toolStripComboNormalizedTo.Items.Clear();
            _standardTypeCount = 0;

            if (mods.HasHeavyModifications)
            {
                // ReSharper disable once CoVariantArrayConversion
                toolStripComboNormalizedTo.Items.AddRange(standardTypes.Select(s => s.Title).ToArray());
                _standardTypeCount = standardTypes.Count;
            }

            var hasGlobalStandard = _graphSummary.DocumentUIContainer.DocumentUI.Settings.HasGlobalStandardArea;

            if (hasGlobalStandard)
            {
                toolStripComboNormalizedTo.Items.Add(Resources.AreaCVToolbar_UpdateUI_Global_standards);
            }
            toolStripComboNormalizedTo.Items.Add(Resources.AreaCVToolbar_UpdateUI_Medians);
            toolStripComboNormalizedTo.Items.Add(Resources.AreaCVToolbar_UpdateUI_None);

            if (AreaGraphController.NormalizationMethod == AreaCVNormalizationMethod.ratio)
            {
                toolStripComboNormalizedTo.SelectedIndex = AreaGraphController.AreaCVRatioIndex;
            }
            else
            {
                var index = _standardTypeCount + (int)AreaGraphController.NormalizationMethod;
                if (!hasGlobalStandard)
                {
                    --index;
                }
                toolStripComboNormalizedTo.SelectedIndex = index;
            }
        }
예제 #26
0
        public AreaCVRefinementData(SrmDocument document, AreaCVRefinementSettings settings,
                                    CancellationToken?token = null)
        {
            _settings = settings;
            if (document == null || !document.Settings.HasResults)
            {
                return;
            }

            var replicates  = document.MeasuredResults.Chromatograms.Count;
            var areas       = new List <AreaInfo>(replicates);
            var annotations = AnnotationHelper.GetPossibleAnnotations(document.Settings, settings.Group, AnnotationDef.AnnotationTarget.replicate);

            if (!annotations.Any() && settings.Group == null)
            {
                annotations = new string[] { null }
            }
            ;

            _internalData = new List <InternalData>();
            var hasHeavyMods       = document.Settings.PeptideSettings.Modifications.HasHeavyModifications;
            var hasGlobalStandards = document.Settings.HasGlobalStandardArea;
            var ms1 = settings.MsLevel == AreaCVMsLevel.precursors;

            // Avoid using not-MS1 with a document that is only MS1
            if (!ms1 && document.MoleculeTransitions.All(t => t.IsMs1))
            {
                ms1 = true;
            }
            double?qvalueCutoff = null;

            if (ShouldUseQValues(document))
            {
                qvalueCutoff = _settings.QValueCutoff;
            }

            int?minDetections = null;

            if (_settings.MinimumDetections != -1)
            {
                minDetections = _settings.MinimumDetections;
            }

            MedianInfo medianInfo = null;

            if (_settings.NormalizationMethod == AreaCVNormalizationMethod.medians)
            {
                medianInfo = CalculateMedianAreas(document);
            }

            foreach (var peptideGroup in document.MoleculeGroups)
            {
                foreach (var peptide in peptideGroup.Molecules)
                {
                    foreach (var transitionGroupDocNode in peptide.TransitionGroups)
                    {
                        if (_settings.PointsType == PointsTypePeakArea.decoys != transitionGroupDocNode.IsDecoy)
                        {
                            continue;
                        }

                        foreach (var a in annotations)
                        {
                            areas.Clear();

                            if (a != _settings.Annotation && (_settings.Group == null || _settings.Annotation != null))
                            {
                                continue;
                            }

                            foreach (var i in AnnotationHelper.GetReplicateIndices(document.Settings, _settings.Group, a))
                            {
                                if (token.HasValue && token.Value.IsCancellationRequested)
                                {
                                    throw new Exception(@"Cancelled");
                                }
                                var groupChromInfo = transitionGroupDocNode.GetSafeChromInfo(i)
                                                     .FirstOrDefault(c => c.OptimizationStep == 0);
                                if (groupChromInfo == null)
                                {
                                    continue;
                                }

                                if (qvalueCutoff.HasValue)
                                {
                                    if (!(groupChromInfo.QValue.HasValue && groupChromInfo.QValue.Value < qvalueCutoff.Value))
                                    {
                                        continue;
                                    }
                                }

                                if (!groupChromInfo.Area.HasValue)
                                {
                                    continue;
                                }
                                var index   = i;
                                var sumArea = transitionGroupDocNode.Transitions.Where(t =>
                                {
                                    if (ms1 != t.IsMs1 || !t.ExplicitQuantitative)
                                    {
                                        return(false);
                                    }

                                    var chromInfo = t.GetSafeChromInfo(index)
                                                    .FirstOrDefault(c => c.OptimizationStep == 0);
                                    if (chromInfo == null)
                                    {
                                        return(false);
                                    }
                                    if (_settings.Transitions == AreaCVTransitions.best)
                                    {
                                        return(chromInfo.RankByLevel == 1);
                                    }
                                    if (_settings.Transitions == AreaCVTransitions.all)
                                    {
                                        return(true);
                                    }

                                    return(chromInfo.RankByLevel <= _settings.CountTransitions);
                                    // ReSharper disable once PossibleNullReferenceException
                                }).Sum(t => (double)t.GetSafeChromInfo(index).FirstOrDefault(c => c.OptimizationStep == 0).Area);

                                var normalizedArea = sumArea;
                                if (_settings.NormalizationMethod == AreaCVNormalizationMethod.medians)
                                {
                                    normalizedArea /= medianInfo.Medians[i] / medianInfo.MedianMedian;
                                }
                                else if (_settings.NormalizationMethod == AreaCVNormalizationMethod.global_standards && hasGlobalStandards)
                                {
                                    normalizedArea =
                                        NormalizeToGlobalStandard(document, transitionGroupDocNode, i, sumArea);
                                }
                                else if (_settings.NormalizationMethod == AreaCVNormalizationMethod.ratio && hasHeavyMods && _settings.RatioIndex >= 0)
                                {
                                    var ci = transitionGroupDocNode.GetSafeChromInfo(i).FirstOrDefault(c => c.OptimizationStep == 0);
                                    if (ci != null)
                                    {
                                        var ratioValue = ci.GetRatio(_settings.RatioIndex);
                                        if (ratioValue == null)
                                        {
                                            continue;   // Skip the standards
                                        }
                                        normalizedArea = ratioValue.Ratio;
                                    }
                                }
                                areas.Add(new AreaInfo(sumArea, normalizedArea));
                            }

                            if (qvalueCutoff.HasValue && minDetections.HasValue && areas.Count < minDetections.Value)
                            {
                                continue;
                            }

                            _settings.AddToInternalData(_internalData, areas, peptideGroup, peptide, transitionGroupDocNode, a);
                        }
                    }
                }
            }
            Data = ImmutableList <CVData> .ValueOf(_internalData.GroupBy(i => i, (key, grouped) =>
            {
                var groupedArray = grouped.ToArray();
                return(new CVData(
                           groupedArray.Select(idata => new PeptideAnnotationPair(idata.PeptideGroup, idata.Peptide, idata.TransitionGroup, idata.Annotation, idata.CV)),
                           key.CVBucketed, key.Area, groupedArray.Length));
            }).OrderBy(d => d.CV));
        }
예제 #27
0
        public override void UpdateUI()
        {
            var document = _graphSummary.DocumentUIContainer.DocumentUI;

            if (!document.Settings.HasResults)
            {
                return;
            }

            var groupsVisible = AreaGraphController.GroupByGroup != null;

            toolStripLabel1.Visible = toolStripComboGroup.Visible = groupsVisible;

            var detectionsVisiblePrev = toolStripLabel2.Visible && toolStripNumericDetections.Visible && toolStripLabel3.Visible;
            var detectionsVisible     = AreaGraphController.ShouldUseQValues(document);

            toolStripLabel2.Visible = toolStripNumericDetections.Visible = toolStripLabel3.Visible = detectionsVisible;

            if (detectionsVisible)
            {
                toolStripNumericDetections.NumericUpDownControl.Minimum = 2;

                if (AreaGraphController.GroupByGroup == null || AreaGraphController.GroupByAnnotation == null)
                {
                    toolStripNumericDetections.NumericUpDownControl.Maximum = document.MeasuredResults.Chromatograms.Count;
                }
                else
                {
                    toolStripNumericDetections.NumericUpDownControl.Maximum = AnnotationHelper.GetReplicateIndices(document, ReplicateValue.FromPersistedString(document.Settings, AreaGraphController.GroupByGroup), AreaGraphController.GroupByAnnotation).Length;
                }

                if (!detectionsVisiblePrev)
                {
                    toolStripNumericDetections.NumericUpDownControl.Value = 2;
                }
            }

            if (groupsVisible)
            {
                var annotations = new[] { Resources.GraphSummary_UpdateToolbar_All }.Concat(
                    AnnotationHelper.GetPossibleAnnotations(document,
                                                            ReplicateValue.FromPersistedString(document.Settings, AreaGraphController.GroupByGroup))
                    .Except(new object[] { null })).ToArray();

                toolStripComboGroup.Items.Clear();
                // ReSharper disable once CoVariantArrayConversion
                toolStripComboGroup.Items.AddRange(annotations);

                if (AreaGraphController.GroupByAnnotation != null)
                {
                    toolStripComboGroup.SelectedItem = AreaGraphController.GroupByAnnotation;
                }
                else
                {
                    toolStripComboGroup.SelectedIndex = 0;
                }
                ComboHelper.AutoSizeDropDown(toolStripComboGroup);
            }

            toolStripComboNormalizedTo.Items.Clear();
            _normalizationMethods.Clear();
            _normalizationMethods.Add(NormalizeOption.DEFAULT);
            _normalizationMethods.AddRange(NormalizeOption.AvailableNormalizeOptions(_graphSummary.DocumentUIContainer.DocumentUI));
            _normalizationMethods.Add(NormalizeOption.NONE);
            toolStripComboNormalizedTo.Items.AddRange(_normalizationMethods.Select(item => item.Caption).ToArray());
            toolStripComboNormalizedTo.SelectedIndex = _normalizationMethods.IndexOf(AreaGraphController.AreaCVNormalizeOption);
            ComboHelper.AutoSizeDropDown(toolStripComboNormalizedTo);
        }
예제 #28
0
        public ActionResult AddNote(string regardingEntityLogicalName, string regardingEntityId, string text, bool isPrivate = false, HttpPostedFileBase file = null, string attachmentSettings = null)
        {
            Guid regardingId;

            Guid.TryParse(regardingEntityId, out regardingId);
            var    regarding           = new EntityReference(regardingEntityLogicalName, regardingId);
            string portalName          = null;
            var    portalContext       = PortalCrmConfigurationManager.CreatePortalContext();
            var    languageCodeSetting = portalContext.ServiceContext.GetSiteSettingValueByName(portalContext.Website, "Language Code");

            if (!string.IsNullOrWhiteSpace(languageCodeSetting))
            {
                int languageCode;
                if (int.TryParse(languageCodeSetting, out languageCode))
                {
                    portalName = languageCode.ToString(CultureInfo.InvariantCulture);
                }
            }

            var dataAdapterDependencies = new PortalConfigurationDataAdapterDependencies(requestContext: Request.RequestContext, portalName: portalName);
            var serviceContext          = dataAdapterDependencies.GetServiceContext();

            var dataAdapter = new AnnotationDataAdapter(dataAdapterDependencies);
            var settings    = JsonConvert.DeserializeObject <AnnotationSettings>(attachmentSettings) ??
                              new AnnotationSettings(serviceContext, true);

            var annotation = new Annotation
            {
                NoteText  = string.Format("{0}{1}", AnnotationHelper.WebAnnotationPrefix, text),
                Subject   = AnnotationHelper.BuildNoteSubject(serviceContext, dataAdapterDependencies.GetPortalUser(), isPrivate),
                Regarding = regarding
            };

            if (file != null && file.ContentLength > 0)
            {
                annotation.FileAttachment = AnnotationDataAdapter.CreateFileAttachment(file, settings.StorageLocation);
            }

            var result = dataAdapter.CreateAnnotation(annotation, settings);

            if (!result.PermissionsExist)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, "Entity Permissions have not been defined. Your request could not be completed."));
            }

            if (!result.CanCreate)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, "Permission Denied. You do not have the appropriate Entity Permissions to create notes."));
            }

            if (!result.CanAppendTo)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, "Permission Denied. You do not have the appropriate Entity Permissions to append to record."));
            }

            if (!result.CanAppend)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, "Permission Denied. You do not have the appropriate Entity Permissions to append notes."));
            }

            return(new HttpStatusCodeResult(HttpStatusCode.NoContent));
        }
예제 #29
0
            private IEnumerable <GraphDataProperties> GetPropertyVariants(AreaCVGraphSettings graphSettings)
            {
                SrmDocument document;

                lock (_cacheInfo)
                {
                    document = _cacheInfo.Document;
                }

                var annotationsArray = AnnotationHelper.GetPossibleAnnotations(document.Settings,
                                                                               graphSettings.Group, AnnotationDef.AnnotationTarget.replicate);

                // Add an entry for All
                var annotations = annotationsArray.Concat(new string[] { null }).ToList();

                var normalizationMethods = new List <AreaCVNormalizationMethod> {
                    AreaCVNormalizationMethod.none, AreaCVNormalizationMethod.medians, AreaCVNormalizationMethod.ratio
                };

                if (document.Settings.HasGlobalStandardArea)
                {
                    normalizationMethods.Add(AreaCVNormalizationMethod.global_standards);
                }

                // First cache for current normalization method
                if (normalizationMethods.Remove(graphSettings.NormalizationMethod))
                {
                    normalizationMethods.Insert(0, graphSettings.NormalizationMethod);
                }

                // First cache the histograms for the current annotation
                if (annotations.Remove(graphSettings.Annotation))
                {
                    annotations.Insert(0, graphSettings.Annotation);
                }

                foreach (var n in normalizationMethods)
                {
                    var isRatio = n == AreaCVNormalizationMethod.ratio;
                    // There can be RatioInternalStandardTypes even though HasHeavyModifications is false
                    if (isRatio && !document.Settings.PeptideSettings.Modifications.HasHeavyModifications)
                    {
                        continue;
                    }

                    var ratioIndices = isRatio
                        ? Enumerable.Range(0, document.Settings.PeptideSettings.Modifications.RatioInternalStandardTypes.Count).ToList()
                        : new List <int> {
                        -1
                    };

                    if (graphSettings.RatioIndex != -1)
                    {
                        if (ratioIndices.Remove(graphSettings.RatioIndex))
                        {
                            ratioIndices.Insert(0, graphSettings.RatioIndex);
                        }
                    }

                    foreach (var r in ratioIndices)
                    {
                        foreach (var a in annotations)
                        {
                            var minDetections = GetMinDetectionsForAnnotation(document, graphSettings, a);

                            for (var i = 2; i <= minDetections; ++i)
                            {
                                yield return(new GraphDataProperties(graphSettings.Group, n, r, a, i));
                            }
                        }
                    }
                }
            }
예제 #30
0
 private static int GetMinDetectionsForAnnotation(SrmDocument document, AreaCVGraphSettings graphSettings, string annotationValue)
 {
     return(document.Settings.PeptideSettings.Integration.PeakScoringModel.IsTrained && !double.IsNaN(graphSettings.QValueCutoff)
         ? AnnotationHelper.GetReplicateIndices(document.Settings, graphSettings.Group, annotationValue).Length
         : 2);
 }