How to count amino acid in a protein sequence using Python program

How to count amino acid in a protein sequence using Python program

In this article, we are going to learn how python can be useful in finding amino acid in a given protein sequence. Before reading this article you must know about FASTA format and single letter code for the amino acid. (Click here  FASTA format)

Here, we will learn how can we find the total length of a sequence and find the number of the specific amino acid in a sequence. For finding the FASTA format of a protein you can use NCBIUniProt, or protein data bank (RSCB).

Example: The given sequence of amino acid is:

>sp|Q14533|KRT81_HUMAN Keratin, type II cuticular Hb1 OS=Homo sapiens OX=9606 GN=KRT81 PE=1 SV=3

MTCGSGFGGRAFSCISACGPRPGRCCITAAPYRGISCYRGLTGGFGSHSVCGGFRAGSCGRSFGYRSGGVCGPSPPCITTVSVNESLLTPLNLEIPNAQCVKQEEKEQIKSLNSRFAAFIDKVRFLEQQNKLLETKLQFYQNRECCQSNLEPLFEGYIETLRREAECVEADSGRLASELNHVQEVLEGYKKKYEEEVSLRATAENEFVALKKDVDCAYLRKSDLEANVEALIQEIDFLRRLYEEEILILQSHISDTSVVVKLDNSRDLNMDCIIAEIKAQYDDIVTRSRAEAESWYRSKCEEMKATVIRHGETLRRTKEEINELNRMIQRLTAEVENAKCQNSKLEAAVAQSEQQGEAALSDARCKLAELEGALQKAKQDMACLIREYQEVMNSKLGLDIEIATYRRLLEGEEQRLCEGIGAVNVCVSSSRGGVVCGDLCVSGSRPVTGSVCSAPCNGNVAVSTGLCAPCGQLNTTCGGGSCGVGSCGISSLGVGSCGSSCRKC

This is a fast sequence of  HUMAN keratin (from UniProt) in this article we are working with a small segment of above FASTA.

Below is the Python code given for this:

# input sequence
given_sequence = "MTCGSGFGGRAFSCISACGPRPGRCCITAAPYRGISCYRGLTGGFGSH"

# length of given sequence
total_amino_acid = len(given_sequence)

# find count of 'M' in the given sequence
# using count method of string
MET_count= given_sequence.count('M')

# find count of 'G' in the given sequence
# using count method of string
GLY_count = given_sequence.count('G')

print('Total amino acid in the sequence are-->',total_amino_acid)
print('Total MET in the sequence-->', MET_count)
print('Total GLY in the sequence-->', GLY_count)

Output:

Total amino acid in the sequence are--> 48
Total MET in the sequence--> 1
Total GLY in the sequence--> 11

2 Comments

Leave a Reply

Your email address will not be published.

📢 Need further clarification or have any questions? Let's connect!

Connect 1:1 With Me: Schedule Call


If you have any doubts or would like to discuss anything related to this blog, feel free to reach out to me. I'm here to help! You can schedule a call by clicking on the above given link.
I'm looking forward to hearing from you and assisting you with any inquiries you may have. Your understanding and engagement are important to me!

This will close in 20 seconds