This is a test version of Biostars. For the public version, visit https://www.biostars.org.
extract protein sequence that is 80aminoacids and below

I have a many protein sequences in a file, and I want to extract sequences that has length 80aminoacids and below. can anyone help me with any script? thank you

perl python script

We can then close this question. What do you think?

Hello peacezah!

Questions similar to yours can already be found at:

We have closed your question to allow us to keep similar content in the same thread.

If you disagree with this please tell us why in a reply below. We'll be happy to talk about it.

Cheers!

PS: duplicate

2 answers

You can use this script written in biopython:

from Bio import SeqIO

input_seq_iterator = SeqIO.parse(open("`YOURFASTAFILE.fa`", "rU"), "fasta")
short_seq_iterator = (record for record in input_seq_iterator \
                      if len(record.seq) <= 80)

output_handle = open("`short_seqs.fasta`", "w")
SeqIO.write(short_seq_iterator, output_handle, "fasta")
output_handle.close()

Change YOURFASTAFILE.fa with your file with protein sequences and save the script into file (Ex.: sc.py). Then call the script doing:

python sc.py

In the working directory you will find short_seqs.fasta containing all the seqs equal or less tan 80 aa.

You might wanna adapt this Perl script to your needs: https://github.com/RamRS/myPerlScripts/blob/master/pickLenMtoN.pl

Log in to answer this question.