public Property(PropertyInfo propertyInfo, TrackAttributeBase trackAttribute) { Assume.IsNotNull(propertyInfo); Assume.IsNotNull(trackAttribute); PropertyInfo = new PropertyInfoWrapper(propertyInfo); _trackAttribute = trackAttribute; }
/// <summary> /// Merge the sorted lists of precursor peak groups into a single sorted list /// </summary> /// <param name="dataSets"></param> private IList <PeptideChromDataPeak> MergePeakGroups(IEnumerable <ChromDataSet> dataSets) { var allPeaks = new List <PeptideChromDataPeak>(); var listUnmerged = new List <ChromDataSet>(dataSets); var listEnumerators = listUnmerged.Select(dataSet => dataSet.PeakSets.GetEnumerator()).ToList(); // Initialize an enumerator for each set of raw peaks, or remove // the set, if the list is found to be empty for (int i = listEnumerators.Count - 1; i >= 0; i--) { if (!listEnumerators[i].MoveNext()) { listEnumerators.RemoveAt(i); listUnmerged.RemoveAt(i); } } while (listEnumerators.Count > 0) { double maxScore = 0; int iMaxEnumerator = -1; // Check each enumerator for the next highest peak score for (int i = 0; i < listEnumerators.Count; i++) { var dataPeakList = listEnumerators[i].Current; if (dataPeakList == null) { throw new InvalidOperationException(Resources.PeptideChromDataSets_MergePeakGroups_Unexpected_null_peak_list); } double score = dataPeakList.CombinedScore; if (score > maxScore) { maxScore = score; iMaxEnumerator = i; } } // If no peaks left, stop looping. if (iMaxEnumerator == -1) { break; } var maxData = listUnmerged[iMaxEnumerator]; var maxEnumerator = listEnumerators[iMaxEnumerator]; var maxPeak = maxEnumerator.Current; Assume.IsNotNull(maxPeak); allPeaks.Add(new PeptideChromDataPeak(maxData, maxPeak)); if (!maxEnumerator.MoveNext()) { listEnumerators.RemoveAt(iMaxEnumerator); listUnmerged.RemoveAt(iMaxEnumerator); } } return(allPeaks); }
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 double CCSFromIonMobility(IonMobilityValue im, double mz, int charge) { if (ProvidesCollisionalCrossSectionConverter) { return(_ionMobilityFunctionsProvider.CCSFromIonMobility(im, mz, charge)); } Assume.IsNotNull(_ionMobilityFunctionsProvider, "No ion mobility to CCS translation is possible for this data set"); // Not L10N return(0); }
public IonMobilityValue IonMobilityFromCCS(double ccs, double mz, int charge) { if (ProvidesCollisionalCrossSectionConverter) { return(_ionMobilityFunctionsProvider.IonMobilityFromCCS(ccs, mz, charge)); } Assume.IsNotNull(_ionMobilityFunctionsProvider, "No CCS to ion mobility translation is possible for this data set"); // Not L10N return(IonMobilityValue.EMPTY); }
private bool IsCreatingHandle() { var GetState = GetType().GetMethod("GetState", BindingFlags.NonPublic | BindingFlags.Instance); Assume.IsNotNull(GetState); // ReSharper disable once PossibleNullReferenceException return((bool)GetState.Invoke(this, new object[] { STATE_CREATINGHANDLE })); }
private void btnAdditionalSettings_Click(object sender, EventArgs e) { Assume.IsNotNull(ImportPeptideSearch.SearchEngine.AdditionalSettings); KeyValueGridDlg.Show(Resources.SearchSettingsControl_Additional_Settings, ImportPeptideSearch.SearchEngine.AdditionalSettings, (setting) => setting.Value.ToString(), (value, setting) => setting.Value = value, (value, setting) => setting.Validate(value)); }
private bool IsMissingAlignment(ChromInfoData chromInfoData) { Assume.IsNotNull(RetentionTimeTransform, "RetentionTimeTransform"); // Not L10N if (null == RetentionTimeTransform.RtTransformOp) { return(false); } Assume.IsNotNull(chromInfoData, "chromInfoData"); // Not L10N Assume.IsNotNull(chromInfoData.ChromFileInfo, "chromInfoData.ChromFileInfo"); // Not L10N IRegressionFunction regressionFunction; return(!RetentionTimeTransform.RtTransformOp.TryGetRegressionFunction(chromInfoData.ChromFileInfo.FileId, out regressionFunction)); }
public static Annotations FromProtoAnnotations(StringPool stringPool, SkylineDocumentProto.Types.Annotations protoAnnotations) { Assume.IsNotNull(stringPool); if (protoAnnotations == null) { return(EMPTY); } return(new Annotations(protoAnnotations.Note, protoAnnotations.Values .Select(value => new KeyValuePair <string, string>( stringPool.GetString(value.Name), stringPool.GetString(value.TextValue))), protoAnnotations.Color)); }
private void Tutorial(ActionTutorial.TutorialType type, string skyFileLocation, string pdfFileLocation, string zipSkyFileLocation) { Assume.IsNotNull(skyFileLocation); var pathChooserDlg = new PathChooserDlg(Resources.StartPage_Tutorial__Folder_for_tutorial_files_, skyFileLocation); if (pathChooserDlg.ShowDialog(this) != DialogResult.OK) { return; } DialogResult = DialogResult.OK; string paths = pathChooserDlg.ExtractionPath; DoAction(new ActionTutorial(type, paths, skyFileLocation, pdfFileLocation, zipSkyFileLocation) .DoStartupAction); }
public DataRow(SrmSettings settings, RetentionTimeSource target, RetentionTimeSource timesToAlign) : this() { DocumentRetentionTimes = settings.DocumentRetentionTimes; Target = target; Source = timesToAlign; Assume.IsNotNull(target, @"target"); Assume.IsNotNull(DocumentRetentionTimes.FileAlignments, @"DocumentRetentionTimes.FileAlignments"); var fileAlignment = DocumentRetentionTimes.FileAlignments.Find(target.Name); if (fileAlignment != null) { Assume.IsNotNull(fileAlignment.RetentionTimeAlignments, @"fileAlignment.RetentionTimeAlignments"); Assume.IsNotNull(Source, @"Source"); Alignment = fileAlignment.RetentionTimeAlignments.Find(Source.Name); } TargetTimes = GetFirstRetentionTimes(settings, target); SourceTimes = GetFirstRetentionTimes(settings, timesToAlign); }
/// <summary> /// Returns a ChromPeak and IFoundPeak that match the start and end times a particular other IFoundPeak /// that was found by Crawdad. /// </summary> public Tuple <ChromPeak, IFoundPeak> IntegrateFoundPeak(IFoundPeak peakMax, ChromPeak.FlagValues flags) { Assume.IsNotNull(PeakFinder); var interpolatedPeak = PeakFinder.GetPeak(peakMax.StartIndex, peakMax.EndIndex); if ((flags & ChromPeak.FlagValues.forced_integration) != 0 && ChromData.AreCoeluting(peakMax, interpolatedPeak)) { flags &= ~ChromPeak.FlagValues.forced_integration; } var chromPeak = new ChromPeak(PeakFinder, interpolatedPeak, flags, InterpolatedTimeIntensities, RawTimeIntensities?.Times); if (TimeIntervals != null) { chromPeak = IntegratePeakWithoutBackground(InterpolatedTimeIntensities.Times[peakMax.StartIndex], InterpolatedTimeIntensities.Times[peakMax.EndIndex], flags); } return(Tuple.Create(chromPeak, interpolatedPeak)); }
private void CompareDocumentTransitions(SrmDocument docA, SrmDocument docB) { // Note that we can't just run the lists in parallel - one of these is likely a small molecule conversion of the other, // and will have its transitions sorted differently Assume.AreEqual(docA.MoleculeTransitionGroupCount, docB.MoleculeTransitionGroupCount); foreach (var transGroupDocB in docB.MoleculeTransitionGroups) { var transGroupDocA = docA.MoleculeTransitionGroups.FirstOrDefault(a => Math.Abs(a.PrecursorMz - transGroupDocB.PrecursorMz) <= 1.5E-6 && Equals(a.TransitionCount, transGroupDocB.TransitionCount) && Equals(a.TransitionGroup.PrecursorAdduct.AdductCharge, transGroupDocB.TransitionGroup.PrecursorAdduct.AdductCharge) && Equals(a.TransitionGroup.LabelType, transGroupDocB.TransitionGroup.LabelType)); Assume.IsNotNull(transGroupDocA, "failed to find matching transition group"); var docBTransitions = transGroupDocB.Transitions.ToArray(); var docBTransitionsMatched = new List <TransitionDocNode>(); // ReSharper disable once PossibleNullReferenceException foreach (var transDocA in transGroupDocA.Transitions) { var a = transDocA; var transDocB = docBTransitions.FirstOrDefault(b => a.Transition.IsPrecursor() == b.Transition.IsPrecursor() && Math.Abs(a.Mz - b.Mz) <= 1.0E-5 && ((a.Results == null) ? (b.Results == null) : (a.Results.Count == b.Results.Count))); Assume.IsNotNull(transDocB, "failed to find matching transition"); Assume.IsFalse(docBTransitionsMatched.Contains(transDocB), "transition matched twice"); docBTransitionsMatched.Add(transDocB); // ReSharper disable PossibleNullReferenceException using (var docBChromInfos = transDocB.ChromInfos.GetEnumerator()) { foreach (var infoDocA in transDocA.ChromInfos) { Assume.IsTrue(docBChromInfos.MoveNext()); var infoDocB = docBChromInfos.Current; Assume.IsTrue(infoDocA.Equals(infoDocB)); } } // ReSharper restore PossibleNullReferenceException } } }
public void OkDialog() { if (treeViewFolders.SelectedNode == null || treeViewFolders.SelectedNode.Level == 0) { // Prompt the user to select a folder if no node is selected or only the top-level node // (the server name) is selected. MessageDlg.Show(this, Resources.PublishDocumentDlg_OkDialog_Please_select_a_folder); return; } FolderInformation folderInfo = treeViewFolders.SelectedNode.Tag as FolderInformation; if (folderInfo == null) { MessageDlg.Show(this, Resources.PublishDocumentDlg_UploadSharedZipFile_Error_obtaining_server_information); return; } if (!folderInfo.HasWritePermission) { MessageDlg.Show(this, Resources.PublishDocumentDlg_UploadSharedZipFile_You_do_not_have_permission_to_upload_to_the_given_folder); return; } try { ShareType = PanoramaPublishClient.DecideShareType(folderInfo, _docContainer.DocumentUI); } catch (PanoramaServerException panoramaServerException) { MessageDlg.ShowWithException(this, panoramaServerException.Message, panoramaServerException); return; } Assume.IsNotNull(ShareType); DialogResult = DialogResult.OK; }
public DialogResult ShowWithTimeout(IWin32Window parent, string message) { Assume.IsNotNull(parent); // Problems if the parent is null if (Program.FunctionalTest && Program.PauseSeconds == 0 && !Debugger.IsAttached) { bool timeout = false; var timeoutTimer = new Timer { Interval = TIMEOUT_SECONDS * 1000 }; timeoutTimer.Tick += (sender, args) => { timeoutTimer.Stop(); if (!timeout) { timeout = true; Close(); } }; timeoutTimer.Start(); var result = ShowDialog(parent); timeoutTimer.Stop(); if (timeout) { throw new TimeoutException( string.Format("{0} not closed for {1} seconds. Message = {2}", // Not L10N GetType(), TIMEOUT_SECONDS, message)); } return(result); } return(ShowDialog(parent)); }
public PeptideGroupDocNode ChangeSettings(SrmSettings settingsNew, SrmSettingsDiff diff, DocumentSettingsContext context = null) { if (diff.Monitor != null) { diff.Monitor.ProcessGroup(this); } if (diff.DiffPeptides && settingsNew.PeptideSettings.Filter.AutoSelect && AutoManageChildren) { IList <DocNode> childrenNew = new List <DocNode>(); int countPeptides = 0; int countIons = 0; Dictionary <int, DocNode> mapIndexToChild = CreateGlobalIndexToChildMap(); Dictionary <PeptideModKey, DocNode> mapIdToChild = CreatePeptideModToChildMap(); IEnumerable <PeptideDocNode> peptideDocNodes; if (settingsNew.PeptideSettings.Filter.PeptideUniqueness == PeptideFilter.PeptideUniquenessConstraint.none || settingsNew.PeptideSettings.NeedsBackgroundProteomeUniquenessCheckProcessing) { peptideDocNodes = GetPeptideNodes(settingsNew, true).ToList(); } else { // Checking peptide uniqueness against the background proteome can be expensive. // Do all the regular processing, then filter those results at the end when we // can do it in aggregate for best speed. IEnumerable <PeptideDocNode> peptideDocNodesUnique; var peptideDocNodesPrecalculatedForUniquenessCheck = context == null ? null : context.PeptideDocNodesPrecalculatedForUniquenessCheck; var uniquenessDict = context == null ? null : context.UniquenessDict; if (peptideDocNodesPrecalculatedForUniquenessCheck != null) { // Already processed, and a global list of peptides provided Assume.IsNotNull(uniquenessDict); peptideDocNodesUnique = peptideDocNodesPrecalculatedForUniquenessCheck; } else { // We'll have to do the processing for this node, and work with // just the peptides on this node. With luck the background proteome // will already have those cached for uniqueness checks. var settingsNoUniquenessFilter = settingsNew.ChangePeptideFilter(f => f.ChangePeptideUniqueness(PeptideFilter.PeptideUniquenessConstraint.none)); var nodes = GetPeptideNodes(settingsNoUniquenessFilter, true).ToList(); var sequences = new List <string>(from p in nodes select p.Peptide.Sequence); peptideDocNodesUnique = nodes; // Avoid ReSharper multiple enumeration warning uniquenessDict = settingsNew.PeptideSettings.Filter.CheckPeptideUniqueness(settingsNew, sequences, diff.Monitor); } // ReSharper disable once PossibleNullReferenceException peptideDocNodes = peptideDocNodesUnique.Where(p => { // It's possible during document load for uniqueness dict to get out of synch, so be // cautious with lookup and just return false of not found. Final document change will clean that up. bool isUnique; return(uniquenessDict.TryGetValue(p.Peptide.Sequence, out isUnique) && isUnique); }); } foreach (var nodePep in peptideDocNodes) { PeptideDocNode nodePepResult = nodePep; SrmSettingsDiff diffNode = SrmSettingsDiff.ALL; DocNode existing; // Add values that existed before the change. First check for exact match by // global index, which will happen when explicit modifications are added, // and then by content identity. if (mapIndexToChild.TryGetValue(nodePep.Id.GlobalIndex, out existing) || mapIdToChild.TryGetValue(nodePep.Key, out existing)) { nodePepResult = (PeptideDocNode)existing; diffNode = diff; } if (nodePepResult != null) { // Materialize children of the peptide. nodePepResult = nodePepResult.ChangeSettings(settingsNew, diffNode); childrenNew.Add(nodePepResult); // Make sure a single peptide group does not exceed document limits. countPeptides++; countIons += nodePepResult.TransitionCount; if (countIons > SrmDocument.MAX_TRANSITION_COUNT) { throw new InvalidDataException(String.Format( Resources.PeptideGroupDocNode_ChangeSettings_The_current_document_settings_would_cause_the_number_of_targeted_transitions_to_exceed__0_n0___The_document_settings_must_be_more_restrictive_or_add_fewer_proteins_, SrmDocument.MAX_TRANSITION_COUNT)); } if (countPeptides > SrmDocument.MAX_PEPTIDE_COUNT) { throw new InvalidDataException(String.Format( Resources.PeptideGroupDocNode_ChangeSettings_The_current_document_settings_would_cause_the_number_of_peptides_to_exceed__0_n0___The_document_settings_must_be_more_restrictive_or_add_fewer_proteins_, SrmDocument.MAX_PEPTIDE_COUNT)); } } } if (PeptideGroup.Sequence != null) { childrenNew = PeptideGroup.RankPeptides(childrenNew, settingsNew, true); } return((PeptideGroupDocNode)ChangeChildrenChecked(childrenNew)); } else { var nodeResult = this; if (diff.DiffPeptides && diff.SettingsOld != null) { // If variable modifications changed, remove all peptides with variable // modifications which are no longer possible. var modsNew = settingsNew.PeptideSettings.Modifications; var modsVarNew = modsNew.VariableModifications.ToArray(); var modsOld = diff.SettingsOld.PeptideSettings.Modifications; var modsVarOld = modsOld.VariableModifications.ToArray(); if (modsNew.MaxVariableMods < modsOld.MaxVariableMods || !ArrayUtil.EqualsDeep(modsVarNew, modsVarOld)) { IList <DocNode> childrenNew = new List <DocNode>(); foreach (PeptideDocNode nodePeptide in nodeResult.Children) { if (nodePeptide.AreVariableModsPossible(modsNew.MaxVariableMods, modsVarNew)) { childrenNew.Add(nodePeptide); } } nodeResult = (PeptideGroupDocNode)nodeResult.ChangeChildrenChecked(childrenNew); } } // Check for changes affecting children if (diff.DiffPeptideProps || diff.DiffExplicit || diff.DiffTransitionGroups || diff.DiffTransitionGroupProps || diff.DiffTransitions || diff.DiffTransitionProps || diff.DiffResults) { IList <DocNode> childrenNew = new List <DocNode>(); // Enumerate the nodes making necessary changes. foreach (PeptideDocNode nodePeptide in nodeResult.Children) { childrenNew.Add(nodePeptide.ChangeSettings(settingsNew, diff)); } childrenNew = RankChildren(settingsNew, childrenNew); nodeResult = (PeptideGroupDocNode)nodeResult.ChangeChildrenChecked(childrenNew); } return(nodeResult); } }
private void WatersImsMseChromatogramTest(DriftFilterType mode, IonMobilityWindowWidthCalculator.IonMobilityPeakWidthType driftPeakWidthCalcType, RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules = RefinementSettings.ConvertToSmallMoleculesMode.none) { if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none && !RunSmallMoleculeTestVersions) { Console.Write(MSG_SKIPPING_SMALLMOLECULE_TEST_VERSION); return; } string subdir = (asSmallMolecules == RefinementSettings.ConvertToSmallMoleculesMode.none) ? null : asSmallMolecules.ToString(); var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE, subdir); TestSmallMolecules = false; // Don't need that extra magic node bool withDriftTimePredictor = (mode == DriftFilterType.predictor); // Load the doc that has a drift time predictor? bool withDriftTimeFilter = (mode != DriftFilterType.none); // Perform drift time filtering? (either with predictor, or with bare times in blib file) string docPath; SrmDocument document = InitWatersImsMseDocument(testFilesDir, driftPeakWidthCalcType, withDriftTimeFilter, withDriftTimePredictor, out docPath); AssertEx.IsDocumentState(document, null, 1, 1, 1, 8); // Drift time lib load bumps the doc version, so does small mol conversion var listChromatograms = new List <ChromatogramSet>(); // A small subset of the QC_HDMSE_02_UCA168_3495_082213 data set (RT 21.5-22.5) from Will Thompson string mz5Path = "waters-mobility" + ExtensionTestContext.ExtMz5; string testModeStr = withDriftTimePredictor ? "with drift time predictor" : "without drift time info"; if (withDriftTimeFilter && !withDriftTimePredictor) { testModeStr = "with drift times from spectral library"; } listChromatograms.Add(AssertResult.FindChromatogramSet(document, new MsDataFilePath(mz5Path)) ?? new ChromatogramSet(Path.GetFileName(mz5Path).Replace('.', '_'), new[] { mz5Path })); using (var docContainer = new ResultsTestDocumentContainer(document, docPath)) { var doc = docContainer.Document; var docResults = doc.ChangeMeasuredResults(new MeasuredResults(listChromatograms)); Assume.IsTrue(docContainer.SetDocument(docResults, doc, true)); docContainer.AssertComplete(); document = docContainer.Document; } document = ConvertToSmallMolecules(document, ref docPath, new[] { mz5Path }, asSmallMolecules); using (var docContainer = new ResultsTestDocumentContainer(document, docPath)) { float tolerance = (float)document.Settings.TransitionSettings.Instrument.MzMatchTolerance; double maxHeight = 0; var results = document.Settings.MeasuredResults; Assume.AreEqual(1, document.MoleculePrecursorPairs.Count()); foreach (var pair in document.MoleculePrecursorPairs) { ChromatogramGroupInfo[] chromGroupInfo; Assume.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroupInfo)); Assume.AreEqual(1, chromGroupInfo.Length, testModeStr); var chromGroup = chromGroupInfo[0]; int expectedPeaks; if (withDriftTimeFilter) { expectedPeaks = 3; } else if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.masses_only) { expectedPeaks = 5; } else { expectedPeaks = 6; // No libraries } Assume.AreEqual(expectedPeaks, chromGroup.NumPeaks, testModeStr); // This will be higher if we don't filter on DT foreach (var tranInfo in chromGroup.TransitionPointSets) { maxHeight = Math.Max(maxHeight, tranInfo.MaxIntensity); } } Assume.AreEqual(withDriftTimeFilter ? 5226 : 20075, maxHeight, 1, testModeStr); // Without DT filtering, this will be much greater // now drill down for specific values int nPeptides = 0; foreach (var nodePep in document.Molecules.Where(nodePep => !nodePep.Results[0].IsEmpty)) { // expecting just one peptide result in this small data set if (nodePep.Results[0].Sum(chromInfo => chromInfo.PeakCountRatio > 0 ? 1 : 0) > 0) { Assume.AreEqual(21.94865, (double)nodePep.GetMeasuredRetentionTime(0), .0001, testModeStr); Assume.AreEqual(1.0, (double)nodePep.GetPeakCountRatio(0), 0.0001, testModeStr); nPeptides++; } } Assume.AreEqual(1, nPeptides); if (withDriftTimePredictor || withDriftTimeFilter) { // Verify that the .imdb pr .blib file goes out in the share zipfile for (int complete = 0; complete <= 1; complete++) { var sharePath = testFilesDir.GetTestPath(complete == 1 ? "share_complete.zip" : "share_minimized.zip"); var share = new SrmDocumentSharing(document, docPath, sharePath, new ShareType(complete == 1, SkylineVersion.CURRENT)); // Explicitly declaring version number forces a save before zip share.Share(new SilentProgressMonitor()); var files = share.ListEntries().ToArray(); var imdbFile = withDriftTimePredictor ? "scaled.imdb" : "waters-mobility.filtered-scaled.blib"; if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none) { var ext = "." + imdbFile.Split('.').Last(); imdbFile = imdbFile.Replace(ext, BiblioSpecLiteSpec.DotConvertedToSmallMolecules + ext); } Assume.IsTrue(files.Contains(imdbFile)); // And round trip it to make sure we haven't left out any new features in minimized imdb or blib files share.Extract(new SilentProgressMonitor()); using (var cmdline = new CommandLine()) { Assume.IsTrue(cmdline.OpenSkyFile(share.DocumentPath)); // Handles any path shifts in database files, like our .imdb file var document2 = cmdline.Document; Assume.IsNotNull(document2); Assume.IsTrue(docContainer.SetDocument(document2, docContainer.Document, true)); docContainer.AssertComplete(); document2 = docContainer.Document; var im = document2.Settings.GetIonMobilities(new MsDataFilePath(mz5Path)); var pep = document2.Molecules.First(); foreach (TransitionGroupDocNode nodeGroup in pep.Children) { double windowDT; var centerDriftTime = document2.Settings.GetIonMobility( pep, nodeGroup, null, im, null, driftTimeMax, out windowDT); Assume.AreEqual(3.86124, centerDriftTime.IonMobility.Mobility.Value, .0001, testModeStr); Assume.AreEqual(0.077224865797235934, windowDT, .0001, testModeStr); } } } } } }
public void DoFullScanSettingsTest(RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules, out List <SrmDocument> docCheckPoints) { docCheckPoints = new List <SrmDocument>(); var doc0 = ResultsUtil.DeserializeDocument("MultiLabel.sky", GetType()); var refine = new RefinementSettings(); var docSM = refine.ConvertToSmallMolecules(doc0, ".", asSmallMolecules); docCheckPoints.Add(docSM); Assume.IsFalse(docSM.MoleculeTransitionGroups.Any(nodeGroup => nodeGroup.IsotopeDist != null)); AssertEx.Serializable(docSM, AssertEx.Cloned); double c13Delta = BioMassCalc.MONOISOTOPIC.GetMass(BioMassCalc.C13) - BioMassCalc.MONOISOTOPIC.GetMass(BioMassCalc.C); double n15Delta = BioMassCalc.MONOISOTOPIC.GetMass(BioMassCalc.N15) - BioMassCalc.MONOISOTOPIC.GetMass(BioMassCalc.N); // Verify isotope distributions calculated when MS1 filtering enabled var enrichments = IsotopeEnrichmentsList.DEFAULT; var docIsotopes = docSM.ChangeSettings(docSM.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 3, enrichments))); docCheckPoints.Add(docIsotopes); Assume.AreEqual(FullScanMassAnalyzerType.tof, docIsotopes.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer); Assume.IsFalse(docIsotopes.MoleculeTransitionGroups.Any(nodeGroup => nodeGroup.IsotopeDist == null)); foreach (var nodeGroup in docIsotopes.MoleculeTransitionGroups) { Assume.AreEqual(3, nodeGroup.Children.Count); var isotopePeaks = nodeGroup.IsotopeDist; Assume.IsNotNull(isotopePeaks); Assume.IsTrue(nodeGroup.HasIsotopeDist); // The peaks should always includ at least M-1 Assume.IsTrue(isotopePeaks.MassIndexToPeakIndex(0) > 0); // Within 2.5% of 100% of the entire isotope distribution Assert.AreEqual(1.0, isotopePeaks.ExpectedProportions.Sum(), 0.025); // Precursor mass and m/z values are expected to match exactly (well, within XML roundtrip accuracy anyway) Assume.AreEqual(nodeGroup.PrecursorMz, nodeGroup.IsotopeDist.GetMZI(0), SequenceMassCalc.MassTolerance); Assume.AreEqual(nodeGroup.PrecursorMz, nodeGroup.TransitionGroup.IsCustomIon ? BioMassCalc.CalculateIonMz(nodeGroup.IsotopeDist.GetMassI(0), nodeGroup.TransitionGroup.PrecursorAdduct.Unlabeled) : SequenceMassCalc.GetMZ(nodeGroup.IsotopeDist.GetMassI(0), nodeGroup.TransitionGroup.PrecursorAdduct), SequenceMassCalc.MassTolerance); // Check isotope distribution masses for (int i = 1; i < isotopePeaks.CountPeaks; i++) { int massIndex = isotopePeaks.PeakIndexToMassIndex(i); Assume.IsTrue(isotopePeaks.GetMZI(massIndex - 1) < isotopePeaks.GetMZI(massIndex)); double massDelta = GetMassDelta(isotopePeaks, massIndex); if (nodeGroup.TransitionGroup.LabelType.IsLight) { // All positive should be close to 13C - C, and 0 should be the same as the next delta double expectedDelta = (massIndex > 0 ? c13Delta : GetMassDelta(isotopePeaks, massIndex + 1)); Assume.AreEqual(expectedDelta, massDelta, 0.001); } else if (nodeGroup.TransitionGroup.LabelType.Name.Contains("15N")) { // All positive should be close to 13C, and all negative 15N double expectedDelta = (massIndex > 0 ? c13Delta : n15Delta); Assume.AreEqual(expectedDelta, massDelta, 0.0015); } else if (massIndex == 0) { double expectedDelta = (isotopePeaks.GetProportionI(massIndex - 1) == 0 ? GetMassDelta(isotopePeaks, massIndex + 1) : 1.0017); Assume.AreEqual(expectedDelta, massDelta, 0.001); } else { Assume.AreEqual(c13Delta, massDelta, 0.001); } } } AssertEx.Serializable(docIsotopes, AssertEx.Cloned); // Narrow the resolution, and verify that predicted proportion of the isotope // distribution captured is reduced for all precursors var docIsotopesFt = docIsotopes.ChangeSettings(docIsotopes.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorResolution(FullScanMassAnalyzerType.ft_icr, 500 * 1000, 400))); docCheckPoints.Add(docIsotopesFt); var tranGroupsOld = docIsotopes.MoleculeTransitionGroups.ToArray(); var tranGroupsNew = docIsotopesFt.MoleculeTransitionGroups.ToArray(); Assume.AreEqual(tranGroupsOld.Length, tranGroupsNew.Length); for (int i = 0; i < tranGroupsOld.Length; i++) { Assert.AreNotSame(tranGroupsOld[i], tranGroupsNew[i]); Assert.AreNotSame(tranGroupsOld[i].IsotopeDist, tranGroupsNew[i].IsotopeDist); Assume.IsTrue(tranGroupsOld[i].IsotopeDist.ExpectedProportions.Sum() > tranGroupsNew[i].IsotopeDist.ExpectedProportions.Sum()); } // Use Min % of base peak and verify variation in transitions used const float minPercent1 = 10; var docIsotopesP1 = docIsotopes.ChangeSettings(docIsotopes.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Percent, minPercent1, enrichments))); docCheckPoints.Add(docIsotopesP1); tranGroupsNew = docIsotopesP1.MoleculeTransitionGroups.ToArray(); int maxTran = 0; for (int i = 0; i < tranGroupsOld.Length; i++) { // Isotope distributions should not have changed var isotopePeaks = tranGroupsNew[i].IsotopeDist; Assert.AreSame(tranGroupsOld[i].IsotopeDist, isotopePeaks); // Expected transitions should be present maxTran = Math.Max(maxTran, tranGroupsNew[i].Children.Count); foreach (TransitionDocNode nodeTran in tranGroupsNew[i].Children) { int massIndex = nodeTran.Transition.MassIndex; Assume.IsTrue(minPercent1 <= isotopePeaks.GetProportionI(massIndex) * 100.0 / isotopePeaks.BaseMassPercent); } } Assume.AreEqual(5, maxTran); AssertEx.Serializable(docIsotopesP1, AssertEx.Cloned); // Express any failure in terms of XML diffs // Use 10%, and check that 15N modifications all have M-1 const float minPercent2 = 5; var docIsotopesP2 = docIsotopesP1.ChangeSettings(docIsotopesP1.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Percent, minPercent2, enrichments))); docCheckPoints.Add(docIsotopesP2); foreach (var nodeGroup in docIsotopesP2.MoleculeTransitionGroups) { var firstChild = (TransitionDocNode)nodeGroup.Children[0]; if (nodeGroup.TransitionGroup.LabelType.Name.EndsWith("15N")) { Assume.AreEqual(-1, firstChild.Transition.MassIndex); } else { Assume.AreNotEqual(-1, firstChild.Transition.MassIndex); } } AssertEx.Serializable(docIsotopesP2, AssertEx.Cloned); // Use lower enrichment of 13C, and verify that this add M-1 for 13C labeled precursors var enrichmentsLow13C = enrichments.ChangeEnrichment(new IsotopeEnrichmentItem(BioMassCalc.C13, 0.9)); var docIsotopesLow13C = docIsotopesP1.ChangeSettings(docIsotopesP1.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Percent, minPercent2, enrichmentsLow13C))); tranGroupsNew = docIsotopesLow13C.MoleculeTransitionGroups.ToArray(); for (int i = 0; i < tranGroupsOld.Length; i++) { var nodeGroup = tranGroupsNew[i]; if (!Equals(nodeGroup.TransitionGroup.LabelType.Name, "heavy")) { Assert.AreSame(tranGroupsOld[i].IsotopeDist, nodeGroup.IsotopeDist); } else { var firstChild = (TransitionDocNode)nodeGroup.Children[0]; Assume.IsTrue(firstChild.Transition.MassIndex < 0); } } AssertEx.Serializable(docIsotopesLow13C, AssertEx.Cloned); // Express any failure as XML diffs // Use 0%, and check that everything has M-1 and lower var enrichmentsLow = enrichmentsLow13C.ChangeEnrichment(new IsotopeEnrichmentItem(BioMassCalc.N15, 0.97)); var docIsotopesLowP0 = docIsotopesP1.ChangeSettings(docIsotopesP1.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Percent, 0, enrichmentsLow))); docCheckPoints.Add(docIsotopesLowP0); foreach (var nodeGroup in docIsotopesLowP0.MoleculeTransitionGroups) { Assume.AreEqual(nodeGroup.IsotopeDist.CountPeaks, nodeGroup.Children.Count); var firstChild = (TransitionDocNode)nodeGroup.Children[0]; if (nodeGroup.TransitionGroup.LabelType.IsLight) { Assume.AreEqual(-1, firstChild.Transition.MassIndex); } else { Assume.IsTrue(-1 > firstChild.Transition.MassIndex); } } AssertEx.Serializable(docIsotopesLowP0, AssertEx.Cloned); // Test a document with variable and heavy modifications, which caused problems for // the original implementation var docVariable = ResultsUtil.DeserializeDocument("HeavyVariable.sky", GetType()); Assume.IsFalse(docVariable.MoleculeTransitionGroups.Any(nodeGroup => nodeGroup.IsotopeDist == null)); foreach (var nodeGroup in docVariable.MoleculeTransitionGroups) { var isotopePeaks = nodeGroup.IsotopeDist; Assume.IsNotNull(isotopePeaks); // The peaks should always includ at least M-1 Assume.IsTrue(isotopePeaks.MassIndexToPeakIndex(0) > 0); // Precursor mass and m/z values are expected to match exactly (well, within XML roundtrip tolerance anyway) var mzI = nodeGroup.IsotopeDist.GetMZI(0); Assume.AreEqual(nodeGroup.PrecursorMz, mzI, SequenceMassCalc.MassTolerance); // Check isotope distribution masses for (int i = 1; i < isotopePeaks.CountPeaks; i++) { int massIndex = isotopePeaks.PeakIndexToMassIndex(i); Assume.IsTrue(isotopePeaks.GetMZI(massIndex - 1) < isotopePeaks.GetMZI(massIndex)); double massDelta = GetMassDelta(isotopePeaks, massIndex); bool containsSulfur = nodeGroup.TransitionGroup.Peptide.IsCustomMolecule ? (nodeGroup.CustomMolecule.Formula.IndexOfAny("S".ToCharArray()) != -1) : (nodeGroup.TransitionGroup.Peptide.Sequence.IndexOfAny("CM".ToCharArray()) != -1); if (massIndex == 0) { double expectedDelta = (isotopePeaks.GetProportionI(massIndex - 1) == 0 ? GetMassDelta(isotopePeaks, massIndex + 1) : 1.0017); Assume.AreEqual(expectedDelta, massDelta, 0.001); } else if (!containsSulfur || massIndex == 1) { Assume.AreEqual(c13Delta, massDelta, 0.001); } else { Assume.AreEqual(1.00075, massDelta, 0.001); } } } docCheckPoints.Add(docVariable); }
private void DoFullScanFilterTest(RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules, out List <SrmDocument> docCheckpoints, bool centroided = false) { docCheckpoints = new List <SrmDocument>(); var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE); string docPath = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_multi.sky"); var expectedPepCount = 7; var expectedTransGroupCount = 7; var expectedTransCount = 49; var doc = InitFullScanDocument(ref docPath, 2, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules); if (centroided && ExtensionTestContext.CanImportThermoRaw) { const double ppm20 = 20.0; doc = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorResolution(FullScanMassAnalyzerType.centroided, ppm20, 0))); } using (var docContainer = new ResultsTestDocumentContainer(doc, docPath)) { // Import the first RAW file (or mzML for international) string rawPath = testFilesDir.GetTestPath("ah_20101011y_BSA_MS-MS_only_5-2" + ExtensionTestContext.ExtThermoRaw); var measuredResults = new MeasuredResults(new[] { new ChromatogramSet("Single", new[] { new MsDataFilePath(rawPath) }) }); SrmDocument docResults = docContainer.ChangeMeasuredResults(measuredResults, 3, 3, 21); docCheckpoints.Add(docResults); // Refilter allowing multiple precursors per spectrum SrmDocument docMulti = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan( fs => fs.ChangeAcquisitionMethod(FullScanAcquisitionMethod.DIA, new IsolationScheme("Test", 2)))); AssertEx.Serializable(docMulti, AssertEx.DocumentCloned); // Release data cache file Assume.IsTrue(docContainer.SetDocument(docMulti, docResults)); // And remove it FileEx.SafeDelete(Path.ChangeExtension(docPath, ChromatogramCache.EXT)); docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, 6, 6, 38)); // Import full scan Orbi-Velos data docPath = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_long_acc_template.sky"); expectedPepCount = 3; expectedTransGroupCount = 3; expectedTransCount = 21; doc = InitFullScanDocument(ref docPath, 1, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules); docCheckpoints.Add(doc); Assume.AreEqual(FullScanMassAnalyzerType.orbitrap, doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer); // Make sure saving this type of document works AssertEx.Serializable(doc, AssertEx.DocumentCloned); Assume.IsTrue(docContainer.SetDocument(doc, docContainer.Document)); rawPath = testFilesDir.GetTestPath("ah_20101029r_BSA_CID_FT_centroid_3uscan_3" + ExtensionTestContext.ExtThermoRaw); measuredResults = new MeasuredResults(new[] { new ChromatogramSet("Accurate", new[] { rawPath }) }); docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, 3, 3, 21)); // Import LTQ data with MS1 and MS/MS docPath = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_test4.sky"); expectedPepCount = 3; expectedTransGroupCount = 4; expectedTransCount = 32; doc = InitFullScanDocument(ref docPath, 3, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules); Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer); Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer); docCheckpoints.Add(doc); var docBoth = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs => fs.ChangeAcquisitionMethod(FullScanAcquisitionMethod.Targeted, null) .ChangePrecursorResolution(FullScanMassAnalyzerType.qit, TransitionFullScan.DEFAULT_RES_QIT, null))); docCheckpoints.Add(docBoth); AssertEx.Serializable(docBoth, AssertEx.DocumentCloned); Assume.IsTrue(docContainer.SetDocument(docBoth, docContainer.Document)); string dataPath = testFilesDir.GetTestPath("klc_20100329v_Protea_Peptide_Curve_200fmol_uL_tech1.mzML"); var listResults = new List <ChromatogramSet> { new ChromatogramSet("MS1 and MS/MS", new[] { dataPath }), }; measuredResults = new MeasuredResults(listResults.ToArray()); docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, expectedPepCount, expectedTransGroupCount, expectedTransCount - 6)); // The mzML was filtered for the m/z range 410 to 910. foreach (var nodeTran in docContainer.Document.MoleculeTransitions) { Assume.IsTrue(nodeTran.HasResults); Assume.IsNotNull(nodeTran.Results[0]); if (410 > nodeTran.Mz || nodeTran.Mz > 910) { Assume.IsTrue(nodeTran.Results[0][0].IsForcedIntegration); } else { Assume.IsFalse(nodeTran.Results[0][0].IsForcedIntegration); } } // Import LTQ data with MS1 and MS/MS using multiple files for a single replicate listResults.Add(new ChromatogramSet("Multi-file", new[] { testFilesDir.GetTestPath("both_DRV.mzML"), testFilesDir.GetTestPath("both_KVP.mzML"), })); measuredResults = new MeasuredResults(listResults.ToArray()); docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, expectedPepCount - 1, expectedTransGroupCount - 1, expectedTransCount - 6)); if (asSmallMolecules == RefinementSettings.ConvertToSmallMoleculesMode.masses_only) { return; // Can't work with isotope distributions when we don't have ion formulas } int indexResults = listResults.Count - 1; var matchIdentifierDRV = "DRV"; if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none) { matchIdentifierDRV = RefinementSettings.TestingConvertedFromProteomicPeptideNameDecorator + matchIdentifierDRV; } int index = 0; foreach (var nodeTran in docContainer.Document.MoleculeTransitions) { Assume.IsTrue(nodeTran.HasResults); Assume.AreEqual(listResults.Count, nodeTran.Results.Count); var peptide = nodeTran.Transition.Group.Peptide; if (peptide.IsCustomMolecule && index == 24) { // Conversion to small molecule loses some of the nuance of "Sequence" vs "FastaSequence", comparisons are inexact Assume.AreEqual("pep_DRVY[+80.0]IHPF", nodeTran.PrimaryCustomIonEquivalenceKey); break; } // DRV without FASTA sequence should not have data for non-precursor transitions if (!peptide.TextId.StartsWith(matchIdentifierDRV) || (!peptide.IsCustomMolecule && !peptide.Begin.HasValue)) { Assume.IsNotNull(nodeTran.Results[indexResults]); Assume.IsFalse(nodeTran.Results[indexResults][0].IsEmpty); } else if (nodeTran.Transition.IonType != IonType.precursor) { Assert.IsTrue(nodeTran.Results[indexResults].IsEmpty); } else { // Random, bogus peaks chosen in both files Assume.IsNotNull(nodeTran.Results[indexResults]); Assume.AreEqual(2, nodeTran.Results[indexResults].Count); Assume.IsFalse(nodeTran.Results[indexResults][0].IsEmpty); Assume.IsFalse(nodeTran.Results[indexResults][1].IsEmpty); } index++; } // Verify handling of bad request for vendor centroided data - out-of-range PPM docPath = testFilesDir.GetTestPath("Yeast_HI3 Peptides_test.sky"); expectedPepCount = 2; expectedTransGroupCount = 2; expectedTransCount = 2; doc = InitFullScanDocument(ref docPath, 2, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules); Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer); Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer); var docBad = doc; AssertEx.ThrowsException <InvalidDataException>(() => docBad.ChangeSettings(docBad.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 1, IsotopeEnrichmentsList.DEFAULT) .ChangePrecursorResolution(FullScanMassAnalyzerType.centroided, 50 * 1000, 400))), string.Format(Resources.TransitionFullScan_ValidateRes_Mass_accuracy_must_be_between__0__and__1__for_centroided_data_, TransitionFullScan.MIN_CENTROID_PPM, TransitionFullScan.MAX_CENTROID_PPM)); // Verify relationship between PPM and resolving power const double ppm = 20.0; // Should yield same filter width as resolving power 50,000 in TOF var docNoCentroid = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 1, IsotopeEnrichmentsList.DEFAULT) .ChangePrecursorResolution(FullScanMassAnalyzerType.centroided, ppm, 0))); AssertEx.Serializable(docNoCentroid, AssertEx.DocumentCloned); Assume.IsTrue(docContainer.SetDocument(docNoCentroid, docContainer.Document)); const double mzTest = 400.0; var filterWidth = docNoCentroid.Settings.TransitionSettings.FullScan.GetPrecursorFilterWindow(mzTest); Assume.AreEqual(mzTest * 2.0 * ppm * 1E-6, filterWidth); // Verify relationship between normal and high-selectivity extraction var docTofNormal = docNoCentroid.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorResolution(FullScanMassAnalyzerType.tof, 50 * 1000, null))); AssertEx.Serializable(docTofNormal, AssertEx.DocumentCloned); var docTofSelective = docTofNormal.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorResolution(FullScanMassAnalyzerType.tof, 25 * 1000, null) .ChangeUseSelectiveExtraction(true))); AssertEx.Serializable(docTofSelective, AssertEx.DocumentCloned); var filterWidthTof = docTofNormal.Settings.TransitionSettings.FullScan.GetPrecursorFilterWindow(mzTest); var filterWidthSelective = docTofSelective.Settings.TransitionSettings.FullScan.GetPrecursorFilterWindow(mzTest); Assume.AreEqual(filterWidth, filterWidthTof); Assume.AreEqual(filterWidth, filterWidthSelective); // Verify handling of bad request for vendor centroided data - ask for centroiding in mzML const string fileName = "S_2_LVN.mzML"; var filePath = testFilesDir.GetTestPath(fileName); AssertEx.ThrowsException <AssertFailedException>(() => { listResults = new List <ChromatogramSet> { new ChromatogramSet("rep1", new[] { new MsDataFilePath(filePath) }), }; docContainer.ChangeMeasuredResults(new MeasuredResults(listResults.ToArray()), 1, 1, 1); }, string.Format(Resources.NoCentroidedDataException_NoCentroidedDataException_No_centroided_data_available_for_file___0_____Adjust_your_Full_Scan_settings_, filePath)); // Import FT data with only MS1 docPath = testFilesDir.GetTestPath("Yeast_HI3 Peptides_test.sky"); expectedPepCount = 2; expectedTransGroupCount = 2; expectedTransCount = 2; doc = InitFullScanDocument(ref docPath, 2, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules); Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer); Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer); var docMs1 = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 1, IsotopeEnrichmentsList.DEFAULT) .ChangePrecursorResolution(FullScanMassAnalyzerType.tof, 50 * 1000, null))); Assume.AreEqual(filterWidth, docMs1.Settings.TransitionSettings.FullScan.GetPrecursorFilterWindow(mzTest)); docMs1 = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 1, IsotopeEnrichmentsList.DEFAULT) .ChangePrecursorResolution(FullScanMassAnalyzerType.ft_icr, 50 * 1000, mzTest))); AssertEx.Serializable(docMs1, AssertEx.DocumentCloned); Assume.IsTrue(docContainer.SetDocument(docMs1, docContainer.Document)); const string rep1 = "rep1"; listResults = new List <ChromatogramSet> { new ChromatogramSet(rep1, new[] { filePath }), }; measuredResults = new MeasuredResults(listResults.ToArray()); docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, 1, 1, 1)); // Because of the way the mzML files were filtered, all of the LVN peaks should be present // in the first replicate, and all of the NVN peaks should be present in the other. var matchIdentifierLVN = "LVN"; if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none) { matchIdentifierLVN = RefinementSettings.TestingConvertedFromProteomicPeptideNameDecorator + matchIdentifierLVN; } foreach (var nodeTranGroup in docContainer.Document.MoleculeTransitionGroups) { foreach (var docNode in nodeTranGroup.Children) { var nodeTran = (TransitionDocNode)docNode; Assume.IsTrue(nodeTran.HasResults); Assume.AreEqual(1, nodeTran.Results.Count); if (nodeTran.Transition.Group.Peptide.Target.ToString().StartsWith(matchIdentifierLVN)) { Assume.IsFalse(nodeTran.Results[0][0].IsEmpty); } else { Assume.IsTrue(nodeTran.Results[0][0].IsEmpty); } } } const string rep2 = "rep2"; listResults.Add(new ChromatogramSet(rep2, new[] { testFilesDir.GetTestPath("S_2_NVN.mzML") })); measuredResults = new MeasuredResults(listResults.ToArray()); docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, 1, 1, 1)); // Because of the way the mzML files were filtered, all of the LVN peaks should be present // in the first replicate, and all of the NVN peaks should be present in the other. foreach (var nodeTranGroup in docContainer.Document.MoleculeTransitionGroups) { foreach (var docNode in nodeTranGroup.Children) { var nodeTran = (TransitionDocNode)docNode; Assume.IsTrue(nodeTran.HasResults); Assume.AreEqual(2, nodeTran.Results.Count); if (nodeTran.Transition.Group.Peptide.Target.ToString().StartsWith(matchIdentifierLVN)) { Assume.IsTrue(nodeTran.Results[1][0].IsEmpty); } else { Assume.IsFalse(nodeTran.Results[1][0].IsEmpty); } } } // Chromatograms should be present in the cache for a number of isotopes. var docMs1Isotopes = docContainer.Document.ChangeSettings(doc.Settings .ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 3, IsotopeEnrichmentsList.DEFAULT)) .ChangeTransitionFilter(filter => filter.ChangePeptideIonTypes(new[] { IonType.precursor }) .ChangeSmallMoleculeIonTypes(new[] { IonType.precursor }))); docCheckpoints.Add(docMs1Isotopes); AssertEx.IsDocumentState(docMs1Isotopes, null, 2, 2, 2); // Need to reset auto-manage for transitions var refineAutoSelect = new RefinementSettings { AutoPickChildrenAll = PickLevel.transitions }; docMs1Isotopes = refineAutoSelect.Refine(docMs1Isotopes); AssertEx.IsDocumentState(docMs1Isotopes, null, 2, 2, 6); AssertResult.IsDocumentResultsState(docMs1Isotopes, rep1, 1, 1, 0, 3, 0); AssertResult.IsDocumentResultsState(docMs1Isotopes, rep2, 1, 1, 0, 3, 0); docCheckpoints.Add(docMs1Isotopes); // Add M-1 transitions, and verify that they have chromatogram data also, but // empty peaks in all cases var docMs1All = docMs1Isotopes.ChangeSettings(docMs1Isotopes.Settings .ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Percent, 0, IsotopeEnrichmentsList.DEFAULT)) .ChangeTransitionIntegration(i => i.ChangeIntegrateAll(false))); // For compatibility with v2.5 and earlier docCheckpoints.Add(docMs1All); AssertEx.IsDocumentState(docMs1All, null, 2, 2, 10); AssertResult.IsDocumentResultsState(docMs1All, rep1, 1, 1, 0, 4, 0); AssertResult.IsDocumentResultsState(docMs1All, rep2, 1, 1, 0, 4, 0); var ms1AllTranstions = docMs1All.MoleculeTransitions.ToArray(); var tranM1 = ms1AllTranstions[0]; Assert.AreEqual(-1, tranM1.Transition.MassIndex); Assert.IsTrue(!tranM1.Results[0].IsEmpty && !tranM1.Results[1].IsEmpty); Assert.IsTrue(tranM1.Results[0][0].IsEmpty && tranM1.Results[1][0].IsForcedIntegration); tranM1 = ms1AllTranstions[5]; Assert.AreEqual(-1, tranM1.Transition.MassIndex); Assert.IsTrue(!tranM1.Results[0].IsEmpty && !tranM1.Results[1].IsEmpty); Assert.IsTrue(tranM1.Results[0][0].IsForcedIntegration && tranM1.Results[1][0].IsEmpty); } }