[Bioperl-l] a problem when using the Bio::DB::Fasta
Guifeng Wei
guifengwei at gmail.com
Tue Aug 24 02:44:57 UTC 2010
Hi,
i came across a problem when i use the Bio::DB::Fasta modules of
BioPerl. The aim i want to arrive at is to extract the subsequences
accoording to the *.bed files which are the C.elegans genomic sequnece
annotation.
when i tried to run the scripts i wrote, the error message was coming, as
follows:
Can't call method "seq" on an undefined value at bed_to_fasta.pl line 28,
<IN> line 1.
so, ask for favor to slove this problem.
Here is my perl scripts.
#!/usr/bin/perl -w
# Purpose: extract sequences from genomic sequences
use strict;
use Bio::DB::Fasta;
open(IN,$ARGV[0]) || die "sorry, the program cannot open the .bed file, plea
check it. \n";
my $db = Bio::DB::Fasta->new( '/home/wgf/elegans190.dna/' );
# The dir ...../elegans190.dna/ includes 6
files:chrI,chrII,chrIII,chrIV,chrV,chrX,
#each stands for the sequences from the coressponding chromosome.
while(<IN>){
chomp $_;
my @bed=split(/\s+/, $_ );
my $chr_id=$bed[0];
my $start=$bed[1];
my $end=$bed[2];
my $seq_name=$bed[3];
my $strand=$bed[5];
my $segment = $db->seq( $chr_id, $start=>$end );
print ">",$seq_name,"_",$chr_id,":",$start=>$end;
print "$segment\n";
}
close(IN);
More information about the Bioperl-l
mailing list