我收到以下错误:
“在连接中使用uninitatlize value $ gi<。>或在fillename.pl第32行第4行使用字符串。”
对于所有打开的文件重复此消息,但第一行后第5行换行。
我无法确定如何修复它!我打开的文件是标准的fasta文件,格式如下,第一行包含序列信息,后面的行是序列。 这是我的代码
#!/usr/bin/perl
use strict;
use warnings;
#open files from data directory
opendir my $data_dir, "data" or die "Unable to open directory!";
my @files = readdir $data_dir; #reading files into array
#Taking only files with .fa extention
my @fa_files = grep /\.fa$/, @files;
my @sorted_fa_files = sort @fa_files;
#Taking each .fa and reading description line
foreach my $filename (@sorted_fa_files) {
open my $filehandle, "<", "data/$filename" or die "Unable to open file!";
while ( my @file_contents = <$filehandle> ) { #setting aray to contain all file contents
chomp @file_contents;
print "filename: $filename\n";
my $description_line = shift @file_contents; #setting array to contain description line only
my $join_seq = join "", @file_contents;
#extracting description line contents individually
my @description_parts = split /[\|\.]/, $join_seq;
foreach (@description_parts) {
my $gi = $description_parts[1];
my $accession_id = $description_parts[3];
my $version = $description_parts[4];
my $seq_description = $description_parts[5];
print "gi number: $gi\n";
}
}
}