Rosalind: Calculating Protein Mass

Python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
def protein_mass(sequence: str) -> float:
    """
    Calculates the mass of a protein sequence.

    Args:
        sequence (str): The protein sequence.

    Returns:
        float: The mass of the protein.

    Examples:
        >>> protein_sequence = "SKADYEK"
        >>> mass = protein_mass(protein_sequence)
        >>> print(mass)
        821.392
    """
    mass = 0
    for amino_acid in sequence:
        mass += MONOISOTOPIC_MASS_TABLE[amino_acid]
    return mass
0%