Skip to content

Commit fb4b105

Browse files
authored
Merge pull request #112 from topdownproteomics/proteoform-mod-evidence
Proteoform Modification Evidence
2 parents c5d5b54 + 54f7ba5 commit fb4b105

File tree

3 files changed

+244
-237
lines changed

3 files changed

+244
-237
lines changed

src/TopDownProteomics/ProForma/Validation/BrnoModificationLookup.cs

+107-106
Original file line numberDiff line numberDiff line change
@@ -2,132 +2,133 @@
22
using TopDownProteomics.Chemistry;
33
using TopDownProteomics.Proteomics;
44

5-
namespace TopDownProteomics.ProForma.Validation
5+
namespace TopDownProteomics.ProForma.Validation;
6+
7+
/// <summary>
8+
/// Lookup for Brno nomenclature for histone modifications.
9+
/// https://doi.org/10.1038/nsmb0205-110
10+
/// </summary>
11+
/// <seealso cref="IProteoformModificationLookup" />
12+
public class BrnoModificationLookup : IProteoformModificationLookup
613
{
14+
BrnoModification[] _modifications;
15+
716
/// <summary>
8-
/// Lookup for Brno nomenclature for histone modifications.
9-
/// https://doi.org/10.1038/nsmb0205-110
17+
/// Initializes a new instance of the <see cref="BrnoModificationLookup"/> class.
1018
/// </summary>
11-
/// <seealso cref="IProteoformModificationLookup" />
12-
public class BrnoModificationLookup : IProteoformModificationLookup
19+
/// <param name="elementProvider">The element provider.</param>
20+
public BrnoModificationLookup(IElementProvider elementProvider)
1321
{
14-
BrnoModification[] _modifications;
22+
_modifications = this.CreateModificationArray(elementProvider);
23+
}
1524

16-
/// <summary>
17-
/// Initializes a new instance of the <see cref="BrnoModificationLookup"/> class.
18-
/// </summary>
19-
/// <param name="elementProvider">The element provider.</param>
20-
public BrnoModificationLookup(IElementProvider elementProvider)
21-
{
22-
_modifications = this.CreateModificationArray(elementProvider);
23-
}
25+
/// <summary>
26+
/// Determines whether this instance [can handle descriptor] the specified descriptor.
27+
/// </summary>
28+
/// <param name="descriptor">The descriptor.</param>
29+
/// <returns>
30+
/// <c>true</c> if this instance [can handle descriptor] the specified descriptor; otherwise, <c>false</c>.
31+
/// </returns>
32+
public bool CanHandleDescriptor(IProFormaDescriptor descriptor)
33+
{
34+
return descriptor.Key == ProFormaKey.Name &&
35+
descriptor.EvidenceType == ProFormaEvidenceType.Brno &&
36+
descriptor.Value != null;
37+
}
2438

25-
/// <summary>
26-
/// Determines whether this instance [can handle descriptor] the specified descriptor.
27-
/// </summary>
28-
/// <param name="descriptor">The descriptor.</param>
29-
/// <returns>
30-
/// <c>true</c> if this instance [can handle descriptor] the specified descriptor; otherwise, <c>false</c>.
31-
/// </returns>
32-
public bool CanHandleDescriptor(IProFormaDescriptor descriptor)
39+
/// <summary>
40+
/// Gets the modification.
41+
/// </summary>
42+
/// <param name="descriptor">The descriptor.</param>
43+
/// <returns></returns>
44+
public IProteoformMassDelta GetModification(IProFormaDescriptor descriptor)
45+
{
46+
string abbreviation = descriptor.Value;
47+
48+
switch (abbreviation)
3349
{
34-
return descriptor.Key == ProFormaKey.Name &&
35-
descriptor.EvidenceType == ProFormaEvidenceType.Brno &&
36-
descriptor.Value != null;
50+
case "ac": return _modifications[0];
51+
case "me1": return _modifications[1];
52+
case "me2s": return _modifications[2];
53+
case "me2a": return _modifications[3];
54+
case "me2": return _modifications[4];
55+
case "me3": return _modifications[5];
56+
case "ph": return _modifications[6];
57+
58+
default:
59+
throw new ProteoformModificationLookupException($"Couldn't handle value for descriptor {descriptor}.");
3760
}
61+
}
3862

39-
/// <summary>
40-
/// Gets the modification.
41-
/// </summary>
42-
/// <param name="descriptor">The descriptor.</param>
43-
/// <returns></returns>
44-
public IProteoformMassDelta GetModification(IProFormaDescriptor descriptor)
63+
private BrnoModification[] CreateModificationArray(IElementProvider elementProvider)
64+
{
65+
var mods = new BrnoModification[7];
66+
67+
var h = elementProvider.GetElement(1);
68+
var c = elementProvider.GetElement(6);
69+
var o = elementProvider.GetElement(8);
70+
var p = elementProvider.GetElement(15);
71+
72+
mods[0] = new BrnoModification("B:ac", new[]
4573
{
46-
string abbreviation = descriptor.Value;
47-
48-
switch (abbreviation)
49-
{
50-
case "ac": return _modifications[0];
51-
case "me1": return _modifications[1];
52-
case "me2s": return _modifications[2];
53-
case "me2a": return _modifications[3];
54-
case "me2": return _modifications[4];
55-
case "me3": return _modifications[5];
56-
case "ph": return _modifications[6];
57-
58-
default:
59-
throw new ProteoformModificationLookupException($"Couldn't handle value for descriptor {descriptor}.");
60-
}
61-
}
74+
new EntityCardinality<IElement>(c, 2),
75+
new EntityCardinality<IElement>(h, 2),
76+
new EntityCardinality<IElement>(o, 1)
77+
});
78+
mods[1] = new BrnoModification("B:me1", new[]
79+
{
80+
new EntityCardinality<IElement>(c, 1),
81+
new EntityCardinality<IElement>(h, 2)
82+
});
6283

63-
private BrnoModification[] CreateModificationArray(IElementProvider elementProvider)
84+
var me2 = new[]
6485
{
65-
var mods = new BrnoModification[7];
66-
67-
var h = elementProvider.GetElement(1);
68-
var c = elementProvider.GetElement(6);
69-
var o = elementProvider.GetElement(8);
70-
var p = elementProvider.GetElement(15);
71-
72-
mods[0] = new BrnoModification("B:ac", new[]
73-
{
74-
new EntityCardinality<IElement>(c, 2),
75-
new EntityCardinality<IElement>(h, 2),
76-
new EntityCardinality<IElement>(o, 1)
77-
});
78-
mods[1] = new BrnoModification("B:me1", new[]
79-
{
80-
new EntityCardinality<IElement>(c, 1),
81-
new EntityCardinality<IElement>(h, 2)
82-
});
83-
84-
var me2 = new[]
85-
{
86-
new EntityCardinality<IElement>(c, 2),
87-
new EntityCardinality<IElement>(h, 4)
88-
};
89-
mods[2] = new BrnoModification("B:me2s", me2);
90-
mods[3] = new BrnoModification("B:me2a", me2);
91-
mods[4] = new BrnoModification("B:me2", me2);
92-
93-
mods[5] = new BrnoModification("B:me3", new[]
94-
{
95-
new EntityCardinality<IElement>(c, 3),
96-
new EntityCardinality<IElement>(h, 6)
97-
});
98-
mods[6] = new BrnoModification("B:ph", new[]
99-
{
100-
new EntityCardinality<IElement>(h, 1),
101-
new EntityCardinality<IElement>(o, 3),
102-
new EntityCardinality<IElement>(p, 1),
103-
});
104-
105-
return mods;
106-
}
86+
new EntityCardinality<IElement>(c, 2),
87+
new EntityCardinality<IElement>(h, 4)
88+
};
89+
mods[2] = new BrnoModification("B:me2s", me2);
90+
mods[3] = new BrnoModification("B:me2a", me2);
91+
mods[4] = new BrnoModification("B:me2", me2);
92+
93+
mods[5] = new BrnoModification("B:me3", new[]
94+
{
95+
new EntityCardinality<IElement>(c, 3),
96+
new EntityCardinality<IElement>(h, 6)
97+
});
98+
mods[6] = new BrnoModification("B:ph", new[]
99+
{
100+
new EntityCardinality<IElement>(h, 1),
101+
new EntityCardinality<IElement>(o, 3),
102+
new EntityCardinality<IElement>(p, 1),
103+
});
107104

108-
private class BrnoModification : IProteoformOntologyDelta
105+
return mods;
106+
}
107+
108+
private class BrnoModification : IProteoformOntologyDelta
109+
{
110+
public BrnoModification(string abbreviation, IReadOnlyCollection<IEntityCardinality<IElement>> elements)
109111
{
110-
public BrnoModification(string abbreviation, IReadOnlyCollection<IEntityCardinality<IElement>> elements)
111-
{
112-
this.Abbreviation = abbreviation;
113-
_elements = elements;
114-
}
112+
this.Abbreviation = abbreviation;
113+
_elements = elements;
114+
}
115115

116-
private IReadOnlyCollection<IEntityCardinality<IElement>> _elements;
117-
string Abbreviation { get; }
116+
private IReadOnlyCollection<IEntityCardinality<IElement>> _elements;
117+
string Abbreviation { get; }
118118

119-
public string Id => this.Abbreviation;
119+
public string Id => this.Abbreviation;
120120

121-
public string Name => this.Abbreviation;
121+
public string Name => this.Abbreviation;
122122

123-
public ChemicalFormula GetChemicalFormula() => new ChemicalFormula(_elements);
123+
public ProFormaEvidenceType EvidenceType => ProFormaEvidenceType.Brno;
124124

125-
public ProFormaDescriptor GetProFormaDescriptor()
126-
{
127-
return new ProFormaDescriptor(ProFormaKey.Identifier, ProFormaEvidenceType.None, this.Abbreviation);
128-
}
125+
public ChemicalFormula GetChemicalFormula() => new ChemicalFormula(_elements);
129126

130-
public double GetMass(MassType massType) => this.GetChemicalFormula().GetMass(massType);
127+
public ProFormaDescriptor GetProFormaDescriptor()
128+
{
129+
return new ProFormaDescriptor(ProFormaKey.Identifier, ProFormaEvidenceType.None, this.Abbreviation);
131130
}
131+
132+
public double GetMass(MassType massType) => this.GetChemicalFormula().GetMass(massType);
132133
}
133134
}

0 commit comments

Comments
 (0)