use strict;
use warnings; 
use Bio::SeqIO;
use Bio::DB::GenBank;
use Bio::SeqFeatureI; 
# you should got some numbers like gi|XXXXX|gb|GU480507.1| from blast result. now we do a sample sequence extraction from NCBI using Bio::DB::GenBank; Please read the module and especially the part you can do something like searching with keywords in entrez
#and we practice a little bit of getting detailed info from genbank files ()
#and, please don't complain if you can't retrieve anything while not having any internet!!!! 

#first define something accession.version numbers 
my @array=("rs48074623");
#build this virtual machine thing to get ready to retrieve sequences
my $gb = Bio::DB::GenBank->new();
#prepare a file to accept the sequences and save as genbank file
my $out = Bio::SeqIO->new(-file => ">output.gb" ,-format => 'genbank');
foreach my $ver (@array)
{  
#we copy part of code: get_Seq_by_version
my $seq = $gb->get_Seq_by_version($ver); 
#have a look at sequences
print $seq->id, " ", $seq->description,"\n"; 
#save it;
$out->write_seq($seq); 


#now we try to see something that describes the sequence information in details, and for that we need the packages Bio::SeqFeatureI; Also, just copy the monster code like following, it will spill all the beans and modify it when you need
foreach my $feat ( $seq->get_SeqFeatures() ) {
       print "Feature from ", $feat->start, "to ",
	       $feat->end, " Primary tag  ", $feat->primary_tag,
	          ", produced by ", $feat->source_tag(), "\n";

       if( $feat->strand == 0 ) {
		    print "Feature applicable to either strand\n";
       } else {
          print "Feature on strand ", $feat->strand,"\n"; # -1,1
       }

       print "feature location is ",$feat->start, "..",
          $feat->end, " on strand ", $feat->strand, "\n";
       print "easy utility to print locations in GenBank/EMBL way ",
          $feat->location->to_FTstring(), "\n";

       foreach my $tag ( $feat->get_all_tags() ) {
		    print "Feature has tag ", $tag, " with values, ",
		      join(' ',$feat->get_tag_values($tag)), "\n";
       }
	    print "new feature\n" if $feat->has_tag('new');
	    # features can have sub features
	    my @subfeat = $feat->get_SeqFeatures();
	 }

}
