def cys_noncys_filter(peptides):
    """ Assigns cys_rank, then separates cys and noncys peptides.
    Collects only peptides from proteins that have at least one cys and one non-cys peptide"""

    # Add cys rank to identify cys peptides
    peptides['cys_rank'] = [
        1 if 'C' in sequence else 0 for sequence in peptides['Sequence']]

    # separate cys and noncys peptides
    cys_peptides = peptides[peptides['cys_rank'] == 1]
    noncys_peptides = peptides[peptides['cys_rank'] == 0]

    # Collect only proteins with at least one cys, one noncys
    common_prots = set(cys_peptides['Proteins']).intersection(
        set(noncys_peptides['Proteins']))
    cys_peptides = cys_peptides[cys_peptides['Proteins'].isin(common_prots)]
    noncys_peptides = noncys_peptides[noncys_peptides['Proteins'].isin(
        common_prots)]

    return cys_peptides, noncys_peptides