Can't call method "index_file" on an undefined value at script.pl line ...
0
0
Entering edit mode
9.1 years ago
R ▴ 10

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 • 2.6k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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!!

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1268 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6