This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Can't call method "index_file" on an undefined value at script.pl line ...

I would like to reload a pre-index file in perl which has been previously indexed as following:

./first_script.pl hg19.fa
use Bio::DB::Fasta;

my $db = Bio::DB::Fasta->new($file_fasta);
..

in an another script I would like to re-load the existing indexed file.

./script.pl hg19.fa.index input
#!/usr/bin/perl

use warnings;
use strict;

use Bio::DB::Fasta;

my $fasta_index_file = $ARGV[0];
my $input_file = $ARGV[1];

open(FH,"<$input_file");

my $db->index_file($fasta_index_file);

In the description it says

 Title   : index_file
Usage   : $db->index_file($filename)
Function: (re)loads a sequence file and indexes sequences offsets in the file
Returns : seq offsets in the file
Args    : filename,
           boolean to force reloading a file

but it returns the following error:

Can't call method "index_file" on an undefined value at script.pl line
perl

It would help if you added the line that wrote the created index into the .index file.

Does "my $db = Bio::DB::Fasta->new($file_fasta);" automatically write the index file into the current dir or I am doing sth wrong. When I ran the first script I saw the hg19.fa.index created in the curent dir!!

Something wrong with the BioPerl on my machine - I'm unable to check this out for myself :(

0 answers

No answers yet.

Log in to answer this question.