def aa_precision_recall_with_threshold(correct_aa_confidences, all_aa_confidences, num_original_aa, threshold):
    """
    Calculate precision and recall for the given amino acid confidence score threshold
    
    Parameters
    ----------
    correct_aa_confidences : list 
        List of confidence scores for correct amino acids predictions
    all_aa_confidences : int
        List of confidence scores for all amino acids prediction
    num_original_aa : int
        Number of amino acids in the predicted peptide sequences
    threshold : float
        Amino acid confidence score threshold
           
    Returns
    -------
    aa_precision: float
        Number of correct aa predictions divided by all predicted aa
    aa_recall: float
        Number of correct aa predictions divided by all original aa     
    """    
   
    correct_aa = sum([conf>=threshold for conf in correct_aa_confidences])
    predicted_aa = sum([conf>=threshold for conf in all_aa_confidences])
    
    aa_precision = correct_aa/predicted_aa
    aa_recall = correct_aa/num_original_aa
    
    return aa_precision, aa_recall