Concatenate Sequences With Bioperl
Hello, I've got some trivial (I guess) question. I try to write features of a sequence in single output sequences. My code looks like that:
my @features = $seq->get_SeqFeatures(); #GenBank sequence
my $split = Bio::Location::Split->new();
foreach my $feat ( @features ) {
if ($feat->primary_tag eq "exon"){ #exons only
$split->add_sub_Location($feat->location);
}
my $cds= $seq->subseq($split);
my $seq = new Bio::PrimarySeq(-seq => $cds,
-id => 'cds',
-alphabet => 'dna');
$seq_out->write_seq($seq);
}}
Unfortunetely every exon is written as separate sequence. What do I do wrong?
Marek
• 2,768 views
•
link
1 answer
Ok, I manage to solve it by myself.
while ($seq=$seq_in->next_seq){
my @features = $seq->get_SeqFeatures();
my $split = Bio::Location::Split->new();
foreach my $feat(@features){
if ($feat->primary_tag eq "exon"){
$split->add_sub_Location($feats->location)
}}
my $cds = $seq->subseq($split);
my $out_seq = Bio::PrimarySeq->new (-seq => $cds,
-id => "cds");
$seq_out->write_seq($out_seq)
}
Now it's working properly.
• 0 views
•
link
Log in to answer this question.