1
$\begingroup$

I have an assignment for a project to build a tetrapeptides library to screen against some target enzymes in silicon.

I am looking for a script to construct about 160000 tetrapeptide from the 20Amino acids permutations.

I am quite familiar with Bash, but am struggling to get a function to working.

$\endgroup$
5
  • $\begingroup$ No "about" 20^4 (permutation with repetition) is 160_000, no approximation. $\endgroup$ Nov 2, 2021 at 16:39
  • 2
    $\begingroup$ Hi @Ruthy and welcome to Bioinformatics.SE! We try always to be a helpful community forum, but we're most eager to help those willing to help themselves. Could you please update your question to describe why you need to solve this problem? What is the context? Is this for a homework assignment? Or a new research project? What have you tried so far? This forum is not designed to teach the very basics of programming, but if you have specific questions about a bioinformatics program you're trying to write we might be able to point you in the right direction. $\endgroup$ Nov 2, 2021 at 17:20
  • $\begingroup$ Noted, @Matteo. And thank you, Daniel. It's an assignment for a project. I am building a tetrapeptides library to screen virtually against some target enzymes. I am quite familiar with Bash. But, writing a script to achieve that has just been a problem. I hope I can just get a function to work with, then... Thank you, once again. $\endgroup$
    – Ruthy
    Nov 2, 2021 at 18:20
  • 1
    $\begingroup$ Please post example of code that you tried. See also help center and How to Ask. $\endgroup$ Nov 3, 2021 at 12:56
  • $\begingroup$ has to be necessarily in bash? can't be python for example? $\endgroup$
    – JRodrigoF
    Nov 6, 2021 at 17:39

2 Answers 2

2
$\begingroup$

The Python solution is here. IMO Bash definitely isn't a good solution for this calculation.

from itertools import permutations, combinations

one2all ={'A': ('A', 'ALA', 'alanine'),
          'R': ('R', 'ARG', 'arginine'),
          'N': ('N', 'ASN', 'asparagine'),
          'D': ('D', 'ASP', 'aspartic acid'),
          'C': ('C', 'CYS', 'cysteine'),
          'Q': ('Q', 'GLN', 'glutamine'),
          'E': ('E', 'GLU', 'glutamic acid'),
          'G': ('G', 'GLY', 'glycine'),
          'H': ('H', 'HIS', 'histidine'),
          'I': ('I', 'ILE', 'isoleucine'),
          'L': ('L', 'LEU', 'leucine'),
          'K': ('K', 'LYS', 'lysine'),
          'M': ('M', 'MET', 'methionine'),
          'F': ('F', 'PHE', 'phenylalanine'),
          'P': ('P', 'PRO', 'proline'),
          'S': ('S', 'SER', 'serine'),
          'T': ('T', 'THR', 'threonine'),
          'W': ('W', 'TRP', 'tryptophan'),
          'Y': ('Y', 'TYR', 'tyrosine'),
          'V': ('V', 'VAL', 'valine'),
          'X': ('X', 'GLX', 'glutaminx'),
          'Z': ('Z', 'GLI', 'glycine'),
          'J': ('J', 'NLE', 'norleucine'),
          'U': ('U', 'CYC', 'cysteinc')}
myprotein = [x for x in one2all.keys()]        
tetrapeps = combinations(myprotein,4)
peptide = []
count = 0
for x in list(tetrapeps):
    peptide.append(''.join(x))
for tetra in peptide:    
    permpeptides = list(permutations (tetra))
    for i in permpeptides:
        count +=1
        print (''.join(i))

I get 255024 permutations so more than the estimate of 160000, however the code is correct (please see Validation below).

Truncated output

.... JUXV UVXJ UVJX UXVJ UXJV UJVX UJXV VZJU VZUJ VJZU VJUZ VUZJ VUJZ ZVJU ZVUJ ZJVU ZJUV ZUVJ ZUJV JVZU JVUZ JZVU JZUV JUVZ JUZV UVZJ UVJZ UZVJ UZJV UJVZ UJZV XZJU XZUJ XJZU XJUZ XUZJ XUJZ ZXJU ZXUJ ZJXU ZJUX ZUXJ ZUJX JXZU JXUZ JZXU JZUX JUXZ JUZX UXZJ UXJZ UZXJ UZJX UJXZ UJZX

I cut and paste the amino dictionary from here (I wasn't going to write it by hand), AminoAcid.py by Pasteur.


Validation

The theoretical number of permutations from 4 samples of 20 amino acids is

116280

However, the amino acid chart I used comprised 24 amino acids (I just copied and pasted it). The theoretical number for 24 amino acids is therefore:

255024

This was the number observed in the output of the above code and validated the calculation.

A permutations calutation can be performed online here

I am not sure how the expected output of 160000 was derived but suspect it was a guess.


The permutation equation is as follows, the output of this equation and the code above coincide,

$$ P_{n, r}=\frac{n !}{(n-r) !}$$

n = no. amino acids

r = size of oligopeptide


Permutation by repetition

If the permutation by repetition equation is sought (comment below). The code is:

from itertools import product
myprotein = [x for x in one2all.keys()]
print(len([p for p in product(myprotein, repeat=4)]))

for 20 amino acids this is:

160000

for 24 amino acids:

331776

$\endgroup$
4
  • $\begingroup$ I think your calculations assume permutation without replacement. If you assume replacement occurs (i.e. an amino acid can occur more than once in a tetrapeptide), then the expected number of unique tetrapeptides is 20^4 = 160,000. $\endgroup$
    – acvill
    Aug 6, 2022 at 20:34
  • 1
    $\begingroup$ Firstly thanks for your answer @acvill. However, the equation you have used is permutation with repetition not the permutation equation. The question asked for just permutations. I've added the permutation equation below the answer and the permutation by repetition code below the equation. $\endgroup$
    – M__
    Aug 7, 2022 at 2:11
  • 1
    $\begingroup$ you are correct that I did not use the permutation equation. From what I can tell, your approach is also more efficient and readily understood. However, it seems that there is a disconnect between the language that OP used ("permutations") and the question they are actually asking, which I read as "How to generate all 160,000 tetrapeptides?" It seems odd that a peptide library built for an enzymatic screen would exclude elements that have repeated residues, though, since this question is now months old, I don't expect we'll get any clarification from OP $\endgroup$
    – acvill
    Aug 7, 2022 at 13:00
  • 1
    $\begingroup$ Thanks @acvill. Now you raise the biological perspective its makes sense. I approached this from stats theory (ad infinitum) and the 'permutation equation' means only one thing. However, from a molecular biological perspective the permutation equation also means only one thing, as you've pointed out, but its a completely different equation. The OP's lecturers should have known this difference however. Epidemiology was one field where the perspective between biologists and maths/stats resulted in some very famous errors (I will avoid details). Anyway upvoted, thanks. $\endgroup$
    – M__
    Aug 7, 2022 at 18:00
1
$\begingroup$

Here's a bash solution using brace expansion and the single-letter codes for the 20 common amino acids:

aalist=D,E,K,R,H,N,Q,S,T,P,G,A,V,I,L,M,C,F,Y,W
eval printf '"%s\n"' {"$aalist"}{"$aalist"}{"$aalist"}{"$aalist"}

This prints 160,000 lines, one for each tetrapeptide.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.