protected override void DoTest() { RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("test.sky"))); var importResultsDlg = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults); var openDataSourceDialog = ShowDialog <OpenDataSourceDialog>(importResultsDlg.OkDialog); var editAccountDlg = ShowDialog <EditRemoteAccountDlg>(() => openDataSourceDialog.CurrentDirectory = RemoteUrl.EMPTY); RunUI(() => editAccountDlg.SetRemoteAccount(UnifiTestUtil.GetTestAccount())); OkDialog(editAccountDlg, editAccountDlg.OkDialog); OpenFile(openDataSourceDialog, "Company"); OpenFile(openDataSourceDialog, "Test Data"); OpenFile(openDataSourceDialog, "HDMSe"); OpenFile(openDataSourceDialog, "250 fmol Hi3 E coli peptides 3-6 min"); var lockMassDlg = WaitForOpenForm <ImportResultsLockMassDlg>(); OkDialog(lockMassDlg, lockMassDlg.OkDialog); // It takes a really long time to extract chromatograms, so we let it run for 5 seconds and then open a file where it's already imported WaitForDocumentLoaded(5000); RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("test_imported.sky"))); WaitForDocumentLoaded(); RunUI(() => SkylineWindow.SelectElement(ElementRefs.FromObjectReference(ElementLocator.Parse("Molecule:/sp|P0A6A8|ACP_ECOLI/ITTVQAAIDYINGHQA")))); ClickChromatogram(4.0, 100); GraphFullScan graphFullScan = FindOpenForm <GraphFullScan>(); Assert.IsNotNull(graphFullScan); }
/// <summary> /// Examine the values in the DocumentGrid which is showing the "NormalizedAreas" form, /// and make sure that all the numbers are correct. /// </summary> private void VerifyNormalizedAreaForm() { var normalizedAreasGrid = EnsureNormalizedAreasForm(); var dataGridView = normalizedAreasGrid.DataGridView; WaitForConditionUI(() => normalizedAreasGrid.IsComplete); var document = SkylineWindow.Document; Assert.AreSame(document, ((SkylineDataSchema)normalizedAreasGrid.ViewInfo.DataSchema).Document); RunUI(() => { var colPeptideLocator = FindColumn(dataGridView, "PeptideLocator"); var colResultFileLocator = FindColumn(dataGridView, "ResultFileLocator"); var colRatioLightToGlobalStandard = FindColumn(dataGridView, "RatioLightToGlobalStandards"); var colNormalizedArea = FindColumn(dataGridView, "NormalizedArea"); for (int iRow = 0; iRow < dataGridView.Rows.Count; iRow++) { var row = dataGridView.Rows[iRow]; var moleculeRef = (MoleculeRef) ElementRefs.FromObjectReference( ElementLocator.Parse((string)row.Cells[colPeptideLocator.Index].Value)); var peptideDocNode = (PeptideDocNode)moleculeRef.FindNode(document); var resultFileRef = (ResultFileRef) ElementRefs.FromObjectReference( ElementLocator.Parse((string)row.Cells[colResultFileLocator.Index].Value)); var chromFileInfo = document.Settings.MeasuredResults.Chromatograms .SelectMany(c => c.MSDataFileInfos) .FirstOrDefault(fileInfo => resultFileRef.Matches(fileInfo.FilePath)); Assert.IsNotNull(chromFileInfo); var peptideChromInfo = FindChromInfo(peptideDocNode.Results, chromFileInfo.FileId); var ratioToGlobalStandard = (double?)row.Cells[colRatioLightToGlobalStandard.Index].Value; double?normalizedArea = (double?)row.Cells[colNormalizedArea.Index].Value; var normalizationMethod = peptideDocNode.NormalizationMethod; double expectedNormalizedArea = double.NaN; double totalArea = peptideDocNode.TransitionGroups.Sum(tg => FindChromInfo(tg.Results, chromFileInfo.FileId)?.Area ?? 0); if (normalizationMethod == null) { expectedNormalizedArea = totalArea; } else if (NormalizationMethod.GLOBAL_STANDARDS.Equals(normalizationMethod)) { expectedNormalizedArea = ratioToGlobalStandard ?? 0; } else if (normalizationMethod is NormalizationMethod.RatioToSurrogate) { var ratioToSurrogate = (NormalizationMethod.RatioToSurrogate)normalizationMethod; double surrogateArea = CalculateStandardArea(document, chromFileInfo.FileId, peptide => peptide.ModifiedTarget.InvariantName == ratioToSurrogate.SurrogateName); expectedNormalizedArea = totalArea / surrogateArea; } else { Assert.Fail("Unexpected normalization method {0}", normalizationMethod); } AssertValuesEqual(expectedNormalizedArea, normalizedArea ?? 0); if (peptideChromInfo == null) { Assert.IsNull(ratioToGlobalStandard); Assert.IsNull(normalizedArea); } else { var ratioValue = peptideChromInfo.LabelRatios.FirstOrDefault(ratio => IsotopeLabelType.light.Equals(ratio.LabelType) && null == ratio.StandardType).Ratio; if (ratioValue == null) { Assert.IsNull(ratioToGlobalStandard); } else { Assert.IsNotNull(normalizedArea); AssertValuesEqual(ratioValue.Ratio, ratioToGlobalStandard.Value); } } } }); }
public void ReadAllAnnotations(CancellationToken cancellationToken, DsvFileReader fileReader) { var fieldNames = fileReader.FieldNames; int locatorColumnIndex = fieldNames.IndexOf(COLUMN_LOCATOR); if (locatorColumnIndex < 0) { throw new InvalidDataException(string.Format(Resources.Columns_Columns_Missing_column___0__, COLUMN_LOCATOR)); } string[] row; while ((row = fileReader.ReadLine()) != null) { cancellationToken.ThrowIfCancellationRequested(); ElementLocator elementLocator = ElementLocator.Parse(row[locatorColumnIndex]); var elementRef = ElementRefs.FromObjectReference(elementLocator); ElementHandler handler; if (!_elementHandlers.TryGetValue(elementRef.ElementType, out handler)) { throw ElementNotSupportedException(elementRef); } SkylineObject element = handler.FindElement(elementRef); if (element == null) { throw ElementNotFoundException(elementRef); } for (int icol = 0; icol < fieldNames.Count; icol++) { if (icol == locatorColumnIndex) { continue; } string fieldName = fieldNames[icol]; TextColumnWrapper propertyInfo = null; AnnotationDef annotationDef = null; if (fieldName.StartsWith(PROPERTY_PREFIX)) { propertyInfo = handler.FindProperty(fieldName.Substring(PROPERTY_PREFIX.Length)); } else if (fieldName.StartsWith(ANNOTATION_PREFIX)) { annotationDef = handler.FindAnnotation(fieldName.Substring(ANNOTATION_PREFIX.Length)); } if (propertyInfo == null && annotationDef == null) { propertyInfo = handler.FindProperty(fieldName); if (propertyInfo == null) { annotationDef = handler.FindAnnotation(fieldName); } } string fieldValue = row[icol]; if (propertyInfo == null && annotationDef == null) { if (string.IsNullOrEmpty(fieldValue)) { continue; } throw AnnotationDoesNotApplyException(fieldName, elementRef); } if (propertyInfo != null) { object value = propertyInfo.ParseTextValue(CultureInfo, fieldValue); propertyInfo.SetValue(element, value); } if (annotationDef != null) { SetAnnotationValue(element, annotationDef, fieldValue); } } } }