Skip to content

Commit 5d44a84

Browse files
Ticket 53573: Formatting adjustments to the Peptide Map report (#1098)
1 parent 27dc181 commit 5d44a84

8 files changed

Lines changed: 67 additions & 20 deletions

File tree

resources/queries/targetedms/PeptideIds.query.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<property name="showNextAndPrevious">true</property>
1818
<property name="useParens">true</property>
1919
<property name="exportFormatted">true</property>
20+
<property name="highlightFixed">false</property>
2021
</properties>
2122
</displayColumnFactory>
2223
</column>

src/org/labkey/targetedms/parser/PeptideSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ public Boolean getExplicitMod()
493493

494494
public boolean isModExplicit()
495495
{
496-
return _explicitMod == null ? false : _explicitMod;
496+
return _explicitMod != null && _explicitMod;
497497
}
498498

499499
public void setExplicitMod(Boolean explicitMod)

src/org/labkey/targetedms/query/CrossLinkedPeptideDisplayColumn.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,29 +173,29 @@ public DisplayColumn createRenderer(ColumnInfo colInfo)
173173
return new CrossLinkedPeptideDisplayColumn(colInfo, (match, sequence, modification) ->
174174
{
175175
String label = match.protein().getLabel();
176-
String suffix = getChainAbbreviation(label);
177-
return (match.index() + 1) + "-" + (match.index() + getPeptideLength(sequence.getUnmodified(), modification)) + suffix;
176+
String prefix = getChainPrefix(label);
177+
return prefix + (match.index() + 1) + "-" + (match.index() + getPeptideLength(sequence.getUnmodified(), modification));
178178
});
179179
}
180180
}
181181

182-
public static @NotNull String getChainAbbreviation(String label)
182+
public static @NotNull String getChainPrefix(String label)
183183
{
184184
String result = "";
185185
if (label != null)
186186
{
187187
label = label.toLowerCase();
188188
if (label.endsWith("_hc"))
189189
{
190-
result = "HC";
190+
result = "H";
191191
}
192192
if (label.endsWith("_hcstar"))
193193
{
194-
result = "HC*";
194+
result = "*";
195195
}
196196
if (label.endsWith("_lc"))
197197
{
198-
result = "LC";
198+
result = "L";
199199
}
200200
}
201201
return result;
@@ -221,7 +221,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo)
221221
{
222222
for (int linkIndex : sequence.getLinkIndices())
223223
{
224-
bonds.add(Character.toString(sequence.getUnmodified().charAt(linkIndex)) + (match.index() + linkIndex + 1) + getChainAbbreviation(match.protein().getLabel()));
224+
bonds.add(Character.toString(sequence.getUnmodified().charAt(linkIndex)) + (match.index() + linkIndex + 1) + getChainPrefix(match.protein().getLabel()));
225225
}
226226
}
227227
allBonds.add(bonds);

src/org/labkey/targetedms/query/ModificationManager.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,15 @@ public static PeptideSettings.ModificationSettings getSettings(long runId)
265265
/**
266266
* @return PeptideId -> (Set of indexes where the peptide has structural modifications)
267267
*/
268-
private static Map<Long, Set<Pair<Integer, Integer>>> getPeptideStructuralModIndexMap(long runId)
268+
private static Map<Long, Set<Pair<Integer, Integer>>> getPeptideStructuralModIndexMap(long runId, boolean includeFixedMods)
269269
{
270270
SQLFragment sql = new SQLFragment();
271271
sql.append(" SELECT mod.PeptideId AS peptideId, mod.IndexAA AS indexAA, mod.PeptideIndex AS peptideIndex");
272272
sql.append(" FROM ");
273273
sql.append(TargetedMSManager.getTableInfoPeptideStructuralModification(), "mod");
274274
sql.append(" , ");
275+
sql.append(TargetedMSManager.getTableInfoRunStructuralModification(), "runmod");
276+
sql.append(" , ");
275277
sql.append(TargetedMSManager.getTableInfoGeneralMolecule(), "gm");
276278
sql.append(" , ");
277279
sql.append(TargetedMSManager.getTableInfoPeptideGroup(), "pg");
@@ -285,6 +287,15 @@ private static Map<Long, Set<Pair<Integer, Integer>>> getPeptideStructuralModInd
285287
sql.append(" gm.peptideGroupId = pg.id ");
286288
sql.append(" AND ");
287289
sql.append(" mod.peptideId = gm.id ");
290+
sql.append(" AND ");
291+
sql.append(" runmod.StructuralModId = mod.StructuralModId");
292+
sql.append(" AND ");
293+
sql.append(" runmod.RunId = run.Id");
294+
if (!includeFixedMods)
295+
{
296+
sql.append(" AND (runmod.variable = ? OR runmod.ExplicitMod IS NOT NULL)");
297+
sql.add(true);
298+
}
288299

289300
final Map<Long, Set<Pair<Integer, Integer>>> peptideModIndexMap = new HashMap<>();
290301

@@ -342,17 +353,25 @@ private static Map<Pair<Long,Long>, Set<Integer>> getPeptideIsotopeModIndexMap(l
342353
return Collections.unmodifiableMap(peptideModIndexMap);
343354
}
344355

345-
/** Pair is the index of the cross-linked peptide (or 0 for non-cross-linked peptides) and the amino acid index */
346-
public static Set<Pair<Integer, Integer>> getStructuralModIndexes(long peptideId, Long runId)
356+
/**
357+
* Pair is the index of the cross-linked peptide (or 0 for non-cross-linked peptides) and the amino acid index
358+
* @param includeFixedMods Whether to include fixed modifications
359+
* @return Set of pairs of peptide index and amino acid index
360+
*/
361+
public static Set<Pair<Integer, Integer>> getStructuralModIndexes(long peptideId, Long runId, boolean includeFixedMods)
347362
{
348-
if(runId == null)
363+
if (runId == null)
349364
{
365+
if (!includeFixedMods)
366+
{
367+
throw new UnsupportedOperationException();
368+
}
350369
Map<Pair<Integer, Integer>, Double> modMap = getPeptideStructuralModsMap(peptideId);
351370
return new HashSet<>(modMap.keySet());
352371
}
353372
else
354373
{
355-
Map<Long, Set<Pair<Integer, Integer>>> modIndexesForRun = PEPTIDE_STR_MOD_INDEXES.get(String.valueOf(runId), null, (runId1, argument) -> getPeptideStructuralModIndexMap(Long.valueOf(runId1)));
374+
Map<Long, Set<Pair<Integer, Integer>>> modIndexesForRun = PEPTIDE_STR_MOD_INDEXES.get(runId + "-" + includeFixedMods, null, (runId1, argument) -> getPeptideStructuralModIndexMap(runId, includeFixedMods));
356375
return modIndexesForRun.getOrDefault(peptideId, Collections.emptySet());
357376
}
358377
}

src/org/labkey/targetedms/query/ModifiedSequenceDisplayColumn.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,15 @@ public abstract class ModifiedSequenceDisplayColumn extends IconColumn
6464
public static final String PRECURSOR_COLUMN_NAME = "ModifiedPrecursorDisplayColumn";
6565

6666
public ModifiedSequenceDisplayColumn(ColumnInfo colInfo)
67+
{
68+
this(colInfo, true);
69+
}
70+
71+
public ModifiedSequenceDisplayColumn(ColumnInfo colInfo, boolean highlightFixed)
6772
{
6873
super(colInfo);
6974

70-
_htmlMaker = new ModifiedPeptideHtmlMaker();
75+
_htmlMaker = new ModifiedPeptideHtmlMaker(highlightFixed);
7176
}
7277

7378
ModifiedPeptideHtmlMaker getHtmlMaker()
@@ -147,6 +152,7 @@ public static class PeptideDisplayColumnFactory implements DisplayColumnFactory
147152
private boolean _exportStrippedHtml = false;
148153
private boolean _showNextAndPrevious = false;
149154
private boolean _useParens = false;
155+
private boolean _highlightFixed = true;
150156
/** Optionally, the name of the column that identifies the animo acid and index within the protein to highlight as modified */
151157
private String _modificationSite;
152158

@@ -161,6 +167,7 @@ public PeptideDisplayColumnFactory(MultiValuedMap<String, String> map)
161167
_useParens = getBooleanProperty(map, "useParens", _useParens);
162168
_exportStrippedHtml = getBooleanProperty(map, "exportFormatted", _exportStrippedHtml);
163169
_modificationSite = map == null || map.get("modificationSite").isEmpty() ? null : map.get("modificationSite").iterator().next();
170+
_highlightFixed = getBooleanProperty(map, "highlightFixed", _highlightFixed);
164171
}
165172

166173
private boolean getBooleanProperty(MultiValuedMap<String, String> map, String propertyName, boolean defaultValue)
@@ -176,7 +183,7 @@ private boolean getBooleanProperty(MultiValuedMap<String, String> map, String pr
176183
@Override
177184
public DisplayColumn createRenderer(ColumnInfo colInfo)
178185
{
179-
return new ModifiedSequenceDisplayColumn.PeptideCol(colInfo, _showNextAndPrevious, _useParens, _exportStrippedHtml, _modificationSite);
186+
return new ModifiedSequenceDisplayColumn.PeptideCol(colInfo, _showNextAndPrevious, _useParens, _exportStrippedHtml, _highlightFixed, _modificationSite);
180187
}
181188
}
182189

@@ -190,12 +197,12 @@ public static class PeptideCol extends ModifiedSequenceDisplayColumn
190197

191198
public PeptideCol(ColumnInfo colInfo)
192199
{
193-
this(colInfo, false, false, false, null);
200+
this(colInfo, false, false, false, true, null);
194201
}
195202

196-
public PeptideCol(ColumnInfo colInfo, boolean showNextAndPrevious, boolean useParens, boolean exportStrippedHtml, String modificationSite)
203+
public PeptideCol(ColumnInfo colInfo, boolean showNextAndPrevious, boolean useParens, boolean exportStrippedHtml, boolean highlightFixed, String modificationSite)
197204
{
198-
super(colInfo);
205+
super(colInfo, highlightFixed);
199206
_showNextAndPrevious = showNextAndPrevious;
200207
_useParens = useParens;
201208
_modificationSite = modificationSite;

src/org/labkey/targetedms/query/SiteLocationDisplayColumnFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void writeCell(Sheet sheet, int column, int row, RenderContext ctx)
7676
};
7777

7878
String chain = _col.getChainLabel(ctx);
79-
String chainPrefix = CrossLinkedPeptideDisplayColumn.getChainAbbreviation(chain);
79+
String chainPrefix = CrossLinkedPeptideDisplayColumn.getChainPrefix(chain);
8080
if (!chainPrefix.isEmpty())
8181
{
8282
chainPrefix = chainPrefix + " ";

src/org/labkey/targetedms/view/ModifiedPeptideHtmlMaker.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public class ModifiedPeptideHtmlMaker
5454

5555
/** RunId -> all proteins in that run */
5656
private final Map<Long, List<Protein>> _proteins = new HashMap<>();
57+
58+
/** Whether to include fixed modifications in the formatting */
59+
private final boolean _highlightFixedMods;
5760

5861
private final static String[] HEX_PADDING = new String[] {
5962
"",
@@ -66,8 +69,17 @@ public class ModifiedPeptideHtmlMaker
6669
};
6770

6871
public ModifiedPeptideHtmlMaker()
72+
{
73+
this(true);
74+
}
75+
76+
/**
77+
* @param highlightFixedMods Whether to include fixed modifications in the formatting
78+
*/
79+
public ModifiedPeptideHtmlMaker(boolean highlightFixedMods)
6980
{
7081
_firstIsotopeLabelIdInDocMap = new HashMap<>();
82+
_highlightFixedMods = highlightFixedMods;
7183
}
7284

7385
public Pair<HtmlString, List<List<SequencePart>>> getPrecursorHtml(Precursor precursor, Long runId, TargetedMSSchema schema)
@@ -147,7 +159,7 @@ private Pair<HtmlString, List<List<SequencePart>>> getHtml(long peptideId, @Null
147159

148160
if (strModIndices == null)
149161
{
150-
strModIndices = ModificationManager.getStructuralModIndexes(peptideId, runId);
162+
strModIndices = ModificationManager.getStructuralModIndexes(peptideId, runId, _highlightFixedMods);
151163
}
152164
Set<Integer> isotopeModIndices = null;
153165
if(isotopeLabelId != null)

test/src/org/labkey/test/tests/targetedms/TargetedMSMAMTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import org.junit.experimental.categories.Category;
2121
import org.labkey.test.Locator;
2222

23+
import static org.junit.Assert.assertTrue;
24+
2325
@Category({})
2426
public class TargetedMSMAMTest extends TargetedMSTest
2527
{
@@ -60,6 +62,9 @@ public void testSteps()
6062
assertTextPresentInThisOrder("70-84", "325-333", "28-41", "190-196; 26-32");
6163
assertTextPresentInThisOrder("(K)ASTEGVAIQGQQGTR(L)", "(K)AQYEDIANR(S)", "(K)SVTEQGAELSNEER(N)");
6264
assertTextPresentInThisOrder("Carbamidomethyl Cysteine @ C157", "Carbamidomethyl Cysteine @ C245", "Carbamidomethyl Cysteine @ C94");
65+
66+
// Ensure that the Cystine isn't highlighted, as it's a fixed modification and that report doesn't want to call it out
67+
assertTrue(getHtmlSource().contains("(K)YLECSALTQR(G)"));
6368
}
6469

6570
@Test
@@ -77,5 +82,8 @@ public void testCrossLinkedPeptideMap()
7782
// Disulfide bonds
7883
assertTextPresentInThisOrder("Q364-T369-D364/\nN366-T369-D364", "V121-S345-Q142/\nQ124-S345-Q142");
7984
assertTextPresentInThisOrder("(A)LKPLALV(D)", "(G)AVVQDPA(Y)", "(F)YGEATSR(E)");
85+
86+
// Ensure that the highlighting is as expected for both crosslinking and modification
87+
assertTrue(getHtmlSource().contains("(Y)<span style=\"font-weight:bold;color:green;text-decoration:underline;\">Q</span><span style=\"font-weight:bold;text-decoration:underline;\">M</span><span style=\"font-weight:bold;color:green;\">N</span>(D)"));
8088
}
8189
}

0 commit comments

Comments
 (0)