*/
public HashMap<Integer, ArrayList<ResidueAnnotation>> getResidueAnnotation(String proteinMatchKey, SequenceMatchingPreferences sequenceMatchingPreferences, IdentificationFeaturesGenerator identificationFeaturesGenerator, Metrics metrics, Identification identification,
boolean allPeptides, SearchParameters searchParameters, boolean enzymatic)
throws IllegalArgumentException, SQLException, IOException, ClassNotFoundException, InterruptedException {
ProteinMatch proteinMatch = identification.getProteinMatch(proteinMatchKey);
Protein currentProtein = sequenceFactory.getProtein(proteinMatch.getMainMatch());
String sequence = currentProtein.getSequence();
HashMap<Integer, ArrayList<ResidueAnnotation>> residueAnnotation = new HashMap<Integer, ArrayList<ResidueAnnotation>>(sequence.length());
double[] coverage = identificationFeaturesGenerator.getCoverableAA(proteinMatchKey);
double lastP = coverage[0];
int lastIndex = 0;
for (int i = 1; i < coverage.length; i++) {
double p = coverage[i];
if (p != lastP) {
String annotation = (lastIndex + 1) + "-" + (i + 1);
if (metrics.getPeptideLengthDistribution() != null) {
annotation += ", " + Util.roundDouble(100 * lastP, 1) + "% chance of coverage";
} else if (lastP > 0.01) {
annotation += ", possible to cover";
}
ArrayList<ResidueAnnotation> annotations = new ArrayList<ResidueAnnotation>(1);
annotations.add(new ResidueAnnotation(annotation, null, false));
for (int j = lastIndex; j < i; j++) {
residueAnnotation.put(j, new ArrayList<ResidueAnnotation>(annotations));
}
lastP = p;
lastIndex = i;
}
}
int i = coverage.length;
String annotation = (lastIndex + 1) + "-" + (i);
if (metrics.getPeptideLengthDistribution() != null) {
annotation += ", " + Util.roundDouble(100 * lastP, 1) + "% chance of coverage";
} else if (lastP > 0.01) {
annotation += ", possible to cover";
}
ArrayList<ResidueAnnotation> annotations = new ArrayList<ResidueAnnotation>(1);
annotations.add(new ResidueAnnotation(annotation, null, false));
for (int j = lastIndex; j < i; j++) {
residueAnnotation.put(j, new ArrayList<ResidueAnnotation>(annotations));
}
// batch load the required data
identification.loadPeptideMatches(proteinMatch.getPeptideMatchesKeys(), null);
for (String peptideKey : proteinMatch.getPeptideMatchesKeys()) {
PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
String peptideSequence = peptideMatch.getTheoreticPeptide().getSequence();
boolean enzymaticPeptide = true;
if (!allPeptides) {
enzymaticPeptide = currentProtein.isEnzymaticPeptide(peptideSequence, searchParameters.getEnzyme(),