static List<String> digestProtein(String sequence, int minLen, int maxLen) {
        List<String> peptides = new ArrayList<String>();
        String peptide;
        int i = 0, idx;
        
        while (i < sequence.length()) {
            idx = i; 
            while ( (idx < sequence.length()-1) && 
                    (((sequence.charAt(idx)=='K' || sequence.charAt(idx)=='R') && 
                    sequence.charAt(idx+1)=='P') ||
                    (sequence.charAt(idx) != 'K' && sequence.charAt(idx) != 'R')) ) {
                idx += 1;
            }
            peptide = sequence.substring(i, idx+1);
            if ((peptide.length() >= minLen) && (peptide.length() <= maxLen)) {
                peptides.add(peptide);
            }
            
            i = idx+1;
        }
        return peptides;
    }