for (String proteinKey : identification.getProteinMap().get(protein)) {
if (!possibleProteinMatches.contains(proteinKey)) {
try {
testMatch = identification.getProteinMatch(proteinKey);
if (testMatch.getPeptideMatchesKeys().contains(peptideKey)) {
Protein currentProtein = sequenceFactory.getProtein(testMatch.getMainMatch());
peptideOccurrence += currentProtein.getPeptideStart(peptideSequence,
sequenceMatchingPreferences).size();
possibleProteinMatches.add(proteinKey);
}
} catch (Exception e) {
// protein deleted due to protein inference issue and not deleted from the map in versions earlier than 0.14.6
System.out.println("Non-existing protein key in protein map: " + proteinKey);
e.printStackTrace();
}
}
}
}
}
if (possibleProteinMatches.isEmpty()) {
System.err.println("No protein found for the given peptide (" + peptideKey + ") when estimating NSAF of '" + proteinMatchKey + "'.");
}
double ratio = 1.0 / peptideOccurrence;
identification.loadSpectrumMatchParameters(peptideMatch.getSpectrumMatches(), pSParameter, null);
for (String spectrumMatchKey : peptideMatch.getSpectrumMatches()) {
pSParameter = (PSParameter) identification.getSpectrumMatchParameter(spectrumMatchKey, pSParameter);
if (!spectrumCountingPreferences.isValidatedHits() || pSParameter.getMatchValidationLevel().isValidated()) {
result += ratio;
}
}
}
Protein currentProtein = sequenceFactory.getProtein(proteinMatch.getMainMatch());
if (!enzyme.isSemiSpecific()) {
result /= currentProtein.getObservableLength(enzyme, maxPepLength);
} else {
result /= currentProtein.getLength(); // @TODO: how to handle this for semi-specific??
}
if (new Double(result).isInfinite() || new Double(result).isNaN()) {
result = 0.0;
}
return result;
} else {
// emPAI
double result;
if (spectrumCountingPreferences.isValidatedHits()) {
result = 0;
identification.loadPeptideMatchParameters(proteinMatch.getPeptideMatchesKeys(), pSParameter, null);
for (String peptideKey : proteinMatch.getPeptideMatchesKeys()) {
pSParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, pSParameter);
if (pSParameter.getMatchValidationLevel().isValidated()) {
result++;
}
}
} else {
result = proteinMatch.getPeptideCount();
}
Protein currentProtein = sequenceFactory.getProtein(proteinMatch.getMainMatch());
result = Math.pow(10, result / currentProtein.getNCleavageSites(enzyme)) - 1;
if (new Double(result).isInfinite() || new Double(result).isNaN()) {
result = 0.0;
}