http://www.perlmonks.org?node_id=1136388

Sosi has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone! I'm trying to get intergenic sequences for many genebank files. To do so I'm trying something like this:

use strict; use warnings; use autodie; use Data::Dump; use Data::Dumper; use Bio::SeqIO; STDOUT->autoflush(1); my $gbffpath='C:\My gbff path'; opendir(DIR, "$gbffpath"); my @files= grep {/\.gbff$/ } readdir(DIR); closedir(DIR); my $featc=0; foreach my $gbfffile (@files){ my $in = Bio::SeqIO->new(-file=>"<$gbffpath\\$gbfffile", -format=> +"genbank"); my @allpos; my $obj = $in->next_seq(); my @features = $obj->get_SeqFeatures(); my @two = shift @features; foreach my $fefe (@features){ my $pt = $fefe->primary_tag(); if ($pt eq "CDS" or $pt eq "rRNA" or $pt eq "tRNA") { $featc++; last if $featc==4; push @two, $fefe; my $starti= $two[1]->start(); my $endi; my $end; my $start; if($two[0]->primary_tag() eq "source"){ $endi = $starti; $end = $endi +1; $start = $starti -1; shift @two; } else{ $endi = $two[0]->end(); $end = $endi +1; $start = $starti -1; #do something else # change $start to be -21 nucleotides # my $subseq = $obj->subseq($end,$start) unless ($end> +=$start); my $subseq = $obj->subseq($end,$start) unless ($end>=$ +start); shift @two; dd ($gbfffile,$pt,"\$two\[0\]:","endi:$endi","\$two\[1 +\]:","starti:$starti","after:","end:$end","start:$start",$subseq); } } }

However, $subseq always returns undefined and I cannot understand why. If I change that to $obj->seq() the same happens. Can someone please help me?

Edit: this question was cross-posted at https://www.biostars.org/p/152157/.