コード例 #1
0
def get_binnary_peptide_overlap(exp1:Experiment, exp2:Experiment)->Peptides:
    """compare the peptide overlap between two experimental objects.

    :param exp1: an instance of class Experiment.
    :type exp1: Experiment
    :param exp2: an instance of class Experiment.
    :type exp2: Experiment
    :return: a list of peptides that have been identified in both experiments.
    :rtype: Peptides
    """
    peptide_one=exp1.get_peptides()
    peptide_two=exp2.get_peptides()
    return list(peptide_one.intersection(peptide_two))
コード例 #2
0
def compute_jaccard_index(exp1:Experiment,exp2:Experiment, level:str='peptide')->float:
    """Compute Jaccard index between samples two samples 

    Args:
        exp1 (Experiment): The first experimental instance 
        exp2 (Experiment): The first experimental instance 
        level (str): The level of computing the overlap between samples, can be any of peptide or protein 

    Returns:
        float: Jaccard index computed with regard to the to provide level
    """
    if level != 'peptide' and level != 'protein': 
        raise ValueError(f"Level: {level} is not supported, currently only level, peptide and protein are supported")
    if level=='peptide':
        return (len(exp1.get_peptides().intersection(exp2.get_peptides())) / len(exp1.get_peptides().union(exp2.get_peptides())))
    if level=='protein':
        return (len(exp1.get_proteins().intersection(exp2.get_proteins())) / len(exp1.get_proteins().union(exp2.get_proteins())))