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); } } }