Hi
I have a fasta file containing a number of sequences.
I would like to extract only the sequences that are of a specific length (lets's say >10 nt).
The sequences are wrapped with new lines, so when trying to read into an array, each line becomes an element. How can I removed these? I have tried join, but it also removes the newline between sequences and puts all of it into single string. How do I separate each sequence into an element or string?
The file looks something like this:
>NM_001 Homo sapiens ADA2 (CECR1)
GATCCAA
>NM_002 Homo sapiens IKBKG
GGAGGTCTTTAGCTTTAGGGAAACCC
Output should be only the second sequence in this case.
#!/usr/bin/perl -w
#open the fastfile Genes.fasta
open (GENES, "Genes.fasta") or die "Could not open file";
chomp (@seq = <GENES>);
$seq = join ("\n", @seq);
$lengthseq = length $seq;
#min length of the seq
$minlength = 10;
#if length is over a certain size, print
if ($lengthseq > $minlength){
print $seq;
}
else {print "No sequence is over $minlength;"
}