Any perl script?
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
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.
I wrote a Perl script that will allow you to partition reads below a certain length. Feel free to use or modify it. The link is here:
https://github.com/sestaton/sesbio/blob/master/gene_annotation/filter_seq_by_length.pl
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.
duplicate of: Perl How To Isolate Fasta Sequences With A Range Of Values
see also: How To Filter Multi Fasta By Length??
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