in reply to Print the data following few specific lines in perl
The code below reads into two hashes the provided sequences depending on whether they have pair info or not at the descriptor portion of their corresponding records, writing each one of these hashes into a file is left as an exercise for the OP..
use strict; use warnings; use Bio::SeqIO; my $file = "FastA.txt"; my $seq_obj = Bio::SeqIO->new(-file =>"<$file",-format=>'fasta',); my %seqPair; my %seq_NoPair; while(my $seq = $seq_obj->next_seq){ #iterate through records if($seq->desc =~ /.*?pair.*?/i){ $seqPair{$seq->id}=$seq->seq; }else{ $seq_NoPair{$seq->id}=$seq->seq; } } #use Data::Dump qw(pp); #print pp \%seqPair; #print pp \%seq_NoPair;
|
---|