Skip to content

Commit 2c2e8e8

Browse files
author
stefanks
authored
Merge pull request #189 from smith-chem-wisc/StefanBranch
move stuff
2 parents 34a8185 + 3ef07bc commit 2c2e8e8

38 files changed

+161
-115
lines changed

EngineLayer/Analysis/AnalysisEngine.cs

+1-11
Original file line numberDiff line numberDiff line change
@@ -668,15 +668,7 @@ private static void OverlappingIonSequences(BinTreeStructure myTreeStructure)
668668
}
669669
}
670670
}
671-
672-
private static void IdentifyPsmsWithMaxMods(BinTreeStructure myTreeStructure)
673-
{
674-
foreach (Bin bin in myTreeStructure.FinalBins)
675-
{
676-
bin.FracWithMaxMods = ((double)bin.uniquePSMs.Values.Count(b => !b.Item3.IsDecoy && b.Item3.thisPSM.NumVariableMods == max_mods_for_peptide)) / bin.CountTarget;
677-
}
678-
}
679-
671+
680672
private static void IdentifyFracWithSingle(BinTreeStructure myTreeStructure)
681673
{
682674
foreach (Bin bin in myTreeStructure.FinalBins)
@@ -926,8 +918,6 @@ private static BinTreeStructure MyAnalysis(List<NewPsmWithFdr> limitedpsms_with_
926918

927919
IdentifyMine(myTreeStructure, binTol);
928920

929-
IdentifyPsmsWithMaxMods(myTreeStructure);
930-
931921
OverlappingIonSequences(myTreeStructure);
932922

933923
IdentifyFracWithSingle(myTreeStructure);

EngineLayer/Analysis/Bin.cs

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public int LocalizeableTarget
7171

7272
public string Mine { get; internal set; }
7373
public Dictionary<char, int> AAsInCommon { get; internal set; }
74-
public double FracWithMaxMods { get; internal set; }
7574
public int Overlapping { get; internal set; }
7675
public double FracWithSingle { get; set; }
7776

EngineLayer/CalibrationEngine/CalibrationEngine.cs

+11-10
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class CalibrationEngine : MyEngine
2121
private readonly int minMS1isotopicPeaksNeededForConfirmedIdentification;
2222
private readonly int minMS2isotopicPeaksNeededForConfirmedIdentification;
2323
private readonly int numFragmentsNeededForEveryIdentification;
24-
private readonly double toleranceInMZforMS1Search;
25-
private readonly double toleranceInMZforMS2Search;
24+
private readonly Tolerance mzToleranceForMs1Search;
25+
private readonly Tolerance mzToleranceForMs2Search;
2626
private readonly int randomSeed;
2727
private readonly FragmentTypes fragmentTypesForCalibration;
2828
private List<NewPsmWithFdr> identifications;
@@ -32,16 +32,16 @@ public class CalibrationEngine : MyEngine
3232

3333
#region Public Constructors
3434

35-
public CalibrationEngine(IMsDataFile<IMzSpectrum<MzPeak>> myMSDataFile, int randomSeed, double toleranceInMZforMS2Search, List<NewPsmWithFdr> identifications, int minMS1IsotopicPeaksNeededForConfirmedIdentification, int minMS2IsotopicPeaksNeededForConfirmedIdentification, int numFragmentsNeededForEveryIdentification, double toleranceInMZforMS1Search, FragmentTypes fragmentTypesForCalibration) : base(2)
35+
public CalibrationEngine(IMsDataFile<IMzSpectrum<MzPeak>> myMSDataFile, int randomSeed, Tolerance mzToleranceForMs2Search, List<NewPsmWithFdr> identifications, int minMS1IsotopicPeaksNeededForConfirmedIdentification, int minMS2IsotopicPeaksNeededForConfirmedIdentification, int numFragmentsNeededForEveryIdentification, Tolerance mzToleranceForMS1Search, FragmentTypes fragmentTypesForCalibration) : base(2)
3636
{
3737
this.myMsDataFile = myMSDataFile;
3838
this.randomSeed = randomSeed;
39-
this.toleranceInMZforMS2Search = toleranceInMZforMS2Search;
4039
this.identifications = identifications;
4140
this.minMS1isotopicPeaksNeededForConfirmedIdentification = minMS1IsotopicPeaksNeededForConfirmedIdentification;
4241
this.minMS2isotopicPeaksNeededForConfirmedIdentification = minMS2IsotopicPeaksNeededForConfirmedIdentification;
4342
this.numFragmentsNeededForEveryIdentification = numFragmentsNeededForEveryIdentification;
44-
this.toleranceInMZforMS1Search = toleranceInMZforMS1Search;
43+
this.mzToleranceForMs1Search = mzToleranceForMS1Search;
44+
this.mzToleranceForMs2Search = mzToleranceForMs2Search;
4545
this.fragmentTypesForCalibration = fragmentTypesForCalibration;
4646
}
4747

@@ -377,7 +377,7 @@ private int SearchMS1Spectra(double[] originalMasses, double[] originalIntensiti
377377
{
378378
double theMZ = a.ToMassToChargeRatio(chargeToLookAt);
379379

380-
var npwr = fullMS1spectrum.NumPeaksWithinRange(theMZ - toleranceInMZforMS1Search, theMZ + toleranceInMZforMS1Search);
380+
var npwr = fullMS1spectrum.NumPeaksWithinRange(mzToleranceForMs1Search.GetMinimumValue(theMZ), mzToleranceForMs1Search.GetMaximumValue(theMZ));
381381
if (npwr == 0)
382382
{
383383
break;
@@ -421,7 +421,7 @@ private int SearchMS1Spectra(double[] originalMasses, double[] originalIntensiti
421421
{
422422
addedAscan = true;
423423
startingToAddCharges = true;
424-
countForThisScan += 1;
424+
countForThisScan++;
425425
double[] inputs = { -1, trainingPointsToAverage.Select(b => b.inputs[0]).Average(), fullMS1scan.RetentionTime, trainingPointsToAverage.Select(b => b.inputs[1]).Average(), fullMS1scan.TotalIonCurrent, fullMS1scan.InjectionTime };
426426
var a = new LabeledDataPoint(inputs, trainingPointsToAverage.Select(b => b.output).Median());
427427

@@ -475,7 +475,8 @@ private List<LabeledDataPoint> SearchMS2Spectrum(IMsDataScan<IMzSpectrum<MzPeak>
475475
if (monoisotopicMZ < scanWindowRange.Minimum)
476476
break;
477477
var closestPeakMZ = ms2DataScan.MassSpectrum.GetClosestPeakXvalue(monoisotopicMZ);
478-
if (Math.Abs(closestPeakMZ - monoisotopicMZ) < toleranceInMZforMS2Search)
478+
479+
if (mzToleranceForMs2Search.Within(closestPeakMZ, monoisotopicMZ))
479480
{
480481
if (!computedIsotopologues)
481482
{
@@ -513,7 +514,7 @@ private List<LabeledDataPoint> SearchMS2Spectrum(IMsDataScan<IMzSpectrum<MzPeak>
513514
foreach (double a in masses)
514515
{
515516
double theMZ = a.ToMassToChargeRatio(chargeToLookAt);
516-
var npwr = ms2DataScan.MassSpectrum.NumPeaksWithinRange(theMZ - toleranceInMZforMS2Search, theMZ + toleranceInMZforMS2Search);
517+
var npwr = ms2DataScan.MassSpectrum.NumPeaksWithinRange(mzToleranceForMs2Search.GetMinimumValue(theMZ), mzToleranceForMs2Search.GetMaximumValue(theMZ));
517518
if (npwr == 0)
518519
{
519520
break;
@@ -548,7 +549,7 @@ private List<LabeledDataPoint> SearchMS2Spectrum(IMsDataScan<IMzSpectrum<MzPeak>
548549
}
549550

550551
countForThisMS2 += trainingPointsToAverage.Count;
551-
countForThisMS2a += 1;
552+
countForThisMS2a++;
552553

553554
double addedMZ = trainingPointsToAverage.Select(b => b.inputs[0]).Average();
554555
double relativeMZ = (addedMZ - ms2DataScan.ScanWindowRange.Minimum) / (ms2DataScan.ScanWindowRange.Maximum - ms2DataScan.ScanWindowRange.Minimum);

EngineLayer/ClassicSearch/PsmClassic.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ private static bool FirstIsPreferableWithoutScore(PeptideWithSetModifications fi
6666
return true;
6767
if (Math.Abs(first.MonoisotopicMass - pm) > tolInDaForPreferringHavingMods && Math.Abs(second.MonoisotopicMass - pm) < tolInDaForPreferringHavingMods)
6868
return false;
69-
70-
if (first.NumVariableMods < second.NumVariableMods)
69+
if (first.NumMods < second.NumMods)
7170
return true;
7271

7372
return false;

EngineLayer/Data/f.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Fixed modifications
2-
ID Carbamidomethylation of C anywhere
2+
ID Carbamidomethyl
33
FT MOD_RES
44
TG Cysteine
55
PP Anywhere.

EngineLayer/Data/glyco.txt

+24
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,28 @@ PP Anywhere.
7070
FM 0
7171
MM 146.057909
7272
CF C6 H10 O4
73+
//
74+
ID HexNAc2
75+
FT MOD_RES
76+
TG Asparagine
77+
PP Anywhere.
78+
FM 0
79+
MM 406.158745
80+
CF C16 O10 N2 H26
81+
//
82+
ID HexNAc2
83+
FT MOD_RES
84+
TG Serine
85+
PP Anywhere.
86+
FM 0
87+
MM 406.158745
88+
CF C16 O10 N2 H26
89+
//
90+
ID HexNAc2
91+
FT MOD_RES
92+
TG Threonine
93+
PP Anywhere.
94+
FM 0
95+
MM 406.158745
96+
CF C16 O10 N2 H26
7397
//

EngineLayer/Data/v.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Variable Modifications
2-
ID Oxidation of M anywhere
2+
ID Oxidation
33
FT MOD_RES
44
TG Methionine
55
PP Anywhere.

EngineLayer/EngineLayer.csproj

+13-13
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,19 @@
102102
<Compile Include="ClassicSearch\ClassicSearchEngine.cs" />
103103
<Compile Include="ClassicSearch\ClassicSearchResults.cs" />
104104
<Compile Include="ClassicSearch\PsmClassic.cs" />
105-
<Compile Include="CleavageSpecificity.cs" />
106-
<Compile Include="CompactPeptide.cs" />
107-
<Compile Include="InitiatorMethionineBehavior.cs" />
108-
<Compile Include="ModificationType.cs" />
109-
<Compile Include="MetaMorpheusModification.cs" />
110-
<Compile Include="OldLogicTerminus.cs" />
111-
<Compile Include="Peptide.cs" />
112-
<Compile Include="PeptideWithPossibleModifications.cs" />
113-
<Compile Include="PeptideWithSetModifications.cs" />
114-
<Compile Include="ProductType.cs" />
115-
<Compile Include="Protease.cs" />
116-
<Compile Include="ProteaseDictionary.cs" />
117-
<Compile Include="Protein.cs" />
105+
<Compile Include="Proteomics\CleavageSpecificity.cs" />
106+
<Compile Include="Proteomics\CompactPeptide.cs" />
107+
<Compile Include="Proteomics\InitiatorMethionineBehavior.cs" />
108+
<Compile Include="Proteomics\ModificationType.cs" />
109+
<Compile Include="Proteomics\MetaMorpheusModification.cs" />
110+
<Compile Include="Proteomics\TerminusType.cs" />
111+
<Compile Include="Proteomics\Peptide.cs" />
112+
<Compile Include="Proteomics\PeptideWithPossibleModifications.cs" />
113+
<Compile Include="Proteomics\PeptideWithSetModifications.cs" />
114+
<Compile Include="Proteomics\ProductType.cs" />
115+
<Compile Include="Proteomics\Protease.cs" />
116+
<Compile Include="Proteomics\ProteaseDictionary.cs" />
117+
<Compile Include="Proteomics\Protein.cs" />
118118
<Compile Include="SearchModes\DotSearchMode.cs" />
119119
<Compile Include="Gptmd\GptmdEngine.cs" />
120120
<Compile Include="Gptmd\GptmdResults.cs" />

EngineLayer/Gptmd/GptmdEngine.cs

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Spectra;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45

@@ -9,23 +10,24 @@ public class GptmdEngine : MyEngine
910

1011
#region Private Fields
1112

13+
private const double missedMonoisopePeak = 1.003;
1214
private readonly List<NewPsmWithFdr> allResultingIdentifications;
1315
private readonly IEnumerable<Tuple<double, double>> combos;
1416
private readonly List<MetaMorpheusModification> gptmdModifications;
1517
private readonly bool isotopeErrors;
16-
private readonly double tolInDaltons;
18+
private readonly Tolerance precursorMassTolerance;
1719

1820
#endregion Private Fields
1921

2022
#region Public Constructors
2123

22-
public GptmdEngine(List<NewPsmWithFdr> allResultingIdentifications, bool isotopeErrors, List<MetaMorpheusModification> gptmdModifications, IEnumerable<Tuple<double, double>> combos, double tolInDaltons) : base(2)
24+
public GptmdEngine(List<NewPsmWithFdr> allResultingIdentifications, bool isotopeErrors, List<MetaMorpheusModification> gptmdModifications, IEnumerable<Tuple<double, double>> combos, Tolerance precursorMassTolerance) : base(2)
2325
{
2426
this.allResultingIdentifications = allResultingIdentifications;
2527
this.isotopeErrors = isotopeErrors;
2628
this.gptmdModifications = gptmdModifications;
2729
this.combos = combos;
28-
this.tolInDaltons = tolInDaltons;
30+
this.precursorMassTolerance = precursorMassTolerance;
2931
}
3032

3133
#endregion Public Constructors
@@ -46,7 +48,7 @@ protected override MyResults RunSpecific()
4648
var peptide = theDict.First();
4749
var baseSequence = ye.thisPSM.BaseSequence;
4850
double massDiff = ye.thisPSM.ScanPrecursorMass - ye.thisPSM.PeptideMonoisotopicMass;
49-
foreach (MetaMorpheusModification mod in GetMod(massDiff, isotopeErrors, gptmdModifications, combos, tolInDaltons))
51+
foreach (MetaMorpheusModification mod in GetMod(massDiff, isotopeErrors, gptmdModifications, combos, precursorMassTolerance))
5052
{
5153
int proteinLength = peptide.Protein.Length;
5254
var proteinAcession = peptide.Protein.Accession;
@@ -94,13 +96,13 @@ private static bool ModFits(MetaMorpheusModification attemptToLocalize, char v1,
9496
return true;
9597
}
9698

97-
private static IEnumerable<MetaMorpheusModification> GetMod(double massDiff, bool isotopeErrors, IEnumerable<MetaMorpheusModification> allMods, IEnumerable<Tuple<double, double>> combos, double tolInDaltons)
99+
private static IEnumerable<MetaMorpheusModification> GetMod(double massDiff, bool isotopeErrors, IEnumerable<MetaMorpheusModification> allMods, IEnumerable<Tuple<double, double>> combos, Tolerance precursorTolerance)
98100
{
99101
foreach (var Mod in allMods)
100102
{
101-
if (Mod.ObservedMassShift > massDiff - tolInDaltons && Mod.ObservedMassShift < massDiff + tolInDaltons)
103+
if (precursorTolerance.Within(massDiff, Mod.ObservedMassShift))
102104
yield return Mod;
103-
if (isotopeErrors && Mod.ObservedMassShift > massDiff - tolInDaltons - 1.003 && Mod.ObservedMassShift < massDiff + tolInDaltons - 1.003)
105+
if (isotopeErrors && precursorTolerance.Within(massDiff - missedMonoisopePeak, Mod.ObservedMassShift))
104106
yield return Mod;
105107
}
106108

@@ -109,18 +111,18 @@ private static IEnumerable<MetaMorpheusModification> GetMod(double massDiff, boo
109111
var m1 = combo.Item1;
110112
var m2 = combo.Item2;
111113
var combined = m1 + m2;
112-
if (combined > massDiff - tolInDaltons && combined < massDiff + tolInDaltons)
114+
if (precursorTolerance.Within(massDiff, combined))
113115
{
114-
foreach (var mod in GetMod(m1, isotopeErrors, allMods, combos, tolInDaltons))
116+
foreach (var mod in GetMod(m1, isotopeErrors, allMods, combos, precursorTolerance))
115117
yield return mod;
116-
foreach (var mod in GetMod(m2, isotopeErrors, allMods, combos, tolInDaltons))
118+
foreach (var mod in GetMod(m2, isotopeErrors, allMods, combos, precursorTolerance))
117119
yield return mod;
118120
}
119-
if (isotopeErrors && combined > massDiff - tolInDaltons - 1.003 && combined < massDiff + tolInDaltons - 1.003)
121+
if (isotopeErrors && precursorTolerance.Within(massDiff - missedMonoisopePeak, combined))
120122
{
121-
foreach (var mod in GetMod(m1, isotopeErrors, allMods, combos, tolInDaltons))
123+
foreach (var mod in GetMod(m1, isotopeErrors, allMods, combos, precursorTolerance))
122124
yield return mod;
123-
foreach (var mod in GetMod(m2, isotopeErrors, allMods, combos, tolInDaltons))
125+
foreach (var mod in GetMod(m2, isotopeErrors, allMods, combos, precursorTolerance))
124126
yield return mod;
125127
}
126128
}

EngineLayer/MyEngine.cs

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ protected MyEngine(int Level)
7373

7474
public static string MetaMorpheusVersion { get; private set; }
7575
public static UsefulProteomicsDatabases.Generated.unimod unimodDeserialized { get; private set; }
76-
7776
public static Dictionary<int, ChemicalFormulaModification> uniprotDeseralized { get; private set; }
7877

7978
#endregion Public Properties
File renamed without changes.

EngineLayer/MetaMorpheusModification.cs EngineLayer/Proteomics/MetaMorpheusModification.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public string Description
4545
{
4646
get
4747
{
48-
return Database + ":" + NameInXml + (Math.Abs(PrecursorMassShift - FragmentMassShift) < 1e-6 ? ":fms" + FragmentMassShift.ToString("F3", CultureInfo.InvariantCulture) : "");
48+
return Database + ":" + NameInXml + (Math.Abs(PrecursorMassShift - FragmentMassShift) > 1e-3 ? ":fms" + FragmentMassShift.ToString("F3", CultureInfo.InvariantCulture) : "");
4949
}
5050
}
5151

File renamed without changes.
File renamed without changes.

EngineLayer/PeptideWithSetModifications.cs EngineLayer/Proteomics/PeptideWithSetModifications.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public virtual string Sequence
109109
}
110110
}
111111

112-
public int NumVariableMods
112+
public int NumMods
113113
{
114114
get
115115
{
File renamed without changes.

EngineLayer/Protease.cs EngineLayer/Proteomics/Protease.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Protease
88

99
#region Public Constructors
1010

11-
public Protease(string name, IEnumerable<string> sequencesInducingCleavage, IEnumerable<string> sequencesPreventingCleavage, OldLogicTerminus cleavageTerminus, CleavageSpecificity cleavageSpecificity, string psiMSAccessionNumber, string psiMSName, string siteRegexp)
11+
public Protease(string name, IEnumerable<string> sequencesInducingCleavage, IEnumerable<string> sequencesPreventingCleavage, TerminusType cleavageTerminus, CleavageSpecificity cleavageSpecificity, string psiMSAccessionNumber, string psiMSName, string siteRegexp)
1212
{
1313
Name = name;
1414
SequencesInducingCleavage = sequencesInducingCleavage;
@@ -26,7 +26,7 @@ public Protease(string name, IEnumerable<string> sequencesInducingCleavage, IEnu
2626

2727
public string Name { get; private set; }
2828

29-
public OldLogicTerminus CleavageTerminus { get; private set; }
29+
public TerminusType CleavageTerminus { get; private set; }
3030
public IEnumerable<string> SequencesInducingCleavage { get; private set; }
3131
public IEnumerable<string> SequencesPreventingCleavage { get; private set; }
3232
public CleavageSpecificity CleavageSpecificity { get; private set; }
@@ -55,14 +55,14 @@ internal List<int> GetDigestionSiteIndices(string sequence)
5555
{
5656
foreach (string c in SequencesInducingCleavage)
5757
{
58-
if ((CleavageTerminus != OldLogicTerminus.N && i - c.Length + 1 >= 0 && sequence.Substring(i - c.Length + 1, c.Length).Equals(c, StringComparison.OrdinalIgnoreCase))
59-
|| (CleavageTerminus == OldLogicTerminus.N && i + 1 + c.Length <= sequence.Length && sequence.Substring(i + 1, c.Length).Equals(c, StringComparison.OrdinalIgnoreCase)))
58+
if ((CleavageTerminus != TerminusType.N && i - c.Length + 1 >= 0 && sequence.Substring(i - c.Length + 1, c.Length).Equals(c, StringComparison.OrdinalIgnoreCase))
59+
|| (CleavageTerminus == TerminusType.N && i + 1 + c.Length <= sequence.Length && sequence.Substring(i + 1, c.Length).Equals(c, StringComparison.OrdinalIgnoreCase)))
6060
{
6161
bool cleave = true;
6262
foreach (string nc in SequencesPreventingCleavage)
6363
{
64-
if ((CleavageTerminus != OldLogicTerminus.N && i + 1 + nc.Length <= sequence.Length && sequence.Substring(i + 1, nc.Length).Equals(nc, StringComparison.OrdinalIgnoreCase))
65-
|| (CleavageTerminus == OldLogicTerminus.N && i - nc.Length + 1 >= 0 && sequence.Substring(i - nc.Length + 1, nc.Length).Equals(nc, StringComparison.OrdinalIgnoreCase)))
64+
if ((CleavageTerminus != TerminusType.N && i + 1 + nc.Length <= sequence.Length && sequence.Substring(i + 1, nc.Length).Equals(nc, StringComparison.OrdinalIgnoreCase))
65+
|| (CleavageTerminus == TerminusType.N && i - nc.Length + 1 >= 0 && sequence.Substring(i - nc.Length + 1, nc.Length).Equals(nc, StringComparison.OrdinalIgnoreCase)))
6666
{
6767
cleave = false;
6868
break;

0 commit comments

Comments
 (0)