/* * public override List<double> ScoreSequences(List<string> seqs) * { * List<DbIrtPeptide> dbPeps; * try * { * dbPeps = Database.GetPeptides(seqs); * } * catch (NullReferenceException) * { * throw new DatabaseNotConnectedException(this); * } * var scores = new List<double>(); * * foreach(var pep in dbPeps) * scores.Add(pep == null? 0 : pep.Irt); * return scores; * } */ public RCalcIrt ChangeDatabasePath(string path) { return(ChangeProp(ImClone(this), im => { im.DatabasePath = path; im.Database = IrtDb.GetIrtDb(path); })); }
public static void CreateIrtDb(string path, ProcessedIrtAverages processed, DbIrtPeptide[] standardPeptides, bool recalibrate, IrtRegressionType regressionType, IProgressMonitor monitor) { DbIrtPeptide[] newStandards = null; if (recalibrate) { monitor.UpdateProgress(new ProgressStatus().ChangeSegments(0, 2)); newStandards = processed.RecalibrateStandards(standardPeptides).ToArray(); processed = RCalcIrt.ProcessRetentionTimes(monitor, processed.ProviderData.Select(data => data.RetentionTimeProvider).ToArray(), newStandards.ToArray(), new DbIrtPeptide[0], regressionType); } var irtDb = IrtDb.CreateIrtDb(path); irtDb.AddPeptides(monitor, (newStandards ?? standardPeptides).Concat(processed.DbIrtPeptides).ToList()); }
private bool CheckConnection() { if (!File.Exists(DatabasePath) || Database == null) { return(false); } try { IrtDb.GetIrtDb(DatabasePath); return(true); } catch (DatabaseOpeningException) { return(false); } }
public static void CreateIrtDatabase(string path) { FileEx.SafeDelete(path); //Create file, initialize db try { IrtDb.CreateIrtDb(path); } catch (DatabaseOpeningException) { throw; } catch (Exception x) { var message = TextUtil.LineSeparate(string.Format(Resources.EditIrtCalcDlg_CreateDatabase_The_file__0__could_not_be_created, path), x.Message); throw new IOException(message, x); } }
public void ExportSpectralLibrary(string path, IProgressMonitor progressMonitor) { const string name = "exported"; var spectra = new Dictionary <LibKey, SpectrumMzInfo>(); foreach (var nodePepGroup in Document.MoleculeGroups) { foreach (var nodePep in nodePepGroup.Molecules) { foreach (var nodeTranGroup in nodePep.TransitionGroups) { for (var i = 0; i < Document.Settings.MeasuredResults.Chromatograms.Count; i++) { ProcessTransitionGroup(spectra, nodePepGroup, nodePep, nodeTranGroup, i); } } } } var rCalcIrt = Document.Settings.HasRTPrediction ? Document.Settings.PeptideSettings.Prediction.RetentionTime.Calculator as RCalcIrt : null; IProgressStatus status = new ProgressStatus(); if (rCalcIrt != null && progressMonitor != null) { progressMonitor.UpdateProgress(status = status.ChangeSegments(0, 2)); } using (var blibDb = BlibDb.CreateBlibDb(path)) { var libSpec = new BiblioSpecLiteSpec(name, path); blibDb.CreateLibraryFromSpectra(libSpec, spectra.Values.ToList(), name, progressMonitor, ref status); } if (rCalcIrt != null) { IrtDb.CreateIrtDb(path).AddPeptides(progressMonitor, rCalcIrt.GetDbIrtPeptides().ToList(), ref status); } }
protected override void DoTest() { const int numStandardPeps = 11; const int numLibraryPeps = 18; const string irtCalc = "iRT-C18"; const string ssrCalc = "SSRCalc 3.0 (300A)"; var testFilesDir = new TestFilesDir(TestContext, TestFilesZip); string databasePath = testFilesDir.GetTestPath("irt-c18.irtdb"); string documentPath = testFilesDir.GetTestPath("iRT Test.sky"); RunUI(() => SkylineWindow.OpenFile(documentPath)); var peptideSettingsDlg1 = ShowDialog <PeptideSettingsUI>( () => SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Prediction)); var editRT1 = ShowDialog <EditRTDlg>(peptideSettingsDlg1.AddRTRegression); var irtDlg1 = ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator); RunUI(() => { irtDlg1.CalcName = irtCalc; irtDlg1.CreateDatabase(databasePath); }); var calibratePeptides = new List <MeasuredPeptide>(); /* * Check several error handling cases * Check the peptide choosing algorithm for sanity (correct # peptides) * Check that the info dialog comes up when too many are requested * Check the peptide linear transformation for sanity * Check that the peptides get passed back to EditIrtCalcDlg */ var calibrateDlg = ShowDialog <CalibrateIrtDlg>(irtDlg1.Calibrate); //Check the peptide choosing algorithm int peptideCount = SkylineWindow.Document.PeptideCount; //29 peptides in the document //Use the dialog box UI var countDlg = ShowDialog <AddIrtStandardsDlg>(calibrateDlg.UseResults); RunUI(() => countDlg.StandardCount = CalibrateIrtDlg.MIN_STANDARD_PEPTIDES - 1); RunDlg <MessageDlg>(countDlg.OkDialog, messageDlg => messageDlg.OkDialog()); RunUI(() => { countDlg.StandardCount = peptideCount; countDlg.OkDialog(); }); WaitForClosedForm(countDlg); Assert.AreEqual(peptideCount, calibrateDlg.StandardPeptideCount); //Bypass the UI foreach (int i in new[] { peptideCount, peptideCount / 2, CalibrateIrtDlg.MIN_STANDARD_PEPTIDES *2, CalibrateIrtDlg.MIN_STANDARD_PEPTIDES }) { int j = i; RunUI(() => { calibratePeptides = calibrateDlg.Recalculate(SkylineWindow.Document, j); Assert.AreEqual(calibratePeptides.Count, j); Assert.IsNull(FindOpenForm <MessageDlg>()); }); } RunUI(() => { calibrateDlg.Recalculate(SkylineWindow.Document, 11); //After closing this dialog, there should be 3 iRT values below 0 //and 3 above 100 calibrateDlg.SetFixedPoints(3, 7); calibrateDlg.OkDialog(); }); WaitForClosedForm(calibrateDlg); //Now check that the peptides were passed to the EditIrtCalcDlg RunUI(() => { Assert.AreEqual(numStandardPeps, irtDlg1.StandardPeptideCount); //And that there are 3 below 0 and 3 above 100 Assert.AreEqual(3, irtDlg1.StandardPeptides.Count(pep => pep.Irt < 0)); Assert.AreEqual(3, irtDlg1.StandardPeptides.Count(pep => pep.Irt > 100)); irtDlg1.ClearStandardPeptides(); }); /* * Test pasting into EditIrtCalcDlg * Test that the dialog requires the whole standard to be in the document * Test that add results gets everything in the document besides the standard * Test that there were no errors along the way */ //Now paste in iRT with each peptide truncated by one amino acid var standard = new[] { BuildMeasuredPeptide("LGGNEQVTR", -24.92), BuildMeasuredPeptide("GAGSSEPVTGLDAK", 0.00), BuildMeasuredPeptide("VEATFGVDESNAK", 12.39), BuildMeasuredPeptide("YILAGVENSK", 19.79), BuildMeasuredPeptide("TPVISGGPYEYR", 28.71), BuildMeasuredPeptide("TPVITGAPYEYR", 33.38), BuildMeasuredPeptide("DGLDAASYYAPVR", 42.26), BuildMeasuredPeptide("ADVTPADFSEWSK", 54.62), BuildMeasuredPeptide("GTFIIDPGGVIR", 70.52), BuildMeasuredPeptide("GTFIIDPAAVIR", 87.23), BuildMeasuredPeptide("LFLQFGAQGSPFLK", 100.00), }; RunUI(() => { string standardText = BuildStandardText(standard, seq => seq.Substring(0, seq.Length - 1)); SetClipboardText(standardText); irtDlg1.DoPasteStandard(); }); // Cannot add results because standard peptides are not in the document RunDlg <AddIrtPeptidesDlg>(irtDlg1.AddResults, messageDlg => messageDlg.OkDialog()); // Paste Biognosys-provided values RunUI(() => { string standardText = BuildStandardText(standard, seq => seq); SetClipboardText(standardText); irtDlg1.ClearStandardPeptides(); irtDlg1.DoPasteStandard(); //Check count Assert.AreEqual(numStandardPeps, irtDlg1.StandardPeptideCount); }); //Add results var addPeptidesDlg1 = ShowDialog <AddIrtPeptidesDlg>(irtDlg1.AddResults); var recalibrateDlg1 = ShowDialog <MultiButtonMsgDlg>(addPeptidesDlg1.OkDialog); OkDialog(recalibrateDlg1, recalibrateDlg1.Btn1Click); RunUI(() => Assert.AreEqual(numLibraryPeps, irtDlg1.LibraryPeptideCount)); // Recalibrate const int shift = 100; const int skew = 10; RunDlg <RecalibrateIrtDlg>(irtDlg1.Calibrate, recalDlg => { recalDlg.MinIrt = standard[1].RetentionTime + shift; recalDlg.MaxIrt = standard[standard.Length - 1].RetentionTime * skew + shift; recalDlg.FixedPoint1 = standard[1].Sequence; recalDlg.FixedPoint2 = standard[standard.Length - 1].Sequence; recalDlg.OkDialog(); }); RunUI(() => { for (int i = 0; i < irtDlg1.StandardPeptideCount; i++) { Assert.AreEqual(standard[i].RetentionTime * skew + shift, irtDlg1.StandardPeptides.Skip(i).First().Irt); } }); RunDlg <RecalibrateIrtDlg>(irtDlg1.Calibrate, recalDlg => { recalDlg.FixedPoint1 = standard[2].Sequence; recalDlg.FixedPoint2 = standard[standard.Length - 2].Sequence; recalDlg.MinIrt = standard[2].RetentionTime; recalDlg.MaxIrt = standard[standard.Length - 2].RetentionTime; recalDlg.OkDialog(); }); // Change peptides var changePeptides = irtDlg1.LibraryPeptides.Where((p, i) => i % 2 == 0).ToArray(); var resetPeptides = irtDlg1.StandardPeptides.ToArray(); RunDlg <ChangeIrtPeptidesDlg>(irtDlg1.ChangeStandardPeptides, changeDlg => { changeDlg.Peptides = changePeptides; changeDlg.OkDialog(); }); Assert.IsTrue(ArrayUtil.EqualsDeep(changePeptides.Select(p => p.Target).ToArray(), irtDlg1.StandardPeptides.Select(p => p.Target).ToArray())); Assert.IsTrue(ArrayUtil.EqualsDeep(changePeptides.Select(p => p.Irt).ToArray(), irtDlg1.StandardPeptides.Select(p => p.Irt).ToArray())); RunDlg <ChangeIrtPeptidesDlg>(irtDlg1.ChangeStandardPeptides, changeDlg => { changeDlg.Peptides = resetPeptides; changeDlg.OkDialog(); }); OkDialog(irtDlg1, irtDlg1.OkDialog); Assert.IsNull(FindOpenForm <MessageDlg>()); /* * Check that the database was created successfully * Check that it has the correct numbers of standard and library peptides */ IrtDb db = IrtDb.GetIrtDb(databasePath, null); Assert.AreEqual(numStandardPeps, db.StandardPeptideCount); Assert.AreEqual(numLibraryPeps, db.LibraryPeptideCount); /* * Make sure that loading the database brings back up the right numbers of peptides */ //Rather than rigging SettingsListComboDriver, just create a new one and load var irtDlg1A = ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator); RunDlg <MessageDlg>(() => irtDlg1A.OpenDatabase(testFilesDir.GetTestPath("bogus.irtdb")), messageDlg => messageDlg.OkDialog()); //There was a _bug_ where opening a path and then clicking OK would save all the peptides //twice, doubling the size of the database. So check that that is fixed. EditIrtCalcDlgPepCountTest(irtDlg1A, numStandardPeps, numLibraryPeps, databasePath, false); EditIrtCalcDlgPepCountTest(ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator), numStandardPeps, numLibraryPeps, databasePath, false); EditIrtCalcDlgPepCountTest(ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator), numStandardPeps, numLibraryPeps, databasePath, true); EditIrtCalcDlgPepCountTest(ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator), numStandardPeps, numLibraryPeps, databasePath, false); /* * Create a regression based on the new calculator * Create a regression based on SSRCalc * Open the graph * Switch to new calculator, verify r = 1.00 and graph is labeled iRT-C18 * Switch to SSRCalc, verify graph label changes */ RunUI(() => { editRT1.SetRegressionName("iRT Regression"); editRT1.AddResults(); editRT1.ChooseCalculator(irtCalc); editRT1.OkDialog(); }); WaitForClosedForm(editRT1); var editRT1A = ShowDialog <EditRTDlg>(peptideSettingsDlg1.AddRTRegression); RunUI(() => { editRT1A.SetRegressionName("SSRCalc Regression"); editRT1A.AddResults(); editRT1A.ChooseCalculator(ssrCalc); }); RunDlg <RTDetails>(editRT1A.ShowDetails, detailsDlg => detailsDlg.Close()); OkDialog(editRT1A, editRT1A.OkDialog); RunUI(peptideSettingsDlg1.CancelButton.PerformClick); WaitForClosedForm(peptideSettingsDlg1); var docPeptides = new List <MeasuredRetentionTime>(); RunUI(() => { var document = Program.ActiveDocumentUI; foreach (var docPepNode in document.Peptides) { docPeptides.Add(new MeasuredRetentionTime(document.Settings.GetModifiedSequence(docPepNode), docPepNode.AverageMeasuredRetentionTime ?? 0)); } }); RetentionTimeStatistics stats = null; RegressionLineElement line = null; RunUI(() => SkylineWindow.ShowRTRegressionGraphScoreToRun()); WaitForRegression(); RunUI(() => { SkylineWindow.SetupCalculatorChooser(); SkylineWindow.ChooseCalculator(irtCalc); }); WaitForRegression(); RunUI(() => { stats = SkylineWindow.RTGraphController.RegressionRefined.CalcStatistics(docPeptides, null); line = SkylineWindow.RTGraphController.RegressionRefined.Conversion as RegressionLineElement; }); Assert.IsNotNull(stats); Assert.IsTrue(stats.R > 0.999); Assert.IsNotNull(line); //These values were taken from the graph, which shows values to 2 decimal places, so the real values must //be +/- 0.01 from these values Assert.IsTrue(Math.Abs(line.Intercept - 14.17) < 0.01); Assert.IsTrue(Math.Abs(line.Slope - 0.15) < 0.01); RunUI(() => SkylineWindow.ChooseCalculator(ssrCalc)); WaitForRegression(); RunUI(() => stats = SkylineWindow.RTGraphController.RegressionRefined.CalcStatistics(docPeptides, null)); Assert.IsNotNull(stats); Assert.IsTrue(Math.Abs(stats.R - 0.97) < 0.01); /* * Delete all peptides except the standard * Create a new calculator with the document standard (instead of pasting) * Create a regression with that calculator * Export a transition list using measured retention times * Export a method using predicted retention times * Test that they are identical */ //Delete from the document all but the last protein, which has all the standard peptides RunUI(() => { SkylineWindow.CollapseProteins(); var seqTree = SkylineWindow.SequenceTree; seqTree.SelectedNode = seqTree.Nodes[0]; seqTree.KeysOverride = Keys.Shift; seqTree.SelectedNode = seqTree.Nodes[17]; SkylineWindow.EditDelete(); }); //Peptide settings dialog -> Add a regression var peptideSettingsDlg2 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); var editRT2 = ShowDialog <EditRTDlg>(peptideSettingsDlg2.AddRTRegression); //Set regression name RunUI(() => editRT2.SetRegressionName("iRT Document Regression")); //Regression dialog -> add a calculator var irtDlg2 = ShowDialog <EditIrtCalcDlg>(editRT2.AddCalculator); //Set calc name, database RunUI(() => { irtDlg2.CalcName = "iRT Document Calculator"; irtDlg2.CreateDatabase(testFilesDir.GetTestPath("irt-doc.irtdb")); }); //Calc dialog -> calibrate standard RunDlg <CalibrateIrtDlg>(irtDlg2.Calibrate, calibrateDlg2 => { //Get 11 peptides from the document (all of them) and go back to calculator dialog calibrateDlg2.Recalculate(SkylineWindow.Document, 11); calibrateDlg2.OkDialog(); }); Assert.AreEqual(11, irtDlg2.StandardPeptideCount); Assert.AreEqual(0, irtDlg2.LibraryPeptideCount); // Close dialog to save calculator OkDialog(irtDlg2, irtDlg2.OkDialog); // Test adding irt calculator { var irtDlgAdd = ShowDialog <EditIrtCalcDlg>(editRT2.EditCurrentCalculator); var addDlg = ShowDialog <AddIrtCalculatorDlg>(irtDlgAdd.AddIrtDatabase); // Check error messages RunUI(() => addDlg.Source = IrtCalculatorSource.file); RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg => { Assert.AreEqual(Resources.AddIrtCalculatorDlg_OkDialog_Please_specify_a_path_to_an_existing_iRT_database, messageDlg.Message); messageDlg.OkDialog(); }); RunUI(() => addDlg.FilePath = "not_irtdb.docx"); RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg => { AssertEx.AreComparableStrings(Resources.AddIrtCalculatorDlg_OkDialog_The_file__0__is_not_an_iRT_database, messageDlg.Message); messageDlg.OkDialog(); }); RunUI(() => addDlg.FilePath = "not_exist.irtdb"); RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg => { AssertEx.AreComparableStrings(TextUtil.LineSeparate( Resources.AddIrtCalculatorDlgOkDialogThe_file__0__does_not_exist, Resources.AddIrtCalculatorDlg_OkDialog_Please_specify_a_path_to_an_existing_iRT_database), messageDlg.Message); messageDlg.OkDialog(); }); RunUI(() => addDlg.CalculatorName = "noexist"); PauseForScreenShot(); RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg => { Assert.AreEqual(Resources.AddIrtCalculatorDlg_OkDialog_Please_choose_the_iRT_calculator_you_would_like_to_add, messageDlg.Message); messageDlg.OkDialog(); }); RunUI(() => addDlg.FilePath = databasePath); var addPepDlg = ShowDialog <AddIrtPeptidesDlg>(addDlg.OkDialog); var recalibrateDlg = ShowDialog <MultiButtonMsgDlg>(addPepDlg.OkDialog); OkDialog(recalibrateDlg, recalibrateDlg.Btn1Click); Assert.AreEqual(18, irtDlgAdd.LibraryPeptideCount); OkDialog(irtDlgAdd, irtDlgAdd.CancelButton.PerformClick); } // Add from existing calculator { var irtDlgAdd = ShowDialog <EditIrtCalcDlg>(editRT2.EditCurrentCalculator); var addDlg = ShowDialog <AddIrtCalculatorDlg>(irtDlgAdd.AddIrtDatabase); RunUI(() => addDlg.CalculatorName = irtCalc); var addPepDlg = ShowDialog <AddIrtPeptidesDlg>(addDlg.OkDialog); var recalibrateDlg = ShowDialog <MultiButtonMsgDlg>(addPepDlg.OkDialog); OkDialog(recalibrateDlg, recalibrateDlg.Btn1Click); Assert.AreEqual(18, irtDlgAdd.LibraryPeptideCount); OkDialog(irtDlgAdd, irtDlgAdd.CancelButton.PerformClick); } var docIrtBefore = SkylineWindow.Document; OkDialog(editRT2, editRT2.OkDialog); OkDialog(peptideSettingsDlg2, peptideSettingsDlg2.OkDialog); WaitForClosedForm(peptideSettingsDlg2); var docIrt = VerifyIrtStandards(docIrtBefore, true); RunUI(() => { // Select 3 of the standards and delete them SkylineWindow.SequenceTree.KeysOverride = Keys.None; SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 0); SkylineWindow.SequenceTree.KeysOverride = Keys.Shift; SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 2); SkylineWindow.SequenceTree.KeysOverride = Keys.None; SkylineWindow.EditDelete(); }); // Should still have iRT peptides docIrt = VerifyIrtStandards(docIrt, true); // Remove one more and standards should be cleared RunUI(SkylineWindow.Cut); docIrt = VerifyIrtStandards(docIrt, false); RunUI(SkylineWindow.Paste); docIrt = VerifyIrtStandards(docIrt, true); // Repeat without results RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg => { dlg.RemoveAllReplicates(); dlg.OkDialog(); }); docIrt = VerifyIrtStandards(docIrt, true); RunUI(SkylineWindow.EditDelete); docIrt = VerifyIrtStandards(docIrt, false); RunUI(SkylineWindow.Paste); VerifyIrtStandards(docIrt, true); //Restore the document to contain all 29 peptides RunUI(() => SkylineWindow.UndoRestore(7)); //Open peptide settings var peptideSettingsDlg3 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunDlg <EditListDlg <SettingsListBase <RetentionTimeRegression>, RetentionTimeRegression> >(peptideSettingsDlg3.EditRegressionList, dlg => { dlg.SelectLastItem(); dlg.RemoveItem(); dlg.OkDialog(); }); //Add a new regression var editRT3 = ShowDialog <EditRTDlg>(peptideSettingsDlg3.AddRTRegression); RunUI(() => editRT3.SetRegressionName("iRT Document Regression")); //Edit the calculator list var editCalculator = ShowDialog <EditListDlg <SettingsListBase <RetentionScoreCalculatorSpec>, RetentionScoreCalculatorSpec> >( editRT3.EditCalculatorList); RunUI(() => editCalculator.SelectItem("iRT Document Calculator")); //Edit the document-based calculator var irtDlg3 = ShowDialog <EditIrtCalcDlg>(editCalculator.EditItem); //Add the 18 non-standard peptides to the calculator, then OkDialog back to Skyline var addPeptidesDlg = ShowDialog <AddIrtPeptidesDlg>(irtDlg3.AddResults); var recalibrateDlg2 = ShowDialog <MultiButtonMsgDlg>(addPeptidesDlg.OkDialog); OkDialog(recalibrateDlg2, recalibrateDlg2.Btn1Click); RunUI(() => { Assert.AreEqual(18, irtDlg3.LibraryPeptideCount); irtDlg3.OkDialog(); }); WaitForClosedForm(irtDlg3); RunUI(editCalculator.OkDialog); WaitForClosedForm(editCalculator); RunUI(() => { editRT3.AddResults(); editRT3.ChooseCalculator("iRT Document Calculator"); editRT3.SetTimeWindow(2.0); editRT3.OkDialog(); }); WaitForClosedForm(editRT3); //Then choose the new, document-based regression and turn off prediction RunUI(() => { peptideSettingsDlg3.ChooseRegression("iRT Document Regression"); peptideSettingsDlg3.IsUseMeasuredRT = true; peptideSettingsDlg3.OkDialog(); }); WaitForClosedForm(peptideSettingsDlg3); Assert.IsNull(FindOpenForm <MessageDlg>()); //Export the measurement-based transition list ExportMethod(testFilesDir.GetTestPath("EmpiricalTL.csv")); //Turn on prediction for scheduling var peptideSettingsDlg4 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunUI(() => { peptideSettingsDlg4.IsUseMeasuredRT = false; peptideSettingsDlg4.OkDialog(); }); WaitForClosedForm(peptideSettingsDlg4); //Export the prediction-based transition list ExportMethod(testFilesDir.GetTestPath("PredictionTL.csv")); //Now open both files and compare AssertEx.NoDiff(File.ReadAllText(testFilesDir.GetTestPath("EmpiricalTL.csv")), File.ReadAllText(testFilesDir.GetTestPath("PredictionTL.csv"))); // Close and re-open, and try again RunUI(() => { Assert.IsTrue(SkylineWindow.SaveDocument()); SkylineWindow.NewDocument(); Assert.IsTrue(SkylineWindow.OpenFile(documentPath)); }); WaitForDocumentLoaded(); ExportMethod(testFilesDir.GetTestPath("PredictionTL_reopen.csv")); AssertEx.NoDiff(File.ReadAllText(testFilesDir.GetTestPath("EmpiricalTL.csv")), File.ReadAllText(testFilesDir.GetTestPath("PredictionTL_reopen.csv"))); /* * Rename the database * Switch to the calculator in EditRTDlg and check for an error * Go to edit the calculator and check for an error * Try to export a transition list and check for an error * Switch to the calculator in the graph and check for an error */ var stream = File.Create(testFilesDir.GetTestPath("irt-c18-copy.irtdb")); stream.Close(); File.Replace(databasePath, testFilesDir.GetTestPath("irt-c18-copy.irtdb"), testFilesDir.GetTestPath("backup.irtdb")); // The database renaming doesn't break usage anymore, since // the iRT databases are loaded into memory during initialization. // So, create a new calculator with a bogus path. const string irtCalcMissing = "iRT-C18-missing"; Settings.Default.RTScoreCalculatorList.SetValue(new RCalcIrt(irtCalcMissing, testFilesDir.GetTestPath("irt-c18-missing.irtdb"))); var peptideSettingsDlg5 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); var editRT5 = ShowDialog <EditRTDlg>(peptideSettingsDlg5.AddRTRegression); //Add results and switch to a calculator whose database is not connected: error RunDlg <MessageDlg>(() => { editRT5.AddResults(); editRT5.ChooseCalculator(irtCalcMissing); }, errorMessage => errorMessage.OkDialog()); //Go to add a new calculator var irtDlg5 = ShowDialog <EditIrtCalcDlg>(editRT5.AddCalculator); //Try to open a file that does not exist: error RunDlg <MessageDlg>(() => irtDlg5.OpenDatabase(databasePath), messageDlg => messageDlg.OkDialog()); RunUI(() => irtDlg5.CancelButton.PerformClick()); WaitForClosedForm(irtDlg5); //In order to export a transition list, we have to set the RT regression to have the iRT Calc. //This means that the iRT calc must have its database connected - else the dialog will not let //the user choose it. So here we will restore the file so we can choose the calculator. //Then once that dialog is closed and the regression is saved, switch the file back again. stream = File.Create(databasePath); stream.Close(); File.Replace(testFilesDir.GetTestPath("irt-c18-copy.irtdb"), databasePath, testFilesDir.GetTestPath("backup.irtdb")); RunUI(() => { editRT5.SetRegressionName("iRT Test Regression"); editRT5.AddResults(); editRT5.ChooseCalculator(irtCalc); editRT5.OkDialog(); }); WaitForClosedForm(editRT5); RunUI(() => { peptideSettingsDlg5.ChooseRegression("iRT Test Regression"); peptideSettingsDlg5.IsUseMeasuredRT = false; //Use prediction peptideSettingsDlg5.OkDialog(); }); WaitForClosedForm(peptideSettingsDlg5); RunUI(() => SkylineWindow.SaveDocument()); //Switch the file back to the copy, destroying the original stream = File.Create(testFilesDir.GetTestPath("irt-c18-copy.irtdb")); stream.Close(); File.Replace(databasePath, testFilesDir.GetTestPath("irt-c18-copy.irtdb"), testFilesDir.GetTestPath("backup.irtdb")); var exportTransList = ShowDialog <ExportMethodDlg>(SkylineWindow.ShowExportTransitionListDlg); // Used to cause a message box, but should work now, because iRT databases get loaded once RunUI(() => exportTransList.SetMethodType(ExportMethodType.Scheduled)); RunUI(() => exportTransList.CancelButton.PerformClick()); WaitForClosedForm(exportTransList); // Used to cause a message box, but should work now, because iRT databases get loaded once RunUI(() => SkylineWindow.ChooseCalculator(irtCalc)); /* * Now clean up by deleting all these calculators. If we don't, then the next functional test * will fail because it will try to use a calculator from settings which will not have its * database. */ RunDlg <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI, peptideSettingsDlg6 => { peptideSettingsDlg6.ChooseRegression(Resources.SettingsList_ELEMENT_NONE_None); peptideSettingsDlg6.OkDialog(); }); // Finally, close and re-open the document to see MissingFileDlg int pepCount = SkylineWindow.Document.PeptideCount; RunUI(() => SkylineWindow.NewDocument(true)); Assert.AreEqual(0, SkylineWindow.Document.PeptideCount); RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath), dlg => dlg.OkDialog()); Assert.AreEqual(pepCount, SkylineWindow.Document.PeptideCount); RunUI(() => SkylineWindow.NewDocument(true)); RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath), dlg => dlg.CancelDialog()); Assert.AreEqual(0, SkylineWindow.Document.PeptideCount); // Make sure no message boxes are left open Assert.IsNull(FindOpenForm <MessageDlg>()); }
private bool AddIrts(LibraryManager.BuildState buildState) { try { Library lib; ProcessedIrtAverages processed = null; var initialMessage = Resources.LibraryBuildNotificationHandler_LibraryBuildCompleteCallback_Adding_iRTs_to_library; using (var longWait = new LongWaitDlg { Text = Resources.LibraryBuildNotificationHandler_LibraryBuildCompleteCallback_Adding_iRTs_to_library }) { var status = longWait.PerformWork(TopMostApplicationForm, 800, monitor => { var initStatus = new ProgressStatus(initialMessage).ChangeSegments(0, 2); monitor.UpdateProgress(initStatus); lib = NotificationContainer.LibraryManager.TryGetLibrary(buildState.LibrarySpec) ?? NotificationContainer.LibraryManager.LoadLibrary(buildState.LibrarySpec, () => new DefaultFileLoadMonitor(monitor)); foreach (var stream in lib.ReadStreams) { stream.CloseStream(); } if (longWait.IsCanceled) { return; } var irtProviders = lib.RetentionTimeProvidersIrt.ToArray(); if (!irtProviders.Any()) { irtProviders = lib.RetentionTimeProviders.ToArray(); } processed = RCalcIrt.ProcessRetentionTimes(monitor, irtProviders, irtProviders.Length, buildState.IrtStandard.Peptides.ToArray(), new DbIrtPeptide[0]); }); if (status.IsCanceled) { return(false); } if (status.IsError) { throw status.ErrorException; } } using (var resultsDlg = new AddIrtPeptidesDlg(AddIrtPeptidesLocation.spectral_library, processed)) { if (resultsDlg.ShowDialog(TopMostApplicationForm) != DialogResult.OK) { return(false); } } var recalibrate = false; if (processed.CanRecalibrateStandards(buildState.IrtStandard.Peptides)) { using (var dlg = new MultiButtonMsgDlg( TextUtil.LineSeparate(Resources.LibraryGridViewDriver_AddToLibrary_Do_you_want_to_recalibrate_the_iRT_standard_values_relative_to_the_peptides_being_added_, Resources.LibraryGridViewDriver_AddToLibrary_This_can_improve_retention_time_alignment_under_stable_chromatographic_conditions_), MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false)) { if (dlg.ShowDialog(TopMostApplicationForm) == DialogResult.Yes) { recalibrate = true; } } } var processedDbIrtPeptides = processed.DbIrtPeptides.ToArray(); if (!processedDbIrtPeptides.Any()) { return(false); } using (var longWait = new LongWaitDlg { Text = Resources.LibraryBuildNotificationHandler_LibraryBuildCompleteCallback_Adding_iRTs_to_library }) { ImmutableList <DbIrtPeptide> newStandards = null; var status = longWait.PerformWork(TopMostApplicationForm, 800, monitor => { if (recalibrate) { monitor.UpdateProgress(new ProgressStatus().ChangeSegments(0, 2)); newStandards = ImmutableList.ValueOf(processed.RecalibrateStandards(buildState.IrtStandard.Peptides)); processed = RCalcIrt.ProcessRetentionTimes( monitor, processed.ProviderData.Select(data => data.Value.RetentionTimeProvider), processed.ProviderData.Count, newStandards.ToArray(), new DbIrtPeptide[0]); } var irtDb = IrtDb.CreateIrtDb(buildState.LibrarySpec.FilePath); irtDb.AddPeptides(monitor, (newStandards ?? buildState.IrtStandard.Peptides).Concat(processedDbIrtPeptides).ToList()); }); if (status.IsError) { throw status.ErrorException; } } } catch (Exception x) { MessageDlg.ShowWithException(TopMostApplicationForm, TextUtil.LineSeparate(Resources.LibraryBuildNotificationHandler_LibraryBuildCompleteCallback_An_error_occurred_trying_to_add_iRTs_to_the_library_, x.Message), x); return(false); } return(true); }
public void OkDialog() { IrtType irtType = GetIrtType(); if (textCalculatorName.Text.Length == 0) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_Calculator_name_cannot_be_empty); return; } if (_existing.Select(spec => spec.Name).Contains(textCalculatorName.Text)) { var replaceResult = MultiButtonMsgDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_A_calculator_with_that_name_already_exists___Do_you_want_to_replace_it_, MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false); if (replaceResult == DialogResult.No) { return; } } if (irtType == IrtType.existing) { try { if (!File.Exists(textOpenDatabase.Text)) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_iRT_database_field_must_contain_a_path_to_a_valid_file_); textOpenDatabase.Focus(); return; } var db = IrtDb.GetIrtDb(textOpenDatabase.Text, null); if (db == null) { throw new DatabaseOpeningException(string.Format(Resources.CreateIrtCalculatorDlg_OkDialog_Cannot_read_the_database_file__0_, textOpenDatabase.Text)); } } catch (Exception x) { MessageDlg.ShowWithException(this, string.Format(Resources.CreateIrtCalculatorDlg_OkDialog_Failed_to_open_the_database_file___0_, x.Message), x); return; } } else if (irtType == IrtType.separate_list) { if (textNewDatabase.Text.Length == 0) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_iRT_database_field_must_not_be_empty_); textNewDatabase.Focus(); return; } if (!CreateIrtDatabase(textNewDatabase.Text)) { return; } } else { if (textNewDatabaseProteins.Text.Length == 0) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_iRT_database_field_must_not_be_empty_); textNewDatabaseProteins.Focus(); return; } if (comboBoxProteins.SelectedIndex == -1) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_Please_select_a_protein_containing_the_list_of_standard_peptides_for_the_iRT_calculator_); comboBoxProteins.Focus(); return; } if (!CreateIrtDatabase(textNewDatabaseProteins.Text)) { return; } } // Make a version of the document with the new calculator in it var databaseFileName = irtType == IrtType.existing ? textOpenDatabase.Text : irtType == IrtType.separate_list ? textNewDatabase.Text : textNewDatabaseProteins.Text; var calculator = new RCalcIrt(textCalculatorName.Text, databaseFileName); // CONSIDER: Probably can't use just a static default like 10 below var retentionTimeRegression = new RetentionTimeRegression(calculator.Name, calculator, null, null, RetentionTimeRegression.DEFAULT_WINDOW, new List <MeasuredRetentionTime>()); var docNew = Document.ChangeSettings(Document.Settings.ChangePeptidePrediction(prediction => prediction.ChangeRetentionTime(retentionTimeRegression))); // Import transition list of standards, if applicable if (irtType == IrtType.separate_list) { try { if (!File.Exists(textImportText.Text)) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_Transition_list_field_must_contain_a_path_to_a_valid_file_); return; } IdentityPath selectPath; List <MeasuredRetentionTime> irtPeptides; List <TransitionImportErrorInfo> errorList; var inputs = new MassListInputs(textImportText.Text); docNew = docNew.ImportMassList(inputs, null, out selectPath, out irtPeptides, out _librarySpectra, out errorList); if (errorList.Any()) { throw new InvalidDataException(errorList[0].ErrorMessage); } _dbIrtPeptides = irtPeptides.Select(rt => new DbIrtPeptide(rt.PeptideSequence, rt.RetentionTime, true, TimeSource.scan)).ToList(); IrtFile = textImportText.Text; } catch (Exception x) { MessageDlg.ShowWithException(this, string.Format(Resources.CreateIrtCalculatorDlg_OkDialog_Error_reading_iRT_standards_transition_list___0_, x.Message), x); return; } } else if (irtType == IrtType.protein) { PeptideGroupDocNode selectedGroup = comboBoxProteins.SelectedItem as PeptideGroupDocNode; // ReSharper disable PossibleNullReferenceException _irtPeptideSequences = new HashSet <Target>(selectedGroup.Peptides.Select(pep => pep.ModifiedTarget)); // ReSharper restore PossibleNullReferenceException } Document = docNew; DialogResult = DialogResult.OK; }
private bool AddIrtLibraryTable(string path, IrtStandard standard) { if (!ImportPeptideSearch.HasDocLib || !ImportPeptideSearch.DocLib.IsLoaded) { return(false); } var lib = ImportPeptideSearch.DocLib; ProcessedIrtAverages processed = null; using (var longWait = new LongWaitDlg { Text = Resources.BuildPeptideSearchLibraryControl_AddIrtLibraryTable_Processing_Retention_Times }) { try { var status = longWait.PerformWork(WizardForm, 800, monitor => { var irtProviders = lib.RetentionTimeProvidersIrt.ToArray(); if (!irtProviders.Any()) { irtProviders = lib.RetentionTimeProviders.ToArray(); } processed = RCalcIrt.ProcessRetentionTimes(monitor, irtProviders, irtProviders.Length, standard.Peptides.ToArray(), new DbIrtPeptide[0]); }); if (status.IsError) { throw status.ErrorException; } } catch (Exception x) { MessageDlg.ShowWithException(WizardForm, TextUtil.LineSeparate(Resources.BuildPeptideSearchLibraryControl_AddIrtLibraryTable_An_error_occurred_while_processing_retention_times_, x.Message), x); return(false); } } using (var resultsDlg = new AddIrtPeptidesDlg(AddIrtPeptidesLocation.spectral_library, processed)) { if (resultsDlg.ShowDialog(this) != DialogResult.OK) { return(false); } } var recalibrate = false; if (processed.CanRecalibrateStandards(standard.Peptides)) { using (var dlg = new MultiButtonMsgDlg( TextUtil.LineSeparate(Resources.LibraryGridViewDriver_AddToLibrary_Do_you_want_to_recalibrate_the_iRT_standard_values_relative_to_the_peptides_being_added_, Resources.LibraryGridViewDriver_AddToLibrary_This_can_improve_retention_time_alignment_under_stable_chromatographic_conditions_), MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false)) { if (dlg.ShowDialog(WizardForm) == DialogResult.Yes) { recalibrate = true; } } } using (var longWait = new LongWaitDlg { Text = Resources.BuildPeptideSearchLibraryControl_AddIrtLibraryTable_Adding_iRTs_to_Library }) { try { ImmutableList <DbIrtPeptide> newStandards = null; var status = longWait.PerformWork(WizardForm, 800, monitor => { if (recalibrate) { monitor.UpdateProgress(new ProgressStatus().ChangeSegments(0, 2)); newStandards = ImmutableList.ValueOf(processed.RecalibrateStandards(standard.Peptides)); processed = RCalcIrt.ProcessRetentionTimes( monitor, processed.ProviderData.Select(data => data.Value.RetentionTimeProvider), processed.ProviderData.Count, newStandards.ToArray(), new DbIrtPeptide[0]); } var irtDb = IrtDb.CreateIrtDb(path); irtDb.AddPeptides(monitor, (newStandards ?? standard.Peptides).Concat(processed.DbIrtPeptides).ToList()); }); if (status.IsError) { throw status.ErrorException; } } catch (Exception x) { MessageDlg.ShowWithException(WizardForm, TextUtil.LineSeparate(Resources.BuildPeptideSearchLibraryControl_AddIrtLibraryTable_An_error_occurred_trying_to_add_iRTs_to_the_library_, x.Message), x); return(false); } } return(true); }
public static bool AddIrts(Library lib, LibrarySpec libSpec, IrtStandard standard, Control parent, bool useTopMostForm = false) { if (lib == null || !lib.IsLoaded || standard == null || standard.Name.Equals(IrtStandard.EMPTY.Name)) { return(false); } Control GetParent() { return(useTopMostForm ? FormUtil.FindTopLevelOpenForm(f => f is BuildLibraryNotification) ?? parent : parent); } IRetentionTimeProvider[] irtProviders = null; var cirtPeptides = new DbIrtPeptide[0]; using (var longWait = new LongWaitDlg { Text = Resources.LibraryBuildNotificationHandler_AddIrts_Loading_retention_time_providers }) { var status = longWait.PerformWork(GetParent(), 800, monitor => { monitor.UpdateProgress(new ProgressStatus().ChangePercentComplete(-1)); irtProviders = lib.RetentionTimeProvidersIrt.ToArray(); if (!irtProviders.Any()) { irtProviders = lib.RetentionTimeProviders.ToArray(); } if (ReferenceEquals(standard, IrtStandard.CIRT_SHORT)) { var libPeptides = irtProviders.SelectMany(provider => provider.PeptideRetentionTimes).Select(rt => rt.PeptideSequence).ToHashSet(); cirtPeptides = IrtStandard.CIRT.Peptides.Where(pep => libPeptides.Contains(pep.ModifiedTarget)).ToArray(); } }); if (status.IsCanceled) { return(false); } if (status.IsError) { throw status.ErrorException; } } int?numCirt = null; if (cirtPeptides.Length >= RCalcIrt.MIN_PEPTIDES_COUNT) { using (var dlg = new AddIrtStandardsDlg(cirtPeptides.Length, string.Format( Resources.LibraryBuildNotificationHandler_AddIrts__0__distinct_CiRT_peptides_were_found__How_many_would_you_like_to_use_as_iRT_standards_, cirtPeptides.Length))) { if (dlg.ShowDialog(GetParent()) != DialogResult.OK) { return(false); } numCirt = dlg.StandardCount; } } var standardPeptides = standard.Peptides.ToArray(); ProcessedIrtAverages processed = null; using (var longWait = new LongWaitDlg { Text = Resources.LibraryBuildNotificationHandler_AddIrts_Processing_retention_times }) { try { var status = longWait.PerformWork(GetParent(), 800, monitor => { processed = !numCirt.HasValue ? RCalcIrt.ProcessRetentionTimes(monitor, irtProviders, standardPeptides, new DbIrtPeptide[0]) : RCalcIrt.ProcessRetentionTimesCirt(monitor, irtProviders, cirtPeptides, numCirt.Value, out standardPeptides); }); if (status.IsCanceled) { return(false); } if (status.IsError) { throw status.ErrorException; } } catch (Exception x) { MessageDlg.ShowWithException(GetParent(), TextUtil.LineSeparate( Resources.BuildPeptideSearchLibraryControl_AddIrtLibraryTable_An_error_occurred_while_processing_retention_times_, x.Message), x); return(false); } } using (var resultsDlg = new AddIrtPeptidesDlg(AddIrtPeptidesLocation.spectral_library, processed)) { if (resultsDlg.ShowDialog(GetParent()) != DialogResult.OK) { return(false); } } var recalibrate = false; if (processed.CanRecalibrateStandards(standardPeptides)) { using (var dlg = new MultiButtonMsgDlg( TextUtil.LineSeparate(Resources.LibraryGridViewDriver_AddToLibrary_Do_you_want_to_recalibrate_the_iRT_standard_values_relative_to_the_peptides_being_added_, Resources.LibraryGridViewDriver_AddToLibrary_This_can_improve_retention_time_alignment_under_stable_chromatographic_conditions_), MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false)) { recalibrate = dlg.ShowDialog(GetParent()) == DialogResult.Yes; } } var processedDbIrtPeptides = processed.DbIrtPeptides.ToArray(); if (!processedDbIrtPeptides.Any()) { return(false); } using (var longWait = new LongWaitDlg { Text = Resources.LibraryBuildNotificationHandler_AddIrts_Adding_iRTs_to_library }) { try { DbIrtPeptide[] newStandards = null; var status = longWait.PerformWork(GetParent(), 800, monitor => { if (recalibrate) { monitor.UpdateProgress(new ProgressStatus().ChangeSegments(0, 2)); newStandards = processed.RecalibrateStandards(standardPeptides).ToArray(); processed = RCalcIrt.ProcessRetentionTimes(monitor, processed.ProviderData.Select(data => data.RetentionTimeProvider).ToArray(), newStandards.ToArray(), new DbIrtPeptide[0]); } var irtDb = IrtDb.CreateIrtDb(libSpec.FilePath); irtDb.AddPeptides(monitor, (newStandards ?? standardPeptides).Concat(processed.DbIrtPeptides).ToList()); }); if (status.IsError) { throw status.ErrorException; } } catch (Exception x) { MessageDlg.ShowWithException(GetParent(), TextUtil.LineSeparate( Resources.LibraryBuildNotificationHandler_AddIrts_An_error_occurred_trying_to_add_iRTs_to_the_library_, x.Message), x); return(false); } } return(true); }
public void ConsoleImportPeptideSearchTest() { var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE); var docPath = testFilesDir.GetTestPath("blank.sky"); var outPath = testFilesDir.GetTestPath("import-search.sky"); var searchFilePath = testFilesDir.GetTestPath("CAexample.pep.xml"); var fastaPath = testFilesDir.GetTestPath("bov-5-prot.fasta"); // with mods and invalid cutoff score const double badCutoff = 1.1; var args = new[] { "--in=" + docPath, "--out=" + outPath, "--import-search-file=" + searchFilePath, "--import-search-cutoff-score=" + badCutoff, "--import-search-add-mods", "--import-fasta=" + fastaPath }; var output = RunCommand(args); AssertEx.Contains(output, new CommandArgs.ValueOutOfRangeDoubleException(CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_CUTOFF, badCutoff, 0, 1).Message); args[3] = "--import-search-cutoff-score=" + Settings.Default.LibraryResultCutOff; output = RunCommand(args); AssertEx.Contains(output, TextUtil.LineSeparate(Resources.CommandLine_ImportSearch_Creating_spectral_library_from_files_, Path.GetFileName(searchFilePath))); AssertEx.Contains(output, string.Format(Resources.CommandLine_ImportSearch_Adding__0__modifications_, 2)); AssertEx.Contains(output, string.Format(Resources.CommandLine_ImportFasta_Importing_FASTA_file__0____, Path.GetFileName(fastaPath))); var doc = ResultsUtil.DeserializeDocument(outPath); Assert.IsTrue(doc.Settings.HasResults); Assert.AreEqual(1, doc.Settings.MeasuredResults.Chromatograms.Count); Assert.IsTrue(doc.Settings.MeasuredResults.ContainsChromatogram("CAexample")); Assert.AreEqual(5, doc.PeptideGroupCount); Assert.AreEqual(26, doc.PeptideCount); Assert.AreEqual(26, doc.PeptideTransitionGroupCount); Assert.AreEqual(78, doc.PeptideTransitionCount); // without mods var outPath2 = testFilesDir.GetTestPath("import-search2.sky"); output = RunCommand("--in=" + docPath, "--out=" + outPath2, "--import-search-file=" + searchFilePath, "--import-fasta=" + fastaPath); AssertEx.Contains(output, TextUtil.LineSeparate(Resources.CommandLine_ImportSearch_Creating_spectral_library_from_files_, Path.GetFileName(searchFilePath))); AssertEx.Contains(output, string.Format(Resources.CommandLine_ImportFasta_Importing_FASTA_file__0____, Path.GetFileName(fastaPath))); doc = ResultsUtil.DeserializeDocument(outPath2); Assert.IsTrue(doc.Settings.HasResults); Assert.AreEqual(1, doc.Settings.MeasuredResults.Chromatograms.Count); Assert.IsTrue(doc.Settings.MeasuredResults.ContainsChromatogram("CAexample")); Assert.AreEqual(5, doc.PeptideGroupCount); Assert.AreEqual(23, doc.PeptideCount); Assert.AreEqual(23, doc.PeptideTransitionGroupCount); Assert.AreEqual(69, doc.PeptideTransitionCount); // test setting cutoff and accepting mods when not importing a search output = RunCommand( "--import-search-cutoff-score=" + 0.99, "--import-search-add-mods"); AssertEx.Contains(output, CommandArgs.WarnArgRequirementText(CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_CUTOFF, CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_FILE)); AssertEx.Contains(output, CommandArgs.WarnArgRequirementText(CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_MODS, CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_FILE)); // MaxQuant embedding error searchFilePath = testFilesDir.GetTestPath("yeast-wiff-msms.txt"); output = RunCommand("--in=" + docPath, "--out=" + outPath2, "--import-search-file=" + searchFilePath, "--import-fasta=" + fastaPath); AssertEx.Contains(output, TextUtil.LineSeparate(Resources.CommandLine_ImportSearch_Creating_spectral_library_from_files_, Path.GetFileName(searchFilePath))); AssertEx.Contains(output, string.Format(Resources.VendorIssueHelper_ShowLibraryMissingExternalSpectraError_Could_not_find_an_external_spectrum_file_matching__0__in_the_same_directory_as_the_MaxQuant_input_file__1__, "wine yeast sampleA_2", searchFilePath)); AssertEx.Contains(output, string.Format(Resources.CommandLine_ShowLibraryMissingExternalSpectraError_DescriptionWithSupportedExtensions__0__, BiblioSpecLiteBuilder.BiblioSpecSupportedFileExtensions)); output = RunCommand("--in=" + docPath, "--out=" + outPath2, "--import-search-file=" + searchFilePath, "--import-fasta=" + fastaPath, "--import-search-prefer-embedded-spectra"); AssertEx.Contains(output, TextUtil.LineSeparate(Resources.CommandLine_ImportSearch_Creating_spectral_library_from_files_, Path.GetFileName(searchFilePath))); Assert.IsTrue(!output.Contains(string.Format(Resources.VendorIssueHelper_ShowLibraryMissingExternalSpectraError_Could_not_find_an_external_spectrum_file_matching__0__in_the_same_directory_as_the_MaxQuant_input_file__1__, "wine yeast sampleA_2", searchFilePath))); Assert.IsTrue(!output.Contains(string.Format(Resources.CommandLine_ShowLibraryMissingExternalSpectraError_DescriptionWithSupportedExtensions__0__, BiblioSpecLiteBuilder.BiblioSpecSupportedFileExtensions))); // iRTs File.Copy(testFilesDir.GetTestPath("cirts.mqpar.xml"), testFilesDir.GetTestPath("mqpar.xml"), true); searchFilePath = testFilesDir.GetTestPath("cirts.msms.txt"); // test setting num cirts and recalibrate when no irts output = RunCommand("--in=" + docPath, "--import-search-file=" + searchFilePath, "--import-search-num-cirts=10", "--import-search-recalibrate-irts"); AssertEx.Contains(output, CommandArgs.WarnArgRequirementText(CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_NUM_CIRTS, CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_IRTS), CommandArgs.WarnArgRequirementText(CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_RECALIBRATE_IRTS, CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_IRTS)); // test cirt without num cirts set output = RunCommand("--in=" + docPath, "--import-search-file=" + searchFilePath, "--import-search-irts=CiRT (iRT-C18)"); AssertEx.Contains(output, string.Format(Resources.CommandLine_ImportSearchInternal__0__must_be_set_when_using_CiRT_peptides_, CommandArgs.ARG_IMPORT_PEPTIDE_SEARCH_NUM_CIRTS.Name)); // test with irts output = RunCommand("--in=" + docPath, "--import-search-file=" + searchFilePath, "--import-search-irts=CiRT (iRT-C18)", "--import-search-num-cirts=10"); var libIrts = IrtDb.GetIrtDb(testFilesDir.GetTestPath("blank.blib"), null).StandardPeptides.ToArray(); AssertEx.AreEqual(10, libIrts.Length); foreach (var libIrt in libIrts) { AssertEx.IsTrue(IrtStandard.CIRT.Contains(libIrt)); } }