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/.


In reply to Trying to get intergenic sequences using BioPerl by Sosi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.