Skip to content

Commit e56b7ee

Browse files
author
stefanks
authored
Merge pull request #164 from smith-chem-wisc/StefanBranch
Stefan branch
2 parents f710e05 + bc871b8 commit e56b7ee

23 files changed

+212
-146
lines changed

InternalLogic/ClassicSearchEngine.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected override MyResults RunSpecific()
7373
var lp = new List<ProductType> { ProductType.B, ProductType.Y };
7474

7575
Status("Getting ms2 scans...");
76-
76+
7777
var outerPsms = new ClassicSpectrumMatch[searchModes.Count][];
7878
for (int aede = 0; aede < searchModes.Count; aede++)
7979
outerPsms[aede] = new ClassicSpectrumMatch[myMsDataFileNumSpectra];

InternalLogic/ModernSearchEngine.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ protected override MyResults RunSpecific()
5252
for (int i = 0; i < searchModes.Count; i++)
5353
newPsms[i] = new List<ModernSpectrumMatch>(new ModernSpectrumMatch[totalSpectra]);
5454

55-
var listOfSortedms2Scans = myMSDataFile.Where(b => b.MsnOrder == 2).Select(b => new LocalMS2Scan(b)).OrderBy(b => b.PrecursorMass).ToArray();
55+
LocalMS2Scan[] listOfSortedms2Scans = GetMs2Scans(myMSDataFile).OrderBy(b => b.PrecursorMass).ToArray();
56+
5657
var listOfSortedms2ScansLength = listOfSortedms2Scans.Length;
5758
var searchModesCount = searchModes.Count;
5859
var outputObject = new object();

InternalLogic/MyEngine.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Proteomics;
1+
using MassSpectrometry;
2+
using Proteomics;
3+
using Spectra;
24
using System;
35
using System.Collections.Generic;
46
using System.Diagnostics;
@@ -68,12 +70,25 @@ protected MyEngine(int Level)
6870

6971
public static string MetaMorpheusVersion { get; private set; }
7072
public static UsefulProteomicsDatabases.Generated.unimod unimodDeserialized { get; private set; }
73+
7174
public static Dictionary<int, ChemicalFormulaModification> uniprotDeseralized { get; private set; }
7275

7376
#endregion Public Properties
7477

7578
#region Public Methods
7679

80+
public static IEnumerable<LocalMS2Scan> GetMs2Scans(IMsDataFile<IMzSpectrum<MzPeak>> myMSDataFile)
81+
{
82+
foreach (var heh in myMSDataFile)
83+
{
84+
int chargeState = 0;
85+
if (heh.TryGetSelectedIonGuessChargeStateGuess(out chargeState) && chargeState > 0)
86+
{
87+
yield return new LocalMS2Scan(heh);
88+
}
89+
}
90+
}
91+
7792
public MyResults Run()
7893
{
7994
startingSingleEngine();

InternalLogic/SearchModes/DotSearchMode.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Spectra;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
45

56
namespace InternalLogicEngineLayer
@@ -16,6 +17,12 @@ public class DotSearchMode : SearchMode
1617

1718
#region Public Constructors
1819

20+
public DotSearchMode(IEnumerable<double> acceptableSortedMassShifts, Tolerance tol) : base(tol.ToString() + "around" + string.Join("|", acceptableSortedMassShifts.Select(b => b.ToString("F3", CultureInfo.InvariantCulture))))
21+
{
22+
this.acceptableSortedMassShifts = acceptableSortedMassShifts.ToList();
23+
this.tol = tol;
24+
}
25+
1926
public DotSearchMode(string FileNameAddition, IEnumerable<double> acceptableSortedMassShifts, Tolerance tol) : base(FileNameAddition)
2027
{
2128
this.acceptableSortedMassShifts = acceptableSortedMassShifts.ToList();
@@ -45,11 +52,6 @@ public override IEnumerable<DoubleRange> GetAllowedPrecursorMassIntervals(double
4552
}
4653
}
4754

48-
public override string SearchModeString()
49-
{
50-
return "Tolerance of " + tol + " around mass diffs: " + string.Join(",", acceptableSortedMassShifts);
51-
}
52-
5355
#endregion Public Methods
5456

5557
}

InternalLogic/SearchModes/IntervalSearchMode.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Spectra;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
45

56
namespace InternalLogicEngineLayer
@@ -20,6 +21,11 @@ public IntervalSearchMode(string fileNameAddition, IEnumerable<DoubleRange> doub
2021
intervals = doubleRanges.ToList();
2122
}
2223

24+
public IntervalSearchMode(IEnumerable<DoubleRange> doubleRanges) : base("intervals" + string.Join("", doubleRanges.Select(b => "[" + b.Minimum.ToString("F3", CultureInfo.InvariantCulture) + "-" + b.Maximum.ToString("F3", CultureInfo.InvariantCulture) + "]")))
25+
{
26+
intervals = doubleRanges.ToList();
27+
}
28+
2329
#endregion Public Constructors
2430

2531
#region Public Methods
@@ -39,11 +45,6 @@ public override IEnumerable<DoubleRange> GetAllowedPrecursorMassIntervals(double
3945
return intervals.Select(b => new DoubleRange(peptideMonoisotopicMass + b.Minimum, peptideMonoisotopicMass + b.Maximum));
4046
}
4147

42-
public override string SearchModeString()
43-
{
44-
return "Intervals allowed: " + string.Join(",", intervals);
45-
}
46-
4748
#endregion Public Methods
4849

4950
}

InternalLogic/SearchModes/OpenSearchMode.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class OpenSearchMode : SearchMode
88

99
#region Public Constructors
1010

11-
public OpenSearchMode(string s) : base(s)
11+
public OpenSearchMode() : base("OpenSearch")
1212
{
1313
}
1414

@@ -26,11 +26,6 @@ public override IEnumerable<DoubleRange> GetAllowedPrecursorMassIntervals(double
2626
yield return new DoubleRange(double.MinValue, double.MaxValue);
2727
}
2828

29-
public override string SearchModeString()
30-
{
31-
return "OpenSearch";
32-
}
33-
3429
#endregion Public Methods
3530

3631
}

InternalLogic/SearchModes/SearchMode.cs

+1-8
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,16 @@ protected SearchMode(string fileNameAddition)
1717

1818
#region Public Properties
1919

20-
public string FileNameAddition { get; internal set; }
20+
public string FileNameAddition { get; private set; }
2121

2222
#endregion Public Properties
2323

2424
#region Public Methods
2525

2626
public abstract bool Accepts(double scanPrecursorMass, double peptideMass);
2727

28-
public override string ToString()
29-
{
30-
return FileNameAddition + ": " + SearchModeString();
31-
}
32-
3328
public abstract IEnumerable<DoubleRange> GetAllowedPrecursorMassIntervals(double peptideMonoisotopicMass);
3429

35-
public abstract string SearchModeString();
36-
3730
#endregion Public Methods
3831

3932
}

InternalLogic/SearchModes/SingleAbsoluteAroundZeroSearchMode.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class SingleAbsoluteAroundZeroSearchMode : SearchMode
1515

1616
#region Public Constructors
1717

18-
public SingleAbsoluteAroundZeroSearchMode(string v, double value) : base(v)
18+
public SingleAbsoluteAroundZeroSearchMode(double value) : base(value + "daltonsAroundZero")
1919
{
2020
this.value = value;
2121
}
@@ -34,11 +34,6 @@ public override IEnumerable<DoubleRange> GetAllowedPrecursorMassIntervals(double
3434
yield return new DoubleRange(peptideMonoisotopicMass - value, peptideMonoisotopicMass + value);
3535
}
3636

37-
public override string SearchModeString()
38-
{
39-
return "SingleAbsoluteAroundZeroSearchMode" + value;
40-
}
41-
4237
#endregion Public Methods
4338

4439
}

InternalLogic/SearchModes/SinglePpmAroundZeroSearchMode.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class SinglePpmAroundZeroSearchMode : SearchMode
1515

1616
#region Public Constructors
1717

18-
public SinglePpmAroundZeroSearchMode(string v1, double ppmTolerance) : base(v1)
18+
public SinglePpmAroundZeroSearchMode(double ppmTolerance) : base(ppmTolerance + "ppmAroundZero")
1919
{
2020
this.ppmTolerance = ppmTolerance;
2121
}
@@ -35,11 +35,6 @@ public override IEnumerable<DoubleRange> GetAllowedPrecursorMassIntervals(double
3535
yield return new DoubleRange(peptideMonoisotopicMass - diff, peptideMonoisotopicMass + diff);
3636
}
3737

38-
public override string SearchModeString()
39-
{
40-
return "SinglePpmAroundZeroSearchMode" + ppmTolerance;
41-
}
42-
4338
#endregion Public Methods
4439

4540
}

InternalLogicWithFileIO/CalibrationTask/CalibrationTask.cs

+10-8
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ protected override MyResults RunSpecific()
7777
myTaskResults.newSpectra = new List<string>();
7878
var currentRawFileList = rawDataFilenameList;
7979

80-
var compactPeptideToProteinPeptideMatching = new Dictionary<CompactPeptide, HashSet<PeptideWithSetModifications>>();
81-
8280
SearchMode searchMode;
83-
searchMode = new SingleAbsoluteAroundZeroSearchMode("", PrecursorMassToleranceInDaltons);
81+
searchMode = new SingleAbsoluteAroundZeroSearchMode(PrecursorMassToleranceInDaltons);
8482
var searchModes = new List<SearchMode> { searchMode };
8583

8684
List<ParentSpectrumMatch>[] allPsms = new List<ParentSpectrumMatch>[1];
@@ -99,19 +97,21 @@ protected override MyResults RunSpecific()
9997

10098
Parallel.For(0, currentRawFileList.Count, spectraFileIndex =>
10199
{
100+
var compactPeptideToProteinPeptideMatching = new Dictionary<CompactPeptide, HashSet<PeptideWithSetModifications>>();
102101
var origDataFileName = currentRawFileList[spectraFileIndex];
103102
LocalMS2Scan[] listOfSortedms2Scans;
104103
IMsDataFile<IMzSpectrum<MzPeak>> myMsDataFile;
105104
lock (myTaskResults)
106105
{
106+
StartingDataFile(origDataFileName);
107107
Status("Loading spectra file " + origDataFileName + "...");
108108
if (Path.GetExtension(origDataFileName).Equals(".mzML"))
109109
myMsDataFile = new Mzml(origDataFileName, MaxNumPeaksPerScan);
110110
else
111111
myMsDataFile = new ThermoRawFile(origDataFileName, MaxNumPeaksPerScan);
112112
Status("Opening spectra file " + origDataFileName + "...");
113113
myMsDataFile.Open();
114-
listOfSortedms2Scans = myMsDataFile.Where(b => b.MsnOrder == 2).Select(b => new LocalMS2Scan(b)).OrderBy(b => b.PrecursorMass).ToArray();
114+
listOfSortedms2Scans = GetMs2Scans(myMsDataFile).OrderBy(b => b.PrecursorMass).ToArray();
115115
}
116116

117117
var searchEngine = new ClassicSearchEngine(listOfSortedms2Scans, myMsDataFile.NumSpectra, variableModifications, fixedModifications, proteinList, new Tolerance(ToleranceUnit.Absolute, ProductMassToleranceInDaltons), Protease, searchModes, MaxMissedCleavages, MaxModificationIsoforms, myMsDataFile.Name);
@@ -121,8 +121,6 @@ protected override MyResults RunSpecific()
121121
for (int i = 0; i < searchModes.Count; i++)
122122
allPsms[i].AddRange(searchResults.OuterPsms[i]);
123123

124-
lock (myTaskResults)
125-
{
126124
// Run analysis on single file results
127125
var analysisEngine = new AnalysisEngine(searchResults.OuterPsms, compactPeptideToProteinPeptideMatching, proteinList, variableModifications, fixedModifications, localizeableModifications, Protease, searchModes, myMsDataFile, new Tolerance(ToleranceUnit.Absolute, ProductMassToleranceInDaltons), (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);
128126

@@ -158,12 +156,16 @@ protected override MyResults RunSpecific()
158156

159157
Status("Creating _indexedmzMLConnection, putting data in it, and writing!");
160158
var path = Path.Combine(OutputFolder, Path.GetFileNameWithoutExtension(origDataFileName) + "-Calibrated.mzML");
161-
MzmlMethods.CreateAndWriteMyIndexedMZmlwithCalibratedSpectra(result.MyMSDataFile, path);
159+
lock (myTaskResults)
160+
{
161+
MzmlMethods.CreateAndWriteMyIndexedMZmlwithCalibratedSpectra(result.MyMSDataFile, path);
162162

163-
SucessfullyFinishedWritingFile(path);
163+
SucessfullyFinishedWritingFile(path);
164164

165165
myTaskResults.newSpectra.Add(path);
166166
}
167+
168+
FinishedDataFile(origDataFileName);
167169
}
168170
);
169171
return myTaskResults;

InternalLogicWithFileIO/GPTMDTask/GPTMDTask.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ protected override MyResults RunSpecific()
211211
Status("Opening spectra file...");
212212
myMsDataFile.Open();
213213

214-
var listOfSortedms2Scans = myMsDataFile.Where(b => b.MsnOrder == 2).Select(b => new LocalMS2Scan(b)).OrderBy(b => b.PrecursorMass).ToArray();
214+
var listOfSortedms2Scans = GetMs2Scans(myMsDataFile).OrderBy(b => b.PrecursorMass).ToArray();
215215

216216
var searchEngine = new ClassicSearchEngine(listOfSortedms2Scans, myMsDataFile.NumSpectra, variableModifications, fixedModifications, proteinList, ProductMassTolerance, Protease, searchModes, MaxMissedCleavages, MaxModificationIsoforms, myMsDataFile.Name);
217217

InternalLogicWithFileIO/Parent/MyTaskEngine.cs

+14
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ protected MyTaskEngine() : base(1)
4545

4646
public static event EventHandler<SingleTaskEventArgs> StartingSingleTaskHander;
4747

48+
public static event EventHandler<StringEventArgs> StartingDataFileHandler;
49+
50+
public static event EventHandler<StringEventArgs> FinishedDataFileHandler;
51+
4852
#endregion Public Events
4953

5054
#region Public Properties
@@ -408,6 +412,16 @@ protected void SucessfullyFinishedWritingFile(string path)
408412
FinishedWritingFileHandler?.Invoke(this, new SingleFileEventArgs(path));
409413
}
410414

415+
protected void StartingDataFile(string v)
416+
{
417+
StartingDataFileHandler?.Invoke(this, new StringEventArgs(v));
418+
}
419+
420+
protected void FinishedDataFile(string v)
421+
{
422+
FinishedDataFileHandler?.Invoke(this, new StringEventArgs(v));
423+
}
424+
411425
#endregion Protected Methods
412426

413427
#region Private Methods

InternalLogicWithFileIO/SearchTask/SearchTask.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public SearchTask(IEnumerable<ModList> modList, IEnumerable<SearchMode> inputSea
2424
ClassicSearch = true;
2525
DoParsimony = false;
2626
SearchDecoy = true;
27-
DoHistogramAnalysis = true;
27+
DoHistogramAnalysis = false;
2828
MaxMissedCleavages = 2;
2929
Protease = ProteaseDictionary.Instance["trypsin (no proline rule)"];
3030
MaxModificationIsoforms = 4096;
@@ -184,8 +184,7 @@ protected override MyResults RunSpecific()
184184

185185
if (ClassicSearch)
186186
{
187-
var listOfSortedms2Scans = myMsDataFile.Where(b => b.MsnOrder == 2).Select(b => new LocalMS2Scan(b)).OrderBy(b => b.PrecursorMass).ToArray();
188-
187+
var listOfSortedms2Scans = GetMs2Scans(myMsDataFile).OrderBy(b => b.PrecursorMass).ToArray();
189188
classicSearchEngine = new ClassicSearchEngine(listOfSortedms2Scans, myMsDataFile.NumSpectra, variableModifications, fixedModifications, proteinList, ProductMassTolerance, Protease, searchModesS, MaxMissedCleavages, MaxModificationIsoforms, myMsDataFile.Name);
190189

191190
classicSearchResults = (ClassicSearchResults)classicSearchEngine.Run();

MetaMorpheusCommandLine/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private static void RunModernSearchEngine()
7474
IMsDataFile<IMzSpectrum<MzPeak>> myMsDataFile = new Mzml(@"C:\Users\stepa\Data\CalibrationPaperData\Step2\Mouse\Calib-0.1.2\04-29-13_B6_Frac9_9p5uL-Calibrated.mzML", 400);
7575
myMsDataFile.Open();
7676
double fragmentToleranceInDaltons = 0.01;
77-
var searchModes = new List<SearchMode> { new SinglePpmAroundZeroSearchMode("", 5) };
77+
var searchModes = new List<SearchMode> { new SinglePpmAroundZeroSearchMode(5) };
7878

7979
var s = new ModernSearchEngine(myMsDataFile, peptideIndex, keys, fragmentIndex, fragmentToleranceInDaltons, searchModes);
8080
s.Run();
@@ -83,7 +83,7 @@ private static void RunModernSearchEngine()
8383
private static void RunSearchTask()
8484
{
8585
IEnumerable<ModList> modList = new List<ModList> { new ModList("f.txt"), new ModList("v.txt"), new ModList("p.txt") };
86-
IEnumerable<SearchMode> ism = new List<SearchMode> { new SinglePpmAroundZeroSearchMode("", 5) };
86+
IEnumerable<SearchMode> ism = new List<SearchMode> { new SinglePpmAroundZeroSearchMode(5) };
8787
var s = new SearchTask(modList, ism);
8888

8989
s.ClassicSearch = false;

MetaMorpheusGUI/ForDisplayingInDataGrids/RawData.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
public class RawData
44
{
5+
56
#region Public Constructors
67

78
public RawData(string FileName)
@@ -17,17 +18,18 @@ public RawData(string FileName)
1718

1819
public bool Use { get; set; }
1920
public string FileName { get; private set; }
21+
public bool InProgress { get; private set; }
2022

2123
#endregion Public Properties
2224

2325
#region Public Methods
2426

25-
public void AddFilePath(string fileName)
27+
public void SetInProgress(bool inProgress)
2628
{
27-
this.FileName = fileName;
28-
Use = true;
29+
InProgress = inProgress;
2930
}
3031

3132
#endregion Public Methods
33+
3234
}
3335
}

0 commit comments

Comments
 (0)