Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions pwiz_tools/Skyline/CommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,25 +334,30 @@ private bool ProcessDocument(CommandArgs commandArgs)
return false;
}

if (commandArgs.ImportingFasta && !commandArgs.ImportingSearch)
// Because importing a FASTA or peptide list relies a lot on spectral
// libraries for transition selection, they only happen this early when
// importing a peptide search that will build a new library.
if (!commandArgs.ImportingSearch)
{
if (!HandleExceptions(commandArgs,
() => { ImportFasta(commandArgs.FastaPath, commandArgs.KeepEmptyProteins); },
Resources.CommandLine_Run_Error__Failed_importing_the_file__0____1_,
commandArgs.FastaPath, true))
if (commandArgs.ImportingFasta)
{
return false;
if (!HandleExceptions(commandArgs,
() => { ImportFasta(commandArgs.FastaPath, commandArgs.KeepEmptyProteins); },
Resources.CommandLine_Run_Error__Failed_importing_the_file__0____1_,
commandArgs.FastaPath, true))
{
return false;
}
}
}

if (commandArgs.ImportingPeptideList)
{
if (!HandleExceptions(commandArgs,
() => { ImportPeptideList(commandArgs.PeptideListName, commandArgs.PeptideListPath); },
Resources.CommandLine_Run_Error__Failed_importing_the_file__0____1_,
commandArgs.PeptideListPath, true))
if (commandArgs.ImportingPeptideList)
{
return false;
if (!HandleExceptions(commandArgs,
() => { ImportPeptideList(commandArgs.PeptideListName, commandArgs.PeptideListPath); },
Resources.CommandLine_Run_Error__Failed_importing_the_file__0____1_,
commandArgs.PeptideListPath, true))
{
return false;
}
}
}

Expand All @@ -377,6 +382,17 @@ private bool ProcessDocument(CommandArgs commandArgs)
{
if (!ImportSearch(commandArgs))
return false;

if (commandArgs.ImportingPeptideList)
{
if (!HandleExceptions(commandArgs,
() => { ImportPeptideList(commandArgs.PeptideListName, commandArgs.PeptideListPath); },
Resources.CommandLine_Run_Error__Failed_importing_the_file__0____1_,
commandArgs.PeptideListPath, true))
{
return false;
}
}
}

if (commandArgs.AssociatingProteins)
Expand Down
35 changes: 31 additions & 4 deletions pwiz_tools/Skyline/TestData/CommandLineImportTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,37 @@ public void ConsoleImportPeptideSearchTest()
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);
AssertEx.IsDocumentState(doc, null, 5, 26, 78);
Assert.IsTrue(doc.PeptideGroups.All(nodePepGroup => nodePepGroup.IsProtein));

// Repeat this with a peptide list, expecting the same numbers but peptide lists
// instead of proteins
var pepListPath = TestFilesDir.GetTestPath("bov-5-peplist.txt");
var outListPath = TestFilesDir.GetTestPath("import-search-list.sky");
WritePeptideList(pepListPath, doc, true);
var listArgs = args.ToList();
listArgs[1] = "--out=" + outListPath;
listArgs[listArgs.Count - 1] = "--import-pep-list=" + pepListPath;

output = RunCommand(listArgs.ToArray());

string lineLibrary = TextUtil.LineSeparate(Resources.CommandLine_ImportSearch_Creating_spectral_library_from_files_,
Path.GetFileName(searchFilePath));
string lineList = string.Format(Resources.CommandLine_ImportPeptideList_Importing_peptide_lists_from_file__0____,
Path.GetFileName(pepListPath));
AssertEx.Contains(output, lineLibrary);
AssertEx.Contains(output, lineList);
Assert.IsTrue(output.IndexOf(lineLibrary, StringComparison.Ordinal) < output.IndexOf(lineList, StringComparison.Ordinal),
TextUtil.LineSeparate("Library building appears after peptide list import in the output:", output));
AssertEx.Contains(output, string.Format(Resources.CommandLine_ImportSearch_Adding__0__modifications_, 2));

var docList = ResultsUtil.DeserializeDocument(outListPath);
Assert.IsTrue(docList.Settings.HasResults);
Assert.AreEqual(1, docList.Settings.MeasuredResults.Chromatograms.Count);
Assert.IsTrue(docList.Settings.MeasuredResults.ContainsChromatogram("CAexample"));
AssertEx.IsDocumentState(docList, null, 5, 26, 78);
Assert.IsTrue(docList.PeptideGroups.All(nodePepGroup => nodePepGroup.IsPeptideList));
Assert.IsTrue(docList.PeptideTransitionGroups.All(nodeGroup => nodeGroup.HasLibInfo));

// without mods
var outPath2 = TestFilesDir.GetTestPath("import-search2.sky");
Expand Down