public void TestProteinAbundance() { var srmDocument = LoadRatPlasmaDocument(); var documentContainer = new MemoryDocumentContainer(); documentContainer.SetDocument(srmDocument, documentContainer.Document); var skylineDataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT); GroupComparisonModel model = new GroupComparisonModel(documentContainer, null); model.GroupComparisonDef = GroupComparisonDef.EMPTY.ChangeControlAnnotation("Condition") .ChangeControlValue("Healthy") .ChangeSummarizationMethod(SummarizationMethod.AVERAGING) .ChangePerProtein(true); var groupComparer = new GroupComparer(model.GroupComparisonDef, srmDocument, new QrFactorizationCache()); foreach (var moleculeGroup in srmDocument.MoleculeGroups) { if (moleculeGroup.Molecules.Any(mol => null != mol.GlobalStandardType)) { continue; } var foldChangeResult = groupComparer.CalculateFoldChange(new GroupComparisonSelector(moleculeGroup, null, IsotopeLabelType.light, null, new GroupIdentifier("Diseased")), null); var xValues = new List <double>(); var yValues = new List <double>(); var protein = new Protein(skylineDataSchema, new IdentityPath(moleculeGroup.PeptideGroup)); foreach (var proteinResult in protein.Results.Values) { var abundance = proteinResult.Abundance; if (!abundance.HasValue) { continue; } var condition = proteinResult.Replicate.ChromatogramSet.Annotations.GetAnnotation("Condition"); if (condition == "Healthy") { xValues.Add(0); } else if (condition == "Diseased") { xValues.Add(1); } yValues.Add(Math.Log(abundance.Value)); } Assert.AreEqual(xValues.Count, foldChangeResult.ReplicateCount); if (!xValues.Any()) { continue; } var yStatistics = new Statistics(yValues); var xStatistics = new Statistics(xValues); var slope = yStatistics.Slope(xStatistics); var actualFoldChange = Math.Exp(slope); var expectedFoldChange = Math.Pow(2.0, foldChangeResult.LinearFitResult.EstimatedValue); AssertEx.AreEqual(expectedFoldChange, actualFoldChange, .01); } }
public object ValueFromString(SkylineDataSchema dataSchema, string strValue) { if (string.IsNullOrEmpty(strValue)) { return(default(T)); } return(ParseValue(dataSchema, strValue)); }
public string ValueToString(SkylineDataSchema dataSchema, object value) { if (value == null) { return(string.Empty); } return(FormatValue(dataSchema, (T)value)); }
public ElementHandler(SkylineDataSchema dataSchema) { DataSchema = dataSchema; // ReSharper disable VirtualMemberCallInConstructor _importableProperties = ListImportableProperties().ToDictionary(pd => pd.Name, pd => new ImportablePropertyInfo(pd)); // ReSharper restore VirtualMemberCallInConstructor _annotationDefs = ListAnnotationDefs().ToDictionary(annotationDef => annotationDef.Name); }
public Peptide(SkylineDataSchema dataSchema, IdentityPath identityPath) : base(dataSchema, identityPath) { _calibrationCurveFitter = CachedValue.Create(dataSchema, () => new CalibrationCurveFitter(GetPeptideQuantifier(), SrmDocument.Settings)); _precursors = CachedValue.Create(dataSchema, () => DocNode.Children.Select(child => new Precursor(DataSchema, new IdentityPath(IdentityPath, child.Id))).ToArray()); _results = CachedValue.Create(dataSchema, MakeResults); }
public static ExportAnnotationSettings AllAnnotations(SrmDocument document) { return(EMPTY.ChangeElementTypes(ElementHandler .GetElementHandlers(SkylineDataSchema.MemoryDataSchema(document, DataSchemaLocalizer.INVARIANT)) .Select(handler => handler.Name)) .ChangeAnnotationNames( document.Settings.DataSettings.AnnotationDefs.Select(annotationDef => annotationDef.Name)) .ChangePropertyNames(new[] { @"Note" })); }
public AuditLogRow(SkylineDataSchema dataSchema, AuditLogEntry entry, int id) : base(dataSchema) { Assume.IsNotNull(entry); _entry = entry; Id = new AuditLogRowId(id, 0); Details = ImmutableList.ValueOf(entry.AllInfo.Select((l, i) => new AuditLogDetailRow(this, new AuditLogRowId(id, i + 1)))); _isMultipleUndo = GetIsMultipleUndo(); }
public IEnumerable <SkylineDataSchema> EnumerateDataSchemas() { var documentContainer = new MemoryDocumentContainer(); Assert.IsTrue(documentContainer.SetDocument(new SrmDocument(SrmSettingsList.GetDefault()), documentContainer.Document)); var dataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); yield return(dataSchema); }
public CheckReportCompatibility(SrmDocument document) { IDocumentContainer documentContainer = new MemoryDocumentContainer(); Assert.IsTrue(documentContainer.SetDocument(document, null)); _database = new Database(document.Settings); _database.AddSrmDocument(document); _dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT); }
public ElementHandler(SkylineDataSchema dataSchema) { DataSchema = dataSchema; var rootColumn = ColumnDescriptor.RootColumn(dataSchema, typeof(object)); // ReSharper disable VirtualMemberCallInConstructor _importableProperties = ListImportableProperties().ToDictionary(pd => pd.Name, pd => new TextColumnWrapper(rootColumn.GetChild(pd))); // ReSharper restore VirtualMemberCallInConstructor _annotationDefs = ListAnnotationDefs().ToDictionary(annotationDef => annotationDef.Name); }
public void TestDefaultViews() { SkylineDataSchema dataSchema = GetDataSchema(); foreach (var type in new[] { typeof(Protein), typeof(Peptide), typeof(Precursor), typeof(Transition), typeof(Replicate) }) { var viewInfo = SkylineViewContext.GetDefaultViewInfo(ColumnDescriptor.RootColumn(dataSchema, type)); EnsureViewRoundTrips(viewInfo); } }
private static ViewInfo CreateAuditLogViewInfo(SkylineDataSchema dataSchema, string name, params string[] columnNames) { var columnDescriptor = ColumnDescriptor.RootColumn(dataSchema, typeof(AuditLogRow)); var viewSpec = new ViewSpec().SetName(name).SetRowType(columnDescriptor.PropertyType); var columns = columnNames.Select(c => new ColumnSpec(PropertyPath.Parse(c))); viewSpec = viewSpec.SetSublistId(PropertyPath.Root.Property(@"Details").LookupAllItems()); viewSpec = viewSpec.SetColumns(columns); return(new ViewInfo(columnDescriptor, viewSpec).ChangeViewGroup(ViewGroup.BUILT_IN)); }
public ListGridForm(IDocumentContainer documentContainer, string listName) { var skylineDataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); ListViewContext = ListViewContext.CreateListViewContext(skylineDataSchema, listName); BindingListSource.QueryLock = ListViewContext.SkylineDataSchema.QueryLock; BindingListSource.ListChanged += BindingListSourceOnListChanged; ListViewContext.BoundDataGridView = DataGridView; DataboundGridControl.BindingListSource.SetViewContext(ListViewContext); DataboundGridControl.BindingListSource.NewRowHandler = ListViewContext; Text = TabText = TextUtil.SpaceSeparate(Text + ':', listName); }
public LiveReportForm(IDocumentContainer documentContainer) { InitializeComponent(); Icon = Resources.Skyline; _dataSchema = new SkylineDataSchema(documentContainer); var parentColumn = new ColumnDescriptor(_dataSchema, typeof(Protein)); var viewContext = new SkylineViewContext(parentColumn); bindingListSource.SetViewContext(viewContext); bindingListSource.RowSource = new Proteins(_dataSchema); navBar.BindingNavigator.Items.Insert(0, toolStripDropDownRowSource); }
private SkylineViewContext GetViewContext(bool clone) { var dataSchema = new SkylineDataSchema(_documentUiContainer, GetDataSchemaLocalizer()); if (clone) { dataSchema = dataSchema.Clone(); } return(new DocumentGridViewContext(dataSchema) { EnablePreview = true }); }
public void EditReportList() { var dataSchema = new SkylineDataSchema(DocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var viewContext = new DocumentGridViewContext(dataSchema) { EnablePreview = true }; using (var manageViewsForm = new ManageViewsForm(viewContext)) { manageViewsForm.ShowDialog(this); } }
public static ListViewContext CreateListViewContext(SkylineDataSchema dataSchema, string listName) { var listItemType = ListItemTypes.INSTANCE.GetListItemType(listName); var rootColumn = ColumnDescriptor.RootColumn(dataSchema, listItemType); var rowSourceConstructor = typeof(ListRowSource <>).MakeGenericType(listItemType) .GetConstructor(new[] { typeof(SkylineDataSchema) }); // ReSharper disable PossibleNullReferenceException var rowSource = (IRowSource)rowSourceConstructor.Invoke(new object[] { dataSchema }); // ReSharper restore PossibleNullReferenceException var rowSourceInfo = new RowSourceInfo(listItemType, rowSource, new[] { GetDefaultViewInfo(rootColumn) }, LIST_ROWSOURCE_PREFIX + listName, listName); return(new ListViewContext(dataSchema, listName, rowSourceInfo)); }
public DocumentAnnotationUpdater(SrmDocument document, IProgressMonitor progressMonitor) { SkylineDataSchema = SkylineDataSchema.MemoryDataSchema(document, DataSchemaLocalizer.INVARIANT); _annotationUpdaters = new Dictionary <AnnotationDef.AnnotationTarget, AnnotationUpdater>(); var calculatedAnnotations = document.Settings.DataSettings.AnnotationDefs .Where(def => null != def.Expression).ToArray(); foreach (AnnotationDef.AnnotationTarget target in Enum.GetValues(typeof(AnnotationDef.AnnotationTarget))) { var annotations = ImmutableList.ValueOf(calculatedAnnotations.Where(def => def.AnnotationTargets.Contains(target))); if (annotations.Count == 0) { continue; } _annotationUpdaters[target] = new AnnotationUpdater(annotations); } AnnotationUpdater transitionResultAnnotationUpdater; if (_annotationUpdaters.TryGetValue(AnnotationDef.AnnotationTarget.transition_result, out transitionResultAnnotationUpdater)) { _transitionResultUpdater = new TransitionResultUpdater { AnnotationUpdater = transitionResultAnnotationUpdater, SkylineDataSchema = SkylineDataSchema }; } AnnotationUpdater precursorResultAnnotationUpdater; if (_annotationUpdaters.TryGetValue(AnnotationDef.AnnotationTarget.precursor_result, out precursorResultAnnotationUpdater)) { _precursorResultUpdater = new PrecursorResultUpdater { AnnotationUpdater = precursorResultAnnotationUpdater, SkylineDataSchema = SkylineDataSchema }; } RecurseTransitions = _annotationUpdaters.ContainsKey(AnnotationDef.AnnotationTarget.transition) || transitionResultAnnotationUpdater != null; RecursePrecursors = RecurseTransitions || _annotationUpdaters.ContainsKey(AnnotationDef.AnnotationTarget.precursor) || precursorResultAnnotationUpdater != null; RecurseMolecules = RecursePrecursors || _annotationUpdaters.ContainsKey(AnnotationDef.AnnotationTarget.peptide); }
public static IList <ElementHandler> GetElementHandlers(SkylineDataSchema dataSchema) { return(new ElementHandler[] { new MoleculeGroupHandler(dataSchema), new MoleculeHandler(dataSchema), new PrecursorHandler(dataSchema), new TransitionHandler(dataSchema), new ReplicateHandler(dataSchema), new ResultFileHandler(dataSchema), new MoleculeResultHandler(dataSchema), new PrecursorResultHandler(dataSchema), new TransitionResultHandler(dataSchema) }); }
public static void ReportToCsv(ReportSpec reportSpec, SrmDocument doc, string fileName, CultureInfo cultureInfo) { var documentContainer = new MemoryDocumentContainer(); Assert.IsTrue(documentContainer.SetDocument(doc, documentContainer.Document)); var skylineDataSchema = new SkylineDataSchema(documentContainer, new DataSchemaLocalizer(cultureInfo, cultureInfo)); var viewSpec = ReportSharing.ConvertAll(new[] { new ReportOrViewSpec(reportSpec) }, doc).First(); var viewContext = new DocumentGridViewContext(skylineDataSchema); using (var writer = new StreamWriter(fileName)) { IProgressStatus status = new ProgressStatus(); viewContext.Export(CancellationToken.None, new SilentProgressMonitor(), ref status, viewContext.GetViewInfo(ViewGroup.BUILT_IN, viewSpec), writer, viewContext.GetCsvWriter()); } }
public ExportAnnotationsDlg(SkylineDataSchema dataSchema) { InitializeComponent(); DataSchema = dataSchema; Handlers = ImmutableList.ValueOf(ElementHandler.GetElementHandlers(dataSchema)); _inUpdate = true; foreach (var handler in Handlers) { listBoxElementTypes.Items.Add(handler.Name); } SelectAll(listBoxElementTypes); _inUpdate = false; UpdateUi(); SelectAll(listBoxAnnotations); SelectAll(listBoxProperties); }
public void NewReport() { var dataSchema = new SkylineDataSchema(DocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var viewContext = new DocumentGridViewContext(dataSchema) { EnablePreview = true }; var newView = viewContext.NewView(this, PersistedViews.MainGroup); if (newView != null) { chooseViewsControl.SelectView(newView.Name); chooseViewsControl.CheckedViews = chooseViewsControl.CheckedViews .Append(PersistedViews.MainGroup.Id.ViewName(newView.Name)); } }
public static AuditLogForm MakeAuditLogForm(SkylineWindow skylineWindow) { var dataSchema = new SkylineDataSchema(skylineWindow, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var viewInfos = new[] { CreateAuditLogViewInfo(dataSchema, AuditLogStrings.AuditLogForm_MakeAuditLogForm_Undo_Redo, @"TimeStamp", @"UndoRedoMessage"), CreateAuditLogViewInfo(dataSchema, AuditLogStrings.AuditLogForm_MakeAuditLogForm_Summary, @"TimeStamp", @"SummaryMessage"), CreateAuditLogViewInfo(dataSchema, AuditLogStrings.AuditLogForm_MakeAuditLogForm_All_Info, @"TimeStamp", @"Details!*.AllInfoMessage") }; var rowSource = new AuditLogRowSource(dataSchema); var rowSourceInfo = new RowSourceInfo(typeof(AuditLogRow), rowSource, viewInfos); var viewContext = new SkylineViewContext(dataSchema, new[] { rowSourceInfo }); return(new AuditLogForm(viewContext, viewInfos[2].Name)); }
public void TestInvariantExport() { SkylineDataSchema skylineDataSchema = new SkylineDataSchema(CreateMemoryDocumentContainer(LoadTestDocument()), DataSchemaLocalizer.INVARIANT); SkylineViewContext viewContext = new DocumentGridViewContext(skylineDataSchema); string testFile = Path.Combine(TestContext.TestDir, "TestInvariantExport.csv"); var dsvWriter = new DsvWriter(CultureInfo.InvariantCulture, ','); viewContext.ExportToFile(null, GetTestReport(skylineDataSchema), testFile, dsvWriter); string strExported = File.ReadAllText(testFile); Assert.AreEqual(ExpectedInvariantReport, strExported); // Assert that the file written out was UTF8 encoding without any byte order mark byte[] bytesExported = File.ReadAllBytes(testFile); CollectionAssert.AreEqual(Encoding.UTF8.GetBytes(strExported), bytesExported); }
public MetadataRuleEditor(IDocumentContainer documentContainer) { InitializeComponent(); _dataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var rootColumn = ColumnDescriptor.RootColumn(_dataSchema, typeof(ResultFile)); var viewContext = new SkylineViewContext(rootColumn, new StaticRowSource(new ExtractedMetadataResultRow[0])); _metadataExtractor = new MetadataExtractor(_dataSchema, typeof(ResultFile)); bindingListSource1.SetViewContext(viewContext); var sources = _metadataExtractor.GetSourceColumns().ToArray(); comboSourceText.Items.AddRange(sources); comboMetadataTarget.Items.AddRange(_metadataExtractor.GetTargetColumns().ToArray()); SelectItem(comboSourceText, PropertyPath.Root.Property(nameof(ResultFile.FileName))); FormatCultureInfo = CultureInfo.InvariantCulture; }
public void AddRef() { if (Interlocked.Increment(ref _referenceCount) == 1) { _skylineDataSchema = new SkylineDataSchema(GroupComparisonModel.DocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var viewInfo = new ViewInfo(_skylineDataSchema, typeof(FoldChangeRow), GetDefaultViewSpec(new FoldChangeRow[0])) .ChangeViewGroup(ViewGroup.BUILT_IN); var rowSourceInfo = new RowSourceInfo(typeof(FoldChangeRow), new StaticRowSource(new FoldChangeRow[0]), new[] { viewInfo }); ViewContext = new GroupComparisonViewContext(_skylineDataSchema, new[] { rowSourceInfo }); _container = new Container(); _bindingListSource = new BindingListSource(_container); _bindingListSource.SetViewContext(ViewContext, viewInfo); GroupComparisonModel.ModelChanged += GroupComparisonModelOnModelChanged; GroupComparisonModelOnModelChanged(GroupComparisonModel, new EventArgs()); } }
public LiveResultsGrid(SkylineWindow skylineWindow) { InitializeComponent(); SkylineWindow = skylineWindow; _dataSchema = new SkylineDataSchema(skylineWindow, SkylineDataSchema.GetLocalizedSchemaLocalizer()); BindingListSource.QueryLock = _dataSchema.QueryLock; BindingListSource.ListChanged += bindingListSource_ListChanged; BindingListSource.CurrentChanged += bindingListSource_CurrentChanged; DataGridView.DataBindingComplete += boundDataGridView_DataBindingComplete; var contextMenuStrip = databoundGridControl.contextMenuStrip; contextMenuStrip.Items.Insert(0, new ToolStripSeparator()); for (int i = contextMenuResultsGrid.Items.Count - 1; i >= 0; i--) { contextMenuStrip.Items.Insert(0, contextMenuResultsGrid.Items[i]); } contextMenuStrip.Opening += contextMenu_Opening; }
private string GetReportRows(SrmDocument document, ViewSpec viewSpec, IProgressMonitor progressMonitor) { var container = new MemoryDocumentContainer(); container.SetDocument(document, container.Document); var dataSchema = new SkylineDataSchema(container, DataSchemaLocalizer.INVARIANT); var viewContext = new DocumentGridViewContext(dataSchema); IProgressStatus status = new ProgressStatus(string.Format(Resources.ReportSpec_ReportToCsvString_Exporting__0__report, viewSpec.Name)); var writer = new StringWriter(); if (viewContext.Export(CancellationToken.None, progressMonitor, ref status, viewContext.GetViewInfo(null, viewSpec), writer, viewContext.GetCsvWriter())) { return(writer.ToString()); } return(null); }
public MetadataRuleSetEditor(IDocumentContainer documentContainer, MetadataRuleSet metadataRuleSet, IEnumerable <MetadataRuleSet> existing) { InitializeComponent(); DocumentContainer = documentContainer; metadataRuleSet = metadataRuleSet ?? new MetadataRuleSet(typeof(ResultFile)); _originalName = metadataRuleSet.Name; _dataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var rootColumn = ColumnDescriptor.RootColumn(_dataSchema, typeof(ExtractedMetadataResultRow)); var viewInfo = new ViewInfo(rootColumn, GetDefaultViewSpec()); var skylineViewContext = new MetadataResultViewContext(rootColumn, new StaticRowSource(new MetadataStepResult[0])); bindingListSourceResults.SetViewContext(skylineViewContext, viewInfo); _metadataExtractor = new MetadataExtractor(_dataSchema, typeof(ResultFile)); _ruleRowList = new List <RuleRow>(); bindingSourceRules.DataSource = new BindingList <RuleRow>(_ruleRowList); MetadataRuleSet = metadataRuleSet; _existing = ImmutableList.ValueOfOrEmpty(existing); }
public void TestGenerateMsStatsInput() { SrmDocument testDocument = OpenTestDocument(); var memoryDocumentContainer = new MemoryDocumentContainer(); Assert.IsTrue(memoryDocumentContainer.SetDocument(testDocument, memoryDocumentContainer.Document)); SkylineDataSchema skylineDataSchema = new SkylineDataSchema(memoryDocumentContainer, DataSchemaLocalizer.INVARIANT); var view = ReportSharing.DeserializeReportList(OpenTestFile("MSstats_report.skyr")).First().ViewSpec; var viewContext = new DocumentGridViewContext(skylineDataSchema); StringWriter stringWriter = new StringWriter(); IProgressStatus progressStatus = new ProgressStatus(); viewContext.Export(new SilentProgressMonitor(), ref progressStatus, viewContext.GetViewInfo(ViewGroup.BUILT_IN, view), stringWriter, viewContext.GetCsvWriter()); string expectedReport = new StreamReader(OpenTestFile("BrudererSubset_MSstatsInput.csv")).ReadToEnd(); AssertEx.NoDiff(expectedReport, stringWriter.ToString()); }
public SkylineObject(SkylineDataSchema dataSchema) { DataSchema = dataSchema; }
public Replicate(SkylineDataSchema dataSchema, int replicateIndex) : base(dataSchema) { ReplicateIndex = replicateIndex; _chromatogramSet = CachedValue.Create(DataSchema, FindChromatogramSet); }
public ResultFile ToResultFile(SkylineDataSchema dataSchema) { return new ResultFile(new Replicate(dataSchema, ReplicateIndex), ChromFileInfoId, OptimizationStep); }