I have been using the module use Bio::DB::Fasta to access fasta files (documentation here:https://metacpan.org/pod/Bio::DB::Fasta#OBJECT-METHODS). I find that this is much fasta than using Samtools for extracting positions from a fasta file. However, I was wondering if anyone knows what happens if a query includes a position beyond the max length of the fasta.
Today, in a query, I tried accessing a position in the fasta which is beyond the maximum position in the fasta. However, the method did not give an error in this case. My fasta file contains 0/1 bases and the output returned was "1". I was wondering if this is an error or in fact it is giving a valid output but for the wrong position. I tried looking through the documentation but could not find any information about the error codes.
My code is as follows:
use strict;
use warnings;
use Bio::DB::Fasta;
my $maskFile = "1KG_maskfile.fa";
my $db = Bio::DB::Fasta->new($maskFile);
my $chrom = "chr1";
my $start = 300240548;
my $end = 300240548;
my $query = "$chrom:$start-$end";
my $seq = $db->seq($query, $start, $end); # also tried $seq = $db->seq($query);
print $seq, "\n";
Note: In the 1KG_maskfile.fa, the max position is 249224750 (based on character count, excluding header).