Skip to content

Commit 43362a1

Browse files
author
stefanks
committed
yahh
1 parent ed7453b commit 43362a1

File tree

9 files changed

+105
-72
lines changed

9 files changed

+105
-72
lines changed

EngineLayer/Analysis/AnalysisEngine.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,13 @@ public List<ProteinGroup> DoProteinFdr(List<ProteinGroup> proteinGroups)
532532

533533
protected override MyResults RunSpecific()
534534
{
535+
AnalysisResults myAnalysisResults = new AnalysisResults(this);
535536
Status("Running analysis engine!");
536537
//At this point have Spectrum-Sequence matching, without knowing which protein, and without know if target/decoy
537538

538539
#region Match Seqeunces to PeptideWithSetModifications
539540

541+
myAnalysisResults.AddText("Starting compactPeptideToProteinPeptideMatching count: " + compactPeptideToProteinPeptideMatching.Count);
540542
Status("Adding observed peptides to dictionary...");
541543
foreach (var psmListForAspecificSerchMode in newPsms)
542544
if (psmListForAspecificSerchMode != null)
@@ -547,6 +549,7 @@ protected override MyResults RunSpecific()
547549
if (!compactPeptideToProteinPeptideMatching.ContainsKey(cp))
548550
compactPeptideToProteinPeptideMatching.Add(cp, new HashSet<PeptideWithSetModifications>());
549551
}
552+
myAnalysisResults.AddText("Ending compactPeptideToProteinPeptideMatching count: " + compactPeptideToProteinPeptideMatching.Count);
550553
int totalProteins = proteinList.Count;
551554
int proteinsSeen = 0;
552555
int old_progress = 0;
@@ -644,7 +647,10 @@ protected override MyResults RunSpecific()
644647
allResultingIdentifications[j] = orderedPsmsWithFDR;
645648
}
646649
}
647-
return new AnalysisResults(this, allResultingIdentifications, proteinGroups);
650+
651+
myAnalysisResults.AllResultingIdentifications = allResultingIdentifications;
652+
myAnalysisResults.ProteinGroups = proteinGroups;
653+
return myAnalysisResults;
648654
}
649655

650656
#endregion Protected Methods

EngineLayer/Analysis/AnalysisResults.cs

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Linq;
34
using System.Text;
@@ -7,20 +8,25 @@ namespace EngineLayer.Analysis
78
public class AnalysisResults : MyResults
89
{
910

11+
#region Private Fields
12+
13+
private string output;
14+
15+
#endregion Private Fields
16+
1017
#region Public Constructors
1118

12-
public AnalysisResults(AnalysisEngine s, List<NewPsmWithFdr>[] allResultingIdentifications, List<ProteinGroup>[] proteinGroups) : base(s)
19+
public AnalysisResults(AnalysisEngine s) : base(s)
1320
{
14-
this.AllResultingIdentifications = allResultingIdentifications;
15-
this.ProteinGroups = proteinGroups;
21+
output = "";
1622
}
1723

1824
#endregion Public Constructors
1925

2026
#region Public Properties
2127

22-
public List<NewPsmWithFdr>[] AllResultingIdentifications { get; private set; }
23-
public List<ProteinGroup>[] ProteinGroups { get; private set; }
28+
public List<NewPsmWithFdr>[] AllResultingIdentifications { get; set; }
29+
public List<ProteinGroup>[] ProteinGroups { get; set; }
2430

2531
#endregion Public Properties
2632

@@ -29,7 +35,7 @@ public AnalysisResults(AnalysisEngine s, List<NewPsmWithFdr>[] allResultingIdent
2935
public override string ToString()
3036
{
3137
var sb = new StringBuilder();
32-
sb.AppendLine(base.ToString());
38+
sb.Append(base.ToString());
3339
sb.AppendLine("All PSMS within 1% FDR: " + string.Join(", ", AllResultingIdentifications.Select(b => b.Count(c => c.qValue <= 0.01))));
3440

3541
if (ProteinGroups != null && ProteinGroups.Any(s => s != null))
@@ -43,13 +49,23 @@ public override string ToString()
4349
numProteinsList.Add(ProteinGroups[i].Count(c => c.QValue <= 0.01));
4450
}
4551

46-
sb.Append("All proteins within 1% FDR: " + string.Join(", ", numProteinsList));
52+
sb.AppendLine("All proteins within 1% FDR: " + string.Join(", ", numProteinsList));
4753
}
54+
sb.Append(output);
4855

4956
return sb.ToString();
5057
}
5158

5259
#endregion Public Methods
5360

61+
#region Internal Methods
62+
63+
internal void AddText(string v)
64+
{
65+
output += v + Environment.NewLine;
66+
}
67+
68+
#endregion Internal Methods
69+
5470
}
5571
}

EngineLayer/MyResults.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ protected MyResults(MyEngine s)
2222
#endregion Protected Constructors
2323

2424
#region Protected Properties
25+
2526
protected MyEngine MyEngine { get; private set; }
2627

2728
#endregion Protected Properties
@@ -32,7 +33,7 @@ public override string ToString()
3233
{
3334
var sb = new StringBuilder();
3435
sb.AppendLine(GetType().Name);
35-
sb.Append("Time to run: " + Time);
36+
sb.AppendLine("Time to run: " + Time);
3637
return sb.ToString();
3738
}
3839

GUI/MainWindow.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void MyEngine_finishedSingleEngineHandler(object sender, SingleEngineFin
119119
}
120120
else
121121
{
122-
outRichTextBox.AppendText(e.ToString() + Environment.NewLine);
122+
outRichTextBox.AppendText(e.ToString());
123123
outRichTextBox.ScrollToEnd();
124124
}
125125
}

TaskLayer/CalibrationTask/CalibrationTask.cs

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ protected override MyResults RunSpecific()
134134
var searchEngine = new ClassicSearchEngine(listOfSortedms2Scans, myMsDataFile.NumSpectra, variableModifications, fixedModifications, proteinList, ProductMassTolerance, Protease, searchModes, MaxMissedCleavages, MaxModificationIsoforms, myMsDataFile.Name, lp);
135135

136136
var searchResults = (ClassicSearchResults)searchEngine.Run();
137+
myTaskResults.AddResultText(searchResults);
137138

138139
for (int i = 0; i < searchModes.Count; i++)
139140
allPsms[i].AddRange(searchResults.OuterPsms[i]);
@@ -143,6 +144,7 @@ protected override MyResults RunSpecific()
143144
var analysisEngine = new AnalysisEngine(searchResults.OuterPsms, compactPeptideToProteinPeptideMatching, proteinList, variableModifications, fixedModifications, localizeableModifications, Protease, searchModes, myMsDataFile, ProductMassTolerance, (BinTreeStructure myTreeStructure, string s) => WriteTree(myTreeStructure, OutputFolder, Path.GetFileNameWithoutExtension(origDataFileName) + s), (List<NewPsmWithFdr> h, string s) => WritePsmsToTsv(h, OutputFolder, Path.GetFileNameWithoutExtension(origDataFileName) + s), null, false, MaxMissedCleavages, MaxModificationIsoforms, false, lp, double.NaN, initiatorMethionineBehavior);
144145

145146
var analysisResults = (AnalysisResults)analysisEngine.Run();
147+
myTaskResults.AddResultText(analysisResults);
146148

147149
var identifications = analysisResults.AllResultingIdentifications[0];
148150

@@ -171,6 +173,7 @@ protected override MyResults RunSpecific()
171173
var a = new CalibrationEngine(myMsDataFileForCalibration, randomSeed, ProductMassTolerance, identifications, minMS1isotopicPeaksNeededForConfirmedIdentification, minMS2isotopicPeaksNeededForConfirmedIdentification, numFragmentsNeededForEveryIdentification, PrecursorMassTolerance, fragmentTypesForCalibration);
172174

173175
var result = a.Run();
176+
myTaskResults.AddResultText(result);
174177

175178
if (result is MyErroredResults)
176179
{

TaskLayer/GPTMDTask/GPTMDTask.cs

+10-19
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,9 @@ protected override MyResults RunSpecific()
222222
lp.Add(ProductType.Y);
223223

224224
Status("Loading proteins...");
225-
var allKnownModifications = GetDict(localizeableModifications);
226225
Dictionary<string, Modification> um = null;
227-
var proteinList = dbFilenameList.SelectMany(b => ProteinDbLoader.LoadProteinDb(b.FileName, true, allKnownModifications, b.IsContaminant, out um)).ToList();
228-
AnalysisEngine analysisEngine;
226+
var proteinList = dbFilenameList.SelectMany(b => ProteinDbLoader.LoadProteinDb(b.FileName, true, GetDict(localizeableModifications), b.IsContaminant, out um)).ToList();
227+
229228
AnalysisResults analysisResults = null;
230229
var numRawFiles = currentRawFileList.Count;
231230
for (int spectraFileIndex = 0; spectraFileIndex < numRawFiles; spectraFileIndex++)
@@ -240,38 +239,30 @@ protected override MyResults RunSpecific()
240239
Status("Opening spectra file...");
241240
myMsDataFile.Open();
242241

243-
var listOfSortedms2Scans = GetMs2Scans(myMsDataFile).OrderBy(b => b.PrecursorMass).ToArray();
244-
245-
var searchEngine = new ClassicSearchEngine(listOfSortedms2Scans, myMsDataFile.NumSpectra, variableModifications, fixedModifications, proteinList, ProductMassTolerance, Protease, searchModes, MaxMissedCleavages, MaxModificationIsoforms, myMsDataFile.Name, lp);
246-
247-
var searchResults = (ClassicSearchResults)searchEngine.Run();
242+
var searchResults = (ClassicSearchResults)new ClassicSearchEngine(GetMs2Scans(myMsDataFile).OrderBy(b => b.PrecursorMass).ToArray(), myMsDataFile.NumSpectra, variableModifications, fixedModifications, proteinList, ProductMassTolerance, Protease, searchModes, MaxMissedCleavages, MaxModificationIsoforms, myMsDataFile.Name, lp).Run();
243+
myGPTMDresults.AddResultText(searchResults);
248244

249245
allPsms[0].AddRange(searchResults.OuterPsms[0]);
250246

251-
analysisEngine = new AnalysisEngine(searchResults.OuterPsms, compactPeptideToProteinPeptideMatching, proteinList, variableModifications, fixedModifications, localizeableModifications, Protease, searchModes, myMsDataFile, ProductMassTolerance, (BinTreeStructure myTreeStructure, string s) => WriteTree(myTreeStructure, OutputFolder, Path.GetFileNameWithoutExtension(origDataFile) + s), (List<NewPsmWithFdr> h, string s) => WritePsmsToTsv(h, OutputFolder, Path.GetFileNameWithoutExtension(origDataFile) + s), null, false, MaxMissedCleavages, MaxModificationIsoforms, true, lp, binTolInDaltons, initiatorMethionineBehavior);
252-
analysisResults = (AnalysisResults)analysisEngine.Run();
253-
//output(analysisResults.ToString());
247+
analysisResults = (AnalysisResults)new AnalysisEngine(searchResults.OuterPsms, compactPeptideToProteinPeptideMatching, proteinList, variableModifications, fixedModifications, localizeableModifications, Protease, searchModes, myMsDataFile, ProductMassTolerance, (BinTreeStructure myTreeStructure, string s) => WriteTree(myTreeStructure, OutputFolder, Path.GetFileNameWithoutExtension(origDataFile) + s), (List<NewPsmWithFdr> h, string s) => WritePsmsToTsv(h, OutputFolder, Path.GetFileNameWithoutExtension(origDataFile) + s), null, false, MaxMissedCleavages, MaxModificationIsoforms, true, lp, binTolInDaltons, initiatorMethionineBehavior).Run();
248+
myGPTMDresults.AddResultText(analysisResults);
254249
}
255250

256251
if (numRawFiles > 1)
257252
{
258-
analysisEngine = new AnalysisEngine(allPsms.Select(b => b.ToArray()).ToArray(), compactPeptideToProteinPeptideMatching, proteinList, variableModifications, fixedModifications, localizeableModifications, Protease, searchModes, null, ProductMassTolerance, (BinTreeStructure myTreeStructure, string s) => WriteTree(myTreeStructure, OutputFolder, "aggregate" + s), (List<NewPsmWithFdr> h, string s) => WritePsmsToTsv(h, OutputFolder, "aggregate" + s), null, false, MaxMissedCleavages, MaxModificationIsoforms, true, lp, binTolInDaltons, initiatorMethionineBehavior);
259-
analysisResults = (AnalysisResults)analysisEngine.Run();
260-
//output(analysisResults.ToString());
253+
analysisResults = (AnalysisResults)new AnalysisEngine(allPsms.Select(b => b.ToArray()).ToArray(), compactPeptideToProteinPeptideMatching, proteinList, variableModifications, fixedModifications, localizeableModifications, Protease, searchModes, null, ProductMassTolerance, (BinTreeStructure myTreeStructure, string s) => WriteTree(myTreeStructure, OutputFolder, "aggregate" + s), (List<NewPsmWithFdr> h, string s) => WritePsmsToTsv(h, OutputFolder, "aggregate" + s), null, false, MaxMissedCleavages, MaxModificationIsoforms, true, lp, binTolInDaltons, initiatorMethionineBehavior).Run();
254+
myGPTMDresults.AddResultText(analysisResults);
261255
}
262256

263-
var gptmdEngine = new GptmdEngine(analysisResults.AllResultingIdentifications[0], IsotopeErrors, gptmdModifications, combos, PrecursorMassTolerance);
264-
var gptmdResults = (GptmdResults)gptmdEngine.Run();
265-
266-
//output(gptmdResults.ToString());
257+
var gptmdResults = (GptmdResults)new GptmdEngine(analysisResults.AllResultingIdentifications[0], IsotopeErrors, gptmdModifications, combos, PrecursorMassTolerance).Run();
258+
myGPTMDresults.AddResultText(gptmdResults);
267259

268260
string outputXMLdbFullName = Path.Combine(OutputFolder, string.Join("-", dbFilenameList.Select(b => Path.GetFileNameWithoutExtension(b.FileName))) + "GPTMD.xml");
269261

270262
WriteXmlDatabase(gptmdResults.Mods, proteinList.Where(b => !b.IsDecoy).ToList(), outputXMLdbFullName);
271263

272264
SucessfullyFinishedWritingFile(outputXMLdbFullName);
273265

274-
// TODO: Fix so not always outputting a contaminant
275266
myGPTMDresults.newDatabases.Add(new DbForTask(outputXMLdbFullName, false));
276267

277268
return myGPTMDresults;

TaskLayer/Parent/MyTaskResults.cs

+35
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using EngineLayer;
22
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
35

46
namespace TaskLayer
57
{
@@ -13,13 +15,46 @@ public abstract class MyTaskResults : MyResults
1315

1416
#endregion Public Fields
1517

18+
#region Private Fields
19+
20+
private readonly List<string> resultTexts;
21+
22+
#endregion Private Fields
23+
1624
#region Protected Constructors
1725

1826
protected MyTaskResults(MetaMorpheusTask s) : base(s)
1927
{
28+
resultTexts = new List<string>();
2029
}
2130

2231
#endregion Protected Constructors
2332

33+
#region Public Methods
34+
35+
public override string ToString()
36+
{
37+
StringBuilder sb = new StringBuilder();
38+
sb.Append(base.ToString());
39+
if (newSpectra != null && newSpectra.Any())
40+
sb.AppendLine("New spectra: " + string.Join(", ", newSpectra));
41+
if (newDatabases != null && newDatabases.Any())
42+
sb.AppendLine("New databases: " + string.Join(", ", newDatabases.Select(b => b.FileName)));
43+
foreach (var ok in resultTexts)
44+
sb.Append(ok);
45+
return sb.ToString();
46+
}
47+
48+
#endregion Public Methods
49+
50+
#region Internal Methods
51+
52+
internal void AddResultText(MyResults indexResults)
53+
{
54+
resultTexts.Add(indexResults.ToString());
55+
}
56+
57+
#endregion Internal Methods
58+
2459
}
2560
}

TaskLayer/SearchTask/MySearchTaskResults.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ public MySearchTaskResults(MetaMorpheusTask s) : base(s)
1313

1414
#endregion Public Constructors
1515

16-
#region Protected Properties
16+
#region Public Methods
1717

1818
public override string ToString()
1919
{
2020
var sb = new StringBuilder();
21-
sb.AppendLine(base.ToString());
21+
sb.Append(base.ToString());
2222
return sb.ToString();
2323
}
2424

25-
#endregion Protected Properties
25+
#endregion Public Methods
2626

2727
}
2828
}

0 commit comments

Comments
 (0)