HashMap<Integer, ArrayList<ResidueAnnotation>> proteinTooltips = new HashMap<Integer, ArrayList<ResidueAnnotation>>();
// we need to add a first empty filler as the coverage table starts at 0
ArrayList<Double> data = new ArrayList<Double>();
data.add(new Double(1));
JSparklinesDataSeries sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
PSPtmScores psPtmScores = new PSPtmScores();
ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
String sequence = sequenceFactory.getProtein(proteinMatch.getMainMatch()).getSequence();
psPtmScores = (PSPtmScores) proteinMatch.getUrParam(psPtmScores);
int unmodifiedCounter = 0;
// get the fixed ptms
HashMap<Integer, String> fixedPtms = new HashMap<Integer, String>(); // @TODO: note this this only supports one fixed ptm per residue
Identification identification = peptideShakerGUI.getIdentification();
identification.loadPeptideMatches(peptideKeys, null);
DisplayPreferences displayPreferences = peptideShakerGUI.getDisplayPreferences();
for (String peptideKey : peptideKeys) {
boolean modified = false;
for (String ptmName : displayPreferences.getDisplayedPtms()) {
if (Peptide.isModified(peptideKey, ptmName)) {
modified = true;
break;
}
}
if (modified) {
PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
for (ModificationMatch modMatch : peptideMatch.getTheoreticPeptide().getModificationMatches()) {
if (!modMatch.isVariable()) {
String ptmName = modMatch.getTheoreticPtm();
if (displayPreferences.isDisplayedPTM(ptmName)) {
ArrayList<Integer> indexes = sequenceFactory.getProtein(proteinAccession).getPeptideStart(Peptide.getSequence(peptideKey),
peptideShakerGUI.getSequenceMatchingPreferences());
for (Integer index : indexes) {
fixedPtms.put(modMatch.getModificationSite() + index - 2, ptmName);
}
}
}
}
}
}
for (int aa = 0; aa < sequence.length(); aa++) {
String ptmName = fixedPtms.get(aa);
for (String variablePTM : psPtmScores.getPtmsAtRepresentativeSite(aa)) {
if (displayPreferences.isDisplayedPTM(variablePTM)) {
ptmName = variablePTM;
break;
}
}
for (String variablePTM : psPtmScores.getConfidentModificationsAt(aa)) {
if (displayPreferences.isDisplayedPTM(variablePTM)) {
ptmName = variablePTM;
break;
}
}
if (ptmName != null) {
// add the non-modified area
if (unmodifiedCounter > 0) {
data = new ArrayList<Double>(1);
data.add(new Double(unmodifiedCounter));
sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
}
// @TODO: what about multiple ptms on the same residue..?
// if (psPtmScores.getMainModificationsAt(aa).size() > 1) {
// for (int i=0; i<psPtmScores.getMainModificationsAt(aa).size(); i++) {
// psPtmScores.getMainModificationsAt(aa).get(i);
// }
// }
// @TODO: are peptide terminal mods excluded??
Color ptmColor = peptideShakerGUI.getSearchParameters().getModificationProfile().getColor(ptmName);
if (ptmColor == null) {
ptmColor = Color.lightGray;
}
ArrayList<ResidueAnnotation> annotations = new ArrayList<ResidueAnnotation>(1);
annotations.add(new ResidueAnnotation(ptmName, null, false));
proteinTooltips.put(sparkLineDataSeriesPtm.size(), annotations);
data = new ArrayList<Double>(1);
data.add(new Double(1));
sparklineDataseriesPtm = new JSparklinesDataSeries(data, ptmColor, null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
// reset the non-modified area counter
unmodifiedCounter = 0;
} else {
unmodifiedCounter++;
}
}
if (unmodifiedCounter > 0) {
// add the remaining non-modified area
data = new ArrayList<Double>();
data.add(new Double(unmodifiedCounter));
sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
}
ptmChart = new ProteinSequencePanel(Color.WHITE).getSequencePlot(this, new JSparklinesDataset(sparkLineDataSeriesPtm), proteinTooltips, false, false);
sequencePtmsPanel.removeAll();