Concatenate Sequences With Bioperl
1
0
Entering edit mode
11.5 years ago
maczerek ▴ 40

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

bioperl • 2.5k views
ADD COMMENT
4
Entering edit mode
11.5 years ago
maczerek ▴ 40

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.

ADD COMMENT

Login before adding your answer.

Traffic: 1469 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6