peptideAssumption.getIdentificationCharge().value,
(MSnSpectrum) spectrum, peptide, 0, searchParameters.getFragmentIonAccuracy(), false, true);
int sequenceLength = peptide.getSequence().length();
boolean[] aaCoverage = new boolean[sequenceLength];
for (IonMatch ionMatch : matches) {
Ion ion = ionMatch.ion;
if (ion instanceof PeptideFragmentIon) {
PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
int number = peptideFragmentIon.getNumber();
aaCoverage[number - 1] = true;
}
}
double nIons = 0.0;
for (boolean aa : aaCoverage) {
if (aa) {
nIons += 1;
}
}
coverage = 100 * nIons / sequenceLength;
return coverage + "";
case longest_amino_acid_sequence_annotated:
peptide = peptideAssumption.getPeptide();
matches = peptideSpectrumAnnotator.getSpectrumAnnotation(
annotationPreferences.getIonTypes(), annotationPreferences.getNeutralLosses(), annotationPreferences.getValidatedCharges(),
peptideAssumption.getIdentificationCharge().value,
(MSnSpectrum) SpectrumFactory.getInstance().getSpectrum(spectrumKey), peptide, 0, searchParameters.getFragmentIonAccuracy(), false, true);
sequence = peptide.getSequence();
sequenceLength = sequence.length();
boolean[] coverageForward = new boolean[sequenceLength];
boolean[] coverageRewind = new boolean[sequenceLength];
for (IonMatch ionMatch : matches) {
Ion ion = ionMatch.ion;
if (ion instanceof PeptideFragmentIon) {
PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
int number = peptideFragmentIon.getNumber();
if (peptideFragmentIon.getSubType() == PeptideFragmentIon.A_ION
|| peptideFragmentIon.getSubType() == PeptideFragmentIon.B_ION
|| peptideFragmentIon.getSubType() == PeptideFragmentIon.C_ION) {
coverageForward[number - 1] = true;
} else {
coverageRewind[number - 1] = true;
}
}
}
aaCoverage = new boolean[sequenceLength];
boolean previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = coverageForward[aaIndex];
if (current && previous) {
aaCoverage[aaIndex] = true;
}
previous = current;
}
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = coverageRewind[aaIndex];
if (current && previous) {
aaCoverage[sequenceLength - aaIndex - 1] = true;
}
previous = current;
}
StringBuilder currentTag = new StringBuilder();
String longestTag = new String();
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
if (aaCoverage[aaIndex]) {
currentTag.append(sequence.charAt(aaIndex));
} else {
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.toString();
}
currentTag = new StringBuilder();
}
}
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.toString();
}
return longestTag;
case longest_amino_acid_sequence_annotated_single_serie:
peptide = peptideAssumption.getPeptide();
matches = peptideSpectrumAnnotator.getSpectrumAnnotation(
annotationPreferences.getIonTypes(), annotationPreferences.getNeutralLosses(), annotationPreferences.getValidatedCharges(),
peptideAssumption.getIdentificationCharge().value,
(MSnSpectrum) SpectrumFactory.getInstance().getSpectrum(spectrumKey), peptide, 0, searchParameters.getFragmentIonAccuracy(), false, true);
sequence = peptide.getSequence();
sequenceLength = sequence.length();
HashMap<Integer, boolean[]> ionCoverage = new HashMap<Integer, boolean[]>(6);
ionCoverage.put(PeptideFragmentIon.A_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.B_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.C_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.X_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.Y_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.Z_ION, new boolean[sequenceLength]);
for (IonMatch ionMatch : matches) {
if (ionMatch.charge.value == 1) {
Ion ion = ionMatch.ion;
if (ion instanceof PeptideFragmentIon) {
PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
int number = peptideFragmentIon.getNumber();
if (peptideFragmentIon.getSubType() == PeptideFragmentIon.A_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
ionCoverage.get(PeptideFragmentIon.A_ION)[number - 1] = true;
} else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.B_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
ionCoverage.get(PeptideFragmentIon.B_ION)[number - 1] = true;
} else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.C_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
ionCoverage.get(PeptideFragmentIon.C_ION)[number - 1] = true;
} else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.X_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
ionCoverage.get(PeptideFragmentIon.X_ION)[number - 1] = true;
} else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.Y_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
ionCoverage.get(PeptideFragmentIon.Y_ION)[number - 1] = true;
} else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.Z_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
ionCoverage.get(PeptideFragmentIon.Z_ION)[number - 1] = true;
}
}
}
}
longestTag = new String();
currentTag = new StringBuilder();
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = ionCoverage.get(PeptideFragmentIon.A_ION)[aaIndex];
if (current && previous) {
currentTag.append(sequence.charAt(aaIndex));
} else {
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.toString();
}
currentTag = new StringBuilder();
}
previous = current;
}
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.reverse().toString();
}
currentTag = new StringBuilder();
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = ionCoverage.get(PeptideFragmentIon.B_ION)[aaIndex];
if (current && previous) {
currentTag.append(sequence.charAt(aaIndex));
} else {
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.toString();
}
currentTag = new StringBuilder();
}
previous = current;
}
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.reverse().toString();
}
currentTag = new StringBuilder();
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = ionCoverage.get(PeptideFragmentIon.C_ION)[aaIndex];
if (current && previous) {
currentTag.append(sequence.charAt(aaIndex));
} else {
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.toString();
}
currentTag = new StringBuilder();
}
previous = current;
}
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.reverse().toString();
}
currentTag = new StringBuilder();
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = ionCoverage.get(PeptideFragmentIon.X_ION)[aaIndex];
if (current && previous) {
currentTag.append(sequence.charAt(sequenceLength - aaIndex - 1));
} else {
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.reverse().toString();
}
currentTag = new StringBuilder();
}
previous = current;
}
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.reverse().toString();
}
currentTag = new StringBuilder();
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = ionCoverage.get(PeptideFragmentIon.Y_ION)[aaIndex];
if (current && previous) {
currentTag.append(sequence.charAt(sequenceLength - aaIndex - 1));
} else {
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.reverse().toString();
}
currentTag = new StringBuilder();
}
previous = current;
}
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.reverse().toString();
}
currentTag = new StringBuilder();
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = ionCoverage.get(PeptideFragmentIon.Z_ION)[aaIndex];
if (current && previous) {
currentTag.append(sequence.charAt(sequenceLength - aaIndex - 1));
} else {
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.reverse().toString();
}
currentTag = new StringBuilder();
}
previous = current;
}
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.reverse().toString();
}
return longestTag;
case amino_acids_annotated:
peptide = peptideAssumption.getPeptide();
spectrum = SpectrumFactory.getInstance().getSpectrum(spectrumKey);
matches = peptideSpectrumAnnotator.getSpectrumAnnotation(
annotationPreferences.getIonTypes(), annotationPreferences.getNeutralLosses(), annotationPreferences.getValidatedCharges(),
peptideAssumption.getIdentificationCharge().value,
(MSnSpectrum) spectrum, peptide, 0, searchParameters.getFragmentIonAccuracy(), false, true);
sequence = peptide.getSequence();
sequenceLength = sequence.length();
coverageForward = new boolean[sequenceLength];
coverageRewind = new boolean[sequenceLength];
for (IonMatch ionMatch : matches) {
Ion ion = ionMatch.ion;
if (ion instanceof PeptideFragmentIon) {
PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
int number = peptideFragmentIon.getNumber();
if (peptideFragmentIon.getSubType() == PeptideFragmentIon.A_ION
|| peptideFragmentIon.getSubType() == PeptideFragmentIon.B_ION