private static void AddAnnotations(Configuration configuration, SrmSettings settings, AnnotationDef.AnnotationTarget annotationTarget, Type persistentClass) { var mapping = configuration.GetClassMapping(persistentClass); foreach (var annotationDef in settings.DataSettings.AnnotationDefs) { if (!annotationDef.AnnotationTargets.Contains(annotationTarget)) { continue; } string columnName = AnnotationDef.GetColumnName(annotationDef.Name); Type accessorType; switch (annotationDef.Type) { case AnnotationDef.AnnotationType.number: accessorType = typeof(NumberAnnotationPropertyAccessor); break; case AnnotationDef.AnnotationType.true_false: accessorType = typeof(BoolAnnotationPropertyAccessor); break; default: accessorType = typeof(AnnotationPropertyAccessor); break; } AddColumn(mapping, columnName, accessorType); } }
public void SetAnnotationDef(AnnotationDef annotationDef) { _annotationDef = annotationDef; if (annotationDef == null) { AnnotationName = string.Empty; AnnotationType = AnnotationDef.AnnotationType.text; AnnotationTargets = AnnotationDef.AnnotationTargetSet.EMPTY; Items = new string[0]; } else { AnnotationName = annotationDef.Name; ListPropertyType = annotationDef.ListPropertyType; AnnotationTargets = annotationDef.AnnotationTargets; Items = annotationDef.Items; if (annotationDef.Expression != null) { var expression = annotationDef.Expression; tabControl1.SelectedTab = tabPageCalculated; availableFieldsTree1.SelectColumn(expression.Column); if (null != expression.AggregateOperation && comboAppliesTo.Items.Contains(expression.AggregateOperation)) { comboAppliesTo.SelectedItem = expression.AggregateOperation; } } else { tabControl1.SelectedTab = tabPageEditable; } } }
private void SetAnnotationValue(SkylineObject skylineObject, AnnotationDef annotationDef, string strValue) { object value; if (string.IsNullOrEmpty(strValue)) { value = null; } else { switch (annotationDef.Type) { case AnnotationDef.AnnotationType.number: value = double.Parse(strValue, CultureInfo); break; case AnnotationDef.AnnotationType.true_false: if (false.ToString(CultureInfo) == strValue) { value = false; } else { value = true; } break; default: value = strValue; break; } } skylineObject.SetAnnotation(annotationDef, value); }
public override PropertyDescriptor GetPropertyDescriptor(Type type, string name) { var propertyDescriptor = base.GetPropertyDescriptor(type, name); if (null != propertyDescriptor) { return(propertyDescriptor); } if (null == type) { return(null); } propertyDescriptor = RatioPropertyDescriptor.GetProperty(Document, type, name); if (null != propertyDescriptor) { return(propertyDescriptor); } if (name.StartsWith(AnnotationDef.ANNOTATION_PREFIX)) { var annotationTargets = GetAnnotationTargets(type); if (!annotationTargets.IsEmpty) { var annotationDef = new AnnotationDef(name.Substring(AnnotationDef.ANNOTATION_PREFIX.Length), annotationTargets, AnnotationDef.AnnotationType.text, new string[0]); return(new AnnotationPropertyDescriptor(this, annotationDef, false)); } } return(null); }
public void AddAnnotationToGridView(AnnotationDef annotationDef, Annotations annotations) { var row = dataGridView1.Rows[dataGridView1.Rows.Add()]; row.Tag = annotationDef; row.Cells[colName.Index].Value = annotationDef.Name; var value = annotations.GetAnnotation(annotationDef); if (annotationDef.Type == AnnotationDef.AnnotationType.true_false) { row.Cells[colValue.Index] = new DataGridViewCheckBoxCell { Value = value }; } else if (annotationDef.Type == AnnotationDef.AnnotationType.value_list) { var cell = new DataGridViewComboBoxCell(); row.Cells[colValue.Index] = cell; cell.Items.Add(string.Empty); foreach (var item in annotationDef.Items) { cell.Items.Add(item); } cell.Value = value; } else { var cell = row.Cells[colValue.Index]; if (annotationDef.Type == AnnotationDef.AnnotationType.number) { cell.ValueType = typeof(double); } cell.Value = value; } }
private static string GetExceptionDisplayMessage(Exception x) { var match = REGEX_MISSING_COLUMN.Match(x.Message); if (match.Success) { try { string columnName = match.Groups[1].ToString(); if (AnnotationDef.IsAnnotationProperty(columnName)) { columnName = AnnotationDef.GetColumnDisplayName(columnName); } else if (RatioPropertyAccessor.IsRatioOrRdotpProperty(columnName)) { columnName = RatioPropertyAccessor.GetDisplayName(columnName); } return(string.Format(Resources.ExportReportDlg_GetExceptionDisplayMessage_The_field__0__does_not_exist_in_this_document, columnName)); } // ReSharper disable EmptyGeneralCatchClause catch { // Could throw a variety of SQLiteException & NHibernat exceptions } // ReSharper restore EmptyGeneralCatchClause } return(x.Message); }
public object Get(object target) { string value; ((DbEntity)target).Annotations.TryGetValue(_name, out value); return(AnnotationDef.ParseNumber(value)); }
protected AnnotationPropertyDescriptor(SkylineDataSchema dataSchema, AnnotationDef annotationDef, Attribute[] attributes) : base(AnnotationDef.ANNOTATION_PREFIX + annotationDef.Name, attributes) { SkylineDataSchema = dataSchema; AnnotationDef = annotationDef; _isValid = true; }
protected virtual string[] GetDropdownItems(AnnotationDef annotationDef) { annotationDef = SkylineDataSchema.Document.Settings.DataSettings.AnnotationDefs .FirstOrDefault(def => def.Name == annotationDef.Name) ?? annotationDef; return(new[] { string.Empty }.Concat(annotationDef.Items).ToArray()); }
protected AnnotationPropertyDescriptor(SkylineDataSchema dataSchema, AnnotationDef annotationDef, Attribute[] attributes) : base(AnnotationDef.ANNOTATION_PREFIX + annotationDef.Name, attributes) { SkylineDataSchema = dataSchema; _annotationDef = CachedValue.Create(dataSchema, () => FindAnnotationDef(annotationDef)); _isValid = true; }
public ListColumnPropertyDescriptor(SkylineDataSchema dataSchema, string listName, AnnotationDef annotationDef) : base(AnnotationDef.ANNOTATION_PREFIX + annotationDef.Name, AnnotationPropertyDescriptor.GetAttributes(annotationDef)) { SkylineDataSchema = dataSchema; ListName = listName; AnnotationDef = annotationDef; _listInfo = CachedValue.Create(dataSchema, () => GetListInfo(SkylineDataSchema.Document)); _listItemType = ListItemTypes.INSTANCE.GetListItemType(listName); }
private object GetAnnotationValue(Annotations annotations, AnnotationDef annotationDef) { var value = annotations.GetAnnotation(annotationDef); if (false.Equals(value)) { return(null); } return(value); }
public GroupIdentifier GetGroupIdentifier(SrmSettings settings, ChromatogramSet chromatogramSet) { AnnotationDef annotationDef = settings.DataSettings.AnnotationDefs.FirstOrDefault(a => a.Name == ControlAnnotation); if (annotationDef == null) { return(default(GroupIdentifier)); } return(GroupIdentifier.MakeGroupIdentifier(chromatogramSet.Annotations.GetAnnotation(annotationDef))); }
public Columns(IList <AnnotationDef> annotationDefs) { LocatorColumn = 0; NoteColumn = 1; var annotationColumns = new AnnotationDef[annotationDefs.Count + 2]; LocatorColumn = 0; NoteColumn = 1; annotationDefs.CopyTo(annotationColumns, 2); AnnotationColumns = ImmutableList.ValueOf(annotationColumns); }
public GroupIdentifier GetGroupIdentifier(AnnotationCalculator annotationCalculator, ChromatogramSet chromatogramSet) { AnnotationDef annotationDef = annotationCalculator.SrmDocument.Settings.DataSettings.AnnotationDefs.FirstOrDefault(a => a.Name == ControlAnnotation); if (annotationDef == null) { return(default(GroupIdentifier)); } return(GroupIdentifier.MakeGroupIdentifier(annotationCalculator.GetReplicateAnnotation(annotationDef, chromatogramSet))); }
public static bool EquivalentAnnotations(AnnotationDef existingAnnotation, AnnotationDef annotationDef) { // if both annotations are value lists, we want to ignore the values in their lists in the comparison if (existingAnnotation.Type.Equals(AnnotationDef.AnnotationType.value_list) && annotationDef.Type.Equals(AnnotationDef.AnnotationType.value_list)) { return(Equals(existingAnnotation.ChangeItems(new string[0]), annotationDef.ChangeItems(new string[0]))); } return(existingAnnotation.Equals(annotationDef)); }
public static ColumnData MakeColumnData(AnnotationDef annotationDef) { if (annotationDef.ValueType == typeof(double)) { return(Doubles.EMPTY); } if (annotationDef.ValueType == typeof(bool)) { return(Booleans.EMPTY); } return(Strings.EMPTY); }
public Schema(ISessionFactory sessionFactory, DataSettings dataSettings) { _sessionFactory = sessionFactory; _annotationDefNames = new HashSet <string>(); if (dataSettings != null) { foreach (var annotationDef in dataSettings.AnnotationDefs) { _annotationDefNames.Add(AnnotationDef.GetKey(annotationDef.Name)); } } }
public override void SetAnnotation(AnnotationDef annotationDef, object value) { // Ignore setting of the old q value and mProphet score annoations. They are // displayed for backward compatibility. Setting them manually never made and sense. if (Equals(annotationDef.Name, MProphetResultsHandler.AnnotationName) || Equals(annotationDef.Name, MProphetResultsHandler.MAnnotationName)) { return; } ChangeChromInfo(EditDescription.SetAnnotation(annotationDef, value), chromInfo => chromInfo.ChangeAnnotations(chromInfo.Annotations.ChangeAnnotation(annotationDef, value))); }
private string FormatAnnotationValue(SkylineObject skylineObject, AnnotationDef annotationDef) { var value = skylineObject.GetAnnotation(annotationDef); if (value == null || false.Equals(value)) { return(string.Empty); } if (value is double d) { return(d.ToString(Formats.RoundTrip, CultureInfo)); } return(value.ToString()); }
protected List <TreeNode> GetTreeNodes(IClassMetadata classMetadata, Identifier identifier) { List <TreeNode> result = new List <TreeNode>(); // Add special ratio names in order after the default ratio name int lastRatioIndex = -1; foreach (String propertyName in classMetadata.PropertyNames) { IType propertyType = classMetadata.GetPropertyType(propertyName); if (propertyType is ManyToOneType) { continue; } var label = propertyName; bool isRatio = RatioPropertyAccessor.IsRatioOrRdotpProperty(label); if (isRatio) { label = RatioPropertyAccessor.GetDisplayName(label); } else if (AnnotationDef.IsAnnotationProperty(label)) { label = AnnotationDef.GetColumnDisplayName(label); } else if (label.IndexOf("Ratio", StringComparison.Ordinal) != -1) // Not L10N: Label is only used in this file. Never displayed. { lastRatioIndex = result.Count; } var columnInfo = CreateColumnInfo(identifier, classMetadata, propertyName); if (columnInfo.IsHidden) { continue; } TreeNode propertyNode = new TreeNode { Name = propertyName, Text = label, Tag = columnInfo }; if (isRatio && lastRatioIndex != -1) { result.Insert(++lastRatioIndex, propertyNode); } else { result.Add(propertyNode); } } return(result); }
public override object GetAnnotation(AnnotationDef annotationDef) { // Return q value and mProphet scores from their new locations if (Equals(annotationDef.Name, MProphetResultsHandler.AnnotationName)) { return(DetectionQValue); } else if (Equals(annotationDef.Name, MProphetResultsHandler.MAnnotationName)) { return(DetectionZScore); } return(ChromInfo.Annotations.GetAnnotation(annotationDef)); }
private IEnumerable <int> GetReplicateIndices(Func <int, ChromFileInfoId> getFileId) { var chromatograms = _document.Settings.MeasuredResults.Chromatograms; if (ReplicateOrder == SummaryReplicateOrder.document && null == OrderByReplicateAnnotation) { for (int iResult = 0; iResult < chromatograms.Count; iResult++) { yield return(iResult); } } else { // Create a list of tuple's that will sort according to user's options. // The sort is optionally by an annotation value, and then optionally acquired time, // and finally document order. var listIndexFile = new List <Tuple <object, DateTime, int> >(); AnnotationDef orderByReplicateAnnotationDef = null; if (null != OrderByReplicateAnnotation) { orderByReplicateAnnotationDef = _document.Settings.DataSettings.AnnotationDefs.FirstOrDefault( annotationDef => annotationDef.Name == OrderByReplicateAnnotation); } for (int iResult = 0; iResult < chromatograms.Count; iResult++) { var chromSet = _document.Settings.MeasuredResults.Chromatograms[iResult]; ChromFileInfoId fileId = getFileId(iResult); ChromFileInfo fileInfo = (fileId != null ? chromSet.GetFileInfo(fileId) : null); object annotationValue = null; DateTime replicateTime = DateTime.MaxValue; if (null != orderByReplicateAnnotationDef) { annotationValue = chromSet.Annotations.GetAnnotation(orderByReplicateAnnotationDef); } if (null != fileInfo && ReplicateOrder == SummaryReplicateOrder.time) { replicateTime = fileInfo.RunStartTime ?? DateTime.MaxValue; } listIndexFile.Add(new Tuple <object, DateTime, int>(annotationValue, replicateTime, iResult)); } listIndexFile.Sort(); foreach (var tuple in listIndexFile) { yield return(tuple.Item3); } } }
public GroupIdentifier GetControlGroupIdentifier(SrmSettings settings) { if (string.IsNullOrEmpty(ControlAnnotation)) { return(default(GroupIdentifier)); } AnnotationDef annotationDef = settings.DataSettings.AnnotationDefs.FirstOrDefault(a => a.Name == ControlAnnotation); if (annotationDef == null) { return(default(GroupIdentifier)); } return(GroupIdentifier.MakeGroupIdentifier(annotationDef.ParsePersistedString(ControlValue))); }
public PropertyDescriptor MakeLookupPropertyDescriptor(AnnotationDef annotationDef, PropertyDescriptor innerPropertyDescriptor) { if (string.IsNullOrEmpty(annotationDef.Lookup)) { return(innerPropertyDescriptor); } var listLookupPropertyDescriptor = new ListLookupPropertyDescriptor(this, annotationDef.Lookup, innerPropertyDescriptor); var listData = listLookupPropertyDescriptor.ListData; if (listData == null || listData.PkColumn == null) { return(innerPropertyDescriptor); } return(listLookupPropertyDescriptor); }
private void CreateBaseView(DocumentGridForm documentGrid) { RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Peptides)); var viewEditor = ShowDialog <ViewEditor>(documentGrid.DataboundGridControl.NavBar.CustomizeView); var columnsToKeep = new[] { PropertyPath.Root.Property("Proteins").LookupAllItems(), PropertyPath.Root.Property("Proteins").LookupAllItems().Property("Peptides").LookupAllItems() }; RunUI(() => { foreach (var column in viewEditor.ChooseColumnsTab.ViewSpec.Columns) { if (!columnsToKeep.Contains(column.PropertyPath)) { viewEditor.ChooseColumnsTab.RemoveColumn(column.PropertyPath); } } }); Assert.AreEqual(columnsToKeep.Length, viewEditor.ChooseColumnsTab.ColumnCount); PropertyPath pathNormalizedArea = PropertyPath.Root.Property("Proteins").LookupAllItems() .Property("Peptides").LookupAllItems() .Property("Results").LookupAllItems().Property("Value").Property("Quantification") .Property("NormalizedArea"); var columnsToAdd = new[] { PropertyPath.Root.Property("Replicates").LookupAllItems() .Property(AnnotationDef.GetColumnName("BioReplicate")), PropertyPath.Root.Property("Replicates").LookupAllItems() .Property(AnnotationDef.GetColumnName("ConditionNumber")), pathNormalizedArea }; RunUI(() => { foreach (var column in columnsToAdd) { viewEditor.ChooseColumnsTab.AddColumn(column); } }); RunUI(() => { viewEditor.ViewName = pivotTestViewName; }); OkDialog(viewEditor, viewEditor.OkDialog); }
public ColumnInfo GetColumnInfo(Type table, String column) { var columnInfo = new ColumnInfo { ReportColumn = new ReportColumn(table, new Identifier(column)), Caption = column }; if (AnnotationDef.IsAnnotationProperty(column)) { var classMetadata = GetClassMetadata(table); columnInfo.Caption = AnnotationDef.GetColumnDisplayName(column); columnInfo.ColumnType = classMetadata.GetPropertyType(column).ReturnedClass; columnInfo.IsHidden = !_annotationDefNames.Contains( AnnotationDef.GetColumnKey(column)); } else if (RatioPropertyAccessor.IsRatioOrRdotpProperty(column)) { var classMetadata = GetClassMetadata(table); columnInfo.Caption = RatioPropertyAccessor.GetDisplayName(column); columnInfo.ColumnType = classMetadata.GetPropertyType(column).ReturnedClass; if (RatioPropertyAccessor.IsRatioGsProperty(column)) { columnInfo.Format = Formats.GLOBAL_STANDARD_RATIO; } else if (RatioPropertyAccessor.IsRatioProperty(column)) { columnInfo.Format = Formats.STANDARD_RATIO; } else if (RatioPropertyAccessor.IsRdotpProperty(column)) { columnInfo.Format = Formats.STANDARD_RATIO; } } else { PropertyInfo propertyInfo = table.GetProperty(column); columnInfo.ColumnType = propertyInfo.PropertyType; foreach (QueryColumn attr in propertyInfo.GetCustomAttributes(typeof(QueryColumn), true)) { columnInfo.Caption = attr.FullName ?? columnInfo.Caption; columnInfo.Format = attr.Format ?? columnInfo.Format; columnInfo.IsHidden = attr.IsHidden; } } return(columnInfo); }
/// <summary> /// Returns the ReplicateGroupOp based on the current value of Settings.Default.GroupByReplicateAnnotation, /// and the specified AggregateOp. Note that if the ReplicateGroupOp is not grouping on an annotation, /// the AggregateOp will be override with the value MEAN. /// </summary> public static ReplicateGroupOp FromCurrentSettings(SrmSettings settings, AggregateOp aggregateOp) { AnnotationDef groupByAnnotationDef = null; string annotationName = Settings.Default.GroupByReplicateAnnotation; if (null != annotationName) { groupByAnnotationDef = settings.DataSettings.AnnotationDefs.FirstOrDefault( annotationDef => annotationName == annotationDef.Name); } if (null == groupByAnnotationDef) { aggregateOp = AggregateOp.MEAN; } return(new ReplicateGroupOp(groupByAnnotationDef, aggregateOp)); }
public void SetAnnotationDef(AnnotationDef annotationDef) { _annotationDef = annotationDef; if (annotationDef == null) { AnnotationName = string.Empty; AnnotationType = AnnotationDef.AnnotationType.text; AnnotationTargets = AnnotationDef.AnnotationTargetSet.EMPTY; Items = new string[0]; } else { AnnotationName = annotationDef.Name; ListPropertyType = annotationDef.ListPropertyType; AnnotationTargets = annotationDef.AnnotationTargets; Items = annotationDef.Items; } }
private SrmDocument EnsureAnnotation(SrmDocument document, string annotationName, bool addAnnotation, IEnumerable <string> annotationNames) { var containsQAnnotation = annotationNames.Contains(annotationName); if (!containsQAnnotation && addAnnotation) { var annotationTargets = AnnotationDef.AnnotationTargetSet.OfValues(AnnotationDef.AnnotationTarget.precursor_result); var newAnnotationDef = new AnnotationDef(annotationName, annotationTargets, AnnotationDef.AnnotationType.number, new string[0]); AnnotationDef existingAnnotationDef; // CONSIDER: Throw error instead of overwriting? if (!Settings.Default.AnnotationDefList.TryGetValue(annotationName, out existingAnnotationDef) && !Equals(existingAnnotationDef, newAnnotationDef)) { Settings.Default.AnnotationDefList.SetValue(newAnnotationDef); } else { // Use the existing annotation newAnnotationDef = existingAnnotationDef; } document = document.ChangeSettings(Document.Settings.ChangeAnnotationDefs(defs => { var defsNew = defs.ToList(); defsNew.Add(newAnnotationDef); return(defsNew); })); } else if (containsQAnnotation && !AddAnnotation) { document = document.ChangeSettings(Document.Settings.ChangeAnnotationDefs(defs => { var defsNew = defs.ToList(); defsNew.RemoveAll(def => Equals(def.Name, annotationName)); return(defsNew); })); var annotationNamesToKeep = document.Settings.DataSettings.AnnotationDefs.Select(def => def.Name).ToList(); document = (SrmDocument)document.StripAnnotationValues(annotationNamesToKeep); } return(document); }
private ToolStripMenuItem GroupByReplicateAnnotationMenuItem(AnnotationDef annotationDef, string groupBy) { return new ToolStripMenuItem(annotationDef.Name, null, (sender, eventArgs)=>GroupByReplicateAnnotation(annotationDef.Name)) { Checked = (annotationDef.Name == groupBy), }; }
private ToolStripMenuItem OrderByReplicateAnnotationMenuItem(AnnotationDef annotationDef, string currentOrderBy) { return new ToolStripMenuItem(annotationDef.Name, null, (sender, eventArgs) => OrderByReplicateAnnotation(annotationDef.Name)) { Checked = (annotationDef.Name == currentOrderBy) }; }
/// <summary> /// Returns an EditDescription corresponding to setting an annotation to a particular value. /// </summary> public static EditDescription SetAnnotation(AnnotationDef annotationDef, object value) { return new EditDescription(ColumnCaption.UnlocalizableCaption(annotationDef.Name), value); }
public void AddAnnotationToGridView(AnnotationDef annotationDef, Annotations annotations) { var row = dataGridView1.Rows[dataGridView1.Rows.Add()]; row.Tag = annotationDef; row.Cells[colName.Index].Value = annotationDef.Name; var value = annotations.GetAnnotation(annotationDef); if (annotationDef.Type == AnnotationDef.AnnotationType.true_false) { row.Cells[colValue.Index] = new DataGridViewCheckBoxCell {Value = value}; } else if (annotationDef.Type == AnnotationDef.AnnotationType.value_list) { var cell = new DataGridViewComboBoxCell(); row.Cells[colValue.Index] = cell; cell.Items.Add(string.Empty); foreach (var item in annotationDef.Items) { cell.Items.Add(item); } cell.Value = value; } else { var cell = row.Cells[colValue.Index]; if (annotationDef.Type == AnnotationDef.AnnotationType.number) { cell.ValueType = typeof (double); } cell.Value = value; } }
public AnnotationPropertyDescriptor(AnnotationDef annotationDef, bool isValid) : base(AnnotationDef.ANNOTATION_PREFIX + annotationDef.Name, GetAttributes(annotationDef)) { AnnotationDef = annotationDef; _isValid = isValid; }
public override void SetAnnotation(AnnotationDef annotationDef, object value) { ChangeChromInfo(EditDescription.SetAnnotation(annotationDef, value), ChromInfo.ChangeAnnotations(ChromInfo.Annotations.ChangeAnnotation(annotationDef, value))); }
private static void DefineAnnotation(EditListDlg<SettingsListBase<AnnotationDef>, AnnotationDef> dialog, String name, AnnotationDef.AnnotationTargetSet targets, AnnotationDef.AnnotationType type, IList<string> items) { var defineAnnotationDlg = ShowDialog<DefineAnnotationDlg>(dialog.AddItem); RunUI(()=> { defineAnnotationDlg.AnnotationName = name; defineAnnotationDlg.AnnotationType = type; defineAnnotationDlg.AnnotationTargets = targets; defineAnnotationDlg.Items = items ?? new string[0]; }); OkDialog(defineAnnotationDlg, defineAnnotationDlg.OkDialog); }
public void SetAnnotationDef(AnnotationDef annotationDef) { _annotationDef = annotationDef; if (annotationDef == null) { AnnotationName = string.Empty; AnnotationType = AnnotationDef.AnnotationType.text; AnnotationTargets = AnnotationDef.AnnotationTargetSet.EMPTY; Items = new string[0]; } else { AnnotationName = annotationDef.Name; AnnotationType = annotationDef.Type; AnnotationTargets = annotationDef.AnnotationTargets; Items = annotationDef.Items; } }
private void AddAnnotation(DocumentSettingsDlg documentSettingsDlg, string annotationName, AnnotationDef.AnnotationType annotationType, IList<string> annotationValues, AnnotationDef.AnnotationTargetSet annotationTargets, int pausePage) { var annotationsListDlg = ShowDialog<EditListDlg<SettingsListBase<AnnotationDef>, AnnotationDef>> (documentSettingsDlg.EditAnnotationList); RunUI(annotationsListDlg.SelectLastItem); var annotationDefDlg = ShowDialog<DefineAnnotationDlg>(annotationsListDlg.AddItem); RunUI(() => { annotationDefDlg.AnnotationName = annotationName; annotationDefDlg.AnnotationType = annotationType; if (annotationValues != null) annotationDefDlg.Items = annotationValues; annotationDefDlg.AnnotationTargets = annotationTargets; }); PauseForScreenShot<DefineAnnotationDlg>("Define Annotation form - " + annotationName, pausePage); OkDialog(annotationDefDlg, annotationDefDlg.OkDialog); OkDialog(annotationsListDlg, annotationsListDlg.OkDialog); }
private void AddReplicateAnnotation(DocumentSettingsDlg documentSettingsDlg, string annotationName, AnnotationDef.AnnotationType annotationType, IList<string> annotationValues, int pausePage) { AddAnnotation(documentSettingsDlg, annotationName, annotationType, annotationValues, AnnotationDef.AnnotationTargetSet.Singleton(AnnotationDef.AnnotationTarget.replicate), pausePage); }
public virtual void SetAnnotation(AnnotationDef annotationDef, object value) { }
public virtual object GetAnnotation(AnnotationDef annotationDef) { return null; }
private static Attribute[] GetAttributes(AnnotationDef annotationDef) { var attributes = new List<Attribute> {new DisplayNameAttribute(annotationDef.Name)}; if (annotationDef.Type == AnnotationDef.AnnotationType.number) { attributes.Add(new FormatAttribute {NullValue = TextUtil.EXCEL_NA}); } if (annotationDef.Type == AnnotationDef.AnnotationType.true_false) { attributes.Add(new DataGridViewColumnTypeAttribute(typeof(DataGridViewCheckBoxColumn))); } else if (annotationDef.Type == AnnotationDef.AnnotationType.value_list) { attributes.Add(new DataGridViewColumnTypeAttribute(typeof(AnnotationValueListDataGridViewColumn))); } return attributes.ToArray(); }
public override PropertyDescriptor GetPropertyDescriptor(Type type, string name) { var propertyDescriptor = base.GetPropertyDescriptor(type, name); if (null != propertyDescriptor) { return propertyDescriptor; } if (null == type) { return null; } propertyDescriptor = RatioPropertyDescriptor.GetProperty(Document, type, name); if (null != propertyDescriptor) { return propertyDescriptor; } if (name.StartsWith(AnnotationDef.ANNOTATION_PREFIX)) { var annotationTargets = GetAnnotationTargets(type); if (!annotationTargets.IsEmpty) { var annotationDef = new AnnotationDef(name.Substring(AnnotationDef.ANNOTATION_PREFIX.Length), annotationTargets, AnnotationDef.AnnotationType.text, new string[0]); return new AnnotationPropertyDescriptor(annotationDef, false); } } return null; }
private void ZipTestAnnotations() { var sampleId = new AnnotationDef("SampleID", // Not L10N AnnotationDef.AnnotationTargetSet.Singleton( AnnotationDef.AnnotationTarget.replicate), AnnotationDef.AnnotationType.text, new List<string>()); var isConc = new AnnotationDef("IS Conc", // Not L10N AnnotationDef.AnnotationTargetSet.Singleton( AnnotationDef.AnnotationTarget.replicate), AnnotationDef.AnnotationType.text, new List<string>()); var analyteConcentration = new AnnotationDef("Analyte Concentration", // Not L10N AnnotationDef.AnnotationTargetSet.Singleton( AnnotationDef.AnnotationTarget.replicate), AnnotationDef.AnnotationType.text, new List<string>()); var sampleIdTransition = new AnnotationDef("SampleID", // Not L10N AnnotationDef.AnnotationTargetSet.Singleton( AnnotationDef.AnnotationTarget.transition), AnnotationDef.AnnotationType.text, new List<string>()); // Test proper loading of annotations string testAnnotationsPath = TestFilesDir.GetTestPath("TestAnnotations.zip"); // Not L10N RunDlg<ConfigureToolsDlg>(() => SkylineWindow.ShowConfigureToolsDlg(), dlg => { dlg.RemoveAllTools(); dlg.InstallZipTool(testAnnotationsPath); WaitForConditionUI(3 * 1000, () => dlg.ToolList.Count == 4); ToolDescription t0 = dlg.ToolList[0]; ToolDescription t1 = dlg.ToolList[1]; ToolDescription t2 = dlg.ToolList[2]; ToolDescription t3 = dlg.ToolList[3]; AssertEx.AreEqualDeep(t0.Annotations, new List<AnnotationDef>()); AssertEx.AreEqualDeep(t1.Annotations, new List<AnnotationDef> { sampleId, isConc, analyteConcentration }); AssertEx.AreEqualDeep(t2.Annotations, new List<AnnotationDef> { sampleId }); AssertEx.AreEqualDeep(t3.Annotations, new List<AnnotationDef>()); Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(sampleId)); Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(isConc)); Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(analyteConcentration)); dlg.OkDialog(); }); // Test conflicting annotations var configureToolsDlg = ShowDialog<ConfigureToolsDlg>(SkylineWindow.ShowConfigureToolsDlg); string conflictAnnotationsPath = TestFilesDir.GetTestPath("ConflictAnnotations.zip"); // Not L10N RunDlg<MultiButtonMsgDlg>(() => configureToolsDlg.InstallZipTool(conflictAnnotationsPath), messageDlg => messageDlg.Btn1Click()); // keep existing annotations WaitForConditionUI(3 * 1000, () => configureToolsDlg.ToolList.Count == 5); Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(sampleId)); RunDlg<MultiButtonMsgDlg>(() => configureToolsDlg.InstallZipTool(conflictAnnotationsPath), dlg => dlg.Btn0Click()); { var messageDlg = WaitForOpenForm<MultiButtonMsgDlg>(); OkDialog(messageDlg, messageDlg.Btn0Click); } // overwrite existing annotations Assert.IsTrue(Settings.Default.AnnotationDefList.Contains(sampleIdTransition)); OkDialog(configureToolsDlg, configureToolsDlg.OkDialog); RunUI(() => SkylineWindow.PopulateToolsMenu()); // Test running the tool with an unchecked annotation RunDlg<MessageDlg>(() => SkylineWindow.RunTool(4), dlg => { Assert.AreEqual(TextUtil.LineSeparate(Resources.ToolDescription_VerifyAnnotations_This_tool_requires_the_use_of_the_following_annotations_which_are_not_enabled_for_this_document, string.Empty, TextUtil.LineSeparate(new Collection<string> {sampleId.GetKey()}), string.Empty, Resources.ToolDescription_VerifyAnnotations_Please_enable_these_annotations_and_fill_in_the_appropriate_data_in_order_to_use_the_tool_), dlg.Message); dlg.OkDialog(); }); // Test running the tool with a missing annotation Settings.Default.AnnotationDefList = new AnnotationDefList(); WaitForCondition(3*1000, () => Settings.Default.AnnotationDefList.Count == 0); RunDlg<MessageDlg>(() => SkylineWindow.RunTool(4), dlg => { Assert.AreEqual(TextUtil.LineSeparate(Resources.ToolDescription_VerifyAnnotations_This_tool_requires_the_use_of_the_following_annotations_which_are_missing_or_improperly_formatted, string.Empty, TextUtil.LineSeparate(new Collection<string> { sampleId.GetKey() }), string.Empty, Resources.ToolDescription_VerifyAnnotations_Please_re_install_the_tool_and_try_again_), dlg.Message); dlg.OkDialog(); }); // Clean-up RunDlg<ConfigureToolsDlg>(() => SkylineWindow.ShowConfigureToolsDlg(), dlg => { dlg.RemoveAllTools(); dlg.OkDialog(); }); }
public override object GetAnnotation(AnnotationDef annotationDef) { return ChromatogramSet.Annotations.GetAnnotation(annotationDef); }
public AnnotationTargetAttribute(AnnotationDef.AnnotationTarget target) { AnnotationTarget = target; }
public AnnotationTargetItem(AnnotationDef.AnnotationTarget annotationTarget) { AnnotationTarget = annotationTarget; }
private SrmDocument EnsureAnnotation(SrmDocument document, string annotationName, bool addAnnotation, IEnumerable<string> annotationNames) { var containsQAnnotation = annotationNames.Contains(annotationName); if (!containsQAnnotation && addAnnotation) { var annotationTargets = AnnotationDef.AnnotationTargetSet.OfValues(AnnotationDef.AnnotationTarget.precursor_result); var newAnnotationDef = new AnnotationDef(annotationName, annotationTargets, AnnotationDef.AnnotationType.number, new string[0]); AnnotationDef existingAnnotationDef; // CONSIDER: Throw error instead of overwriting? if (!Settings.Default.AnnotationDefList.TryGetValue(annotationName, out existingAnnotationDef) && !Equals(existingAnnotationDef, newAnnotationDef)) { Settings.Default.AnnotationDefList.SetValue(newAnnotationDef); } else { // Use the existing annotation newAnnotationDef = existingAnnotationDef; } document = document.ChangeSettings(Document.Settings.ChangeAnnotationDefs(defs => { var defsNew = defs.ToList(); defsNew.Add(newAnnotationDef); return defsNew; })); } else if (containsQAnnotation && !AddAnnotation) { document = document.ChangeSettings(Document.Settings.ChangeAnnotationDefs(defs => { var defsNew = defs.ToList(); defsNew.RemoveAll(def => Equals(def.Name, annotationName)); return defsNew; })); var annotationNamesToKeep = document.Settings.DataSettings.AnnotationDefs.Select(def => def.Name).ToList(); document = (SrmDocument) document.StripAnnotationValues(annotationNamesToKeep); } return document; }
public override object GetAnnotation(AnnotationDef annotationDef) { return ChromInfo.Annotations.GetAnnotation(annotationDef); }
public static Annotations MergeAnnotations(SrmDocument document, IEnumerable<IdentityPath> selPaths, out AnnotationDef.AnnotationTargetSet annotationTarget) { annotationTarget = AnnotationDef.AnnotationTargetSet.EMPTY; // If the nodes have matching text, colors, or annotations, then we should display these values // in the EditNodeDlg. Otherwise, we should not display any value for that variable. bool matchingText = true; bool matchingColors = true; bool isFirstSelNode = true; bool allEmpty = true; // These are the default values we want for the annotations, if the node(s) do not already have // annotations, or if the annotations do not match. string text = null; int colorIndex = -1; var dictMatchingAnnotations = new Dictionary<string, string>(); // Find what all nodes have in common as far as note, annotations, and color. foreach (IdentityPath selPath in selPaths) { if(Equals(selPath.Child, SequenceTree.NODE_INSERT_ID)) continue; var nodeDoc = document.FindNode(selPath); var nodeAnnotations = nodeDoc.Annotations; var dictNodeAnnotations = nodeAnnotations.ListAnnotations() .ToDictionary(nodeAnnotation => nodeAnnotation.Key, nodeAnnotation => nodeAnnotation.Value); // If this is the first iteration, use the value for this node to start matching. if (isFirstSelNode) { foreach (KeyValuePair<string, string> annotation in dictNodeAnnotations) { dictMatchingAnnotations.Add(annotation.Key, annotation.Value); } text = nodeAnnotations.Note; colorIndex = nodeAnnotations.ColorIndex; isFirstSelNode = false; } foreach (string key in dictMatchingAnnotations.Keys.ToArray()) { string value; // If the list of annotations we are building for the dialog contains this key, // check that the values are the same, otherwise the value for this annotation needs // to be null for the dialog. if (!dictNodeAnnotations.TryGetValue(key, out value) || !Equals(dictMatchingAnnotations[key], value)) dictMatchingAnnotations.Remove(key); } matchingText = matchingText && nodeAnnotations.Note != null && Equals(text, nodeAnnotations.Note); matchingColors = matchingColors && !nodeAnnotations.IsEmpty && nodeAnnotations.ColorIndex != -1 && Equals(colorIndex, nodeAnnotations.ColorIndex); allEmpty = allEmpty && nodeAnnotations.IsEmpty; // Update annotation target to include this type of node. annotationTarget = annotationTarget.Union(nodeDoc.AnnotationTarget); } if (!matchingText) text = string.Empty; if (allEmpty) colorIndex = Settings.Default.AnnotationColor; else if (!matchingColors) colorIndex = -1; return new Annotations(text, dictMatchingAnnotations, colorIndex); }
public static SrmDocument AddAnnotationIfMissing(SrmDocument docOriginal, string annotationName) { SrmDocument docNew = docOriginal; var annotationNames = from def in docOriginal.Settings.DataSettings.AnnotationDefs where def.AnnotationTargets.Contains(AnnotationDef.AnnotationTarget.precursor_result) select def.Name; var containsAnnotation = annotationNames.Contains(annotationName); if (!containsAnnotation) { var annotationTargets = AnnotationDef.AnnotationTargetSet.OfValues(AnnotationDef.AnnotationTarget.precursor_result); var newAnnotationDef = new AnnotationDef(annotationName, annotationTargets, AnnotationDef.AnnotationType.number, new string[0]); docNew = docOriginal.ChangeSettings(docOriginal.Settings.ChangeAnnotationDefs(defs => { var defsNew = defs.ToList(); defsNew.Add(newAnnotationDef); return defsNew; })); } return docNew; }
private static void AddAnnotations(Configuration configuration, SrmSettings settings, AnnotationDef.AnnotationTarget annotationTarget, Type persistentClass) { var mapping = configuration.GetClassMapping(persistentClass); foreach (var annotationDef in settings.DataSettings.AnnotationDefs) { if (!annotationDef.AnnotationTargets.Contains(annotationTarget)) { continue; } string columnName = AnnotationDef.GetColumnName(annotationDef.Name); Type accessorType; switch (annotationDef.Type) { case AnnotationDef.AnnotationType.number: accessorType = typeof (NumberAnnotationPropertyAccessor); break; case AnnotationDef.AnnotationType.true_false: accessorType = typeof (BoolAnnotationPropertyAccessor); break; default: accessorType = typeof (AnnotationPropertyAccessor); break; } AddColumn(mapping, columnName, accessorType); } }