【发布时间】:2016-07-06 23:17:17
【问题描述】:
我有一个程序旨在从 multifasta 中提取行并通过 THREADER 运行它们:
#¡/usr/bin/perl
use warnings;
use strict;
use File::Temp qw(tempfile);
my $filename = 'unchar_prot'; #open file
open (my $fh, '<:encoding(UTF-8)', $filename)
or die "Error - cannot open file";
my %id2seq = (); #create a hash
my $seq_id = '';
while (my $line = <$fh>) {
chomp $line;
if ($line =~ /^>(.+)/) { #Find lines starting in >
$seq_id = $1;
} else {
$id2seq{$seq_id} .= $line; #Store seq and ID on hash
}
}
open(my $outfile, '>', 'out.txt') or die
close (my $outfile)
while (my ($seq_id, $seq) = each %id2seq) { #Call key and value from hash
my ($temp_fh, $prot) = tempfile ("tempXXXX", SUFFIX => '.seq'); #create a temporary file
print $temp_fh ">$seq_id\n$seq\n"; #print the 2 lines to the temp file
my ($out_fh, $out) = tempfile("outXXXX", SUFFIX => '.txt'); # create a temporary outfile
system ('nohup threader -p $temp_fh $out_fh cdc6.lst &'); #call threader
open($outfile, '>>', 'out.txt');
print $outfile "$out_fh"; # append the content of the temp out to the main outfile
}
当我尝试运行它时,“我的”会出现很多问题:
“my”变量 $outfile 掩盖了 testfile4.pl 第 22 行同一语句中的早期声明。
“my”变量 $seq_id 掩盖了 testfile4.pl 第 24 行相同范围内的早期声明。
“my”变量 $temp_fh 掩盖了 testfile4.pl 第 26 行同一语句中的早期声明。
“my”变量 $seq_id 掩盖了 testfile4.pl 第 26 行同一语句中的早期声明。
“my”变量 $seq 掩盖了 testfile4.pl 第 26 行同一语句中的早期声明。
testfile4.pl 第 24 行的语法错误,靠近 ") {"
testfile4.pl 第 31 行“}”附近的语法错误
testfile4.pl 的执行由于编译错误而中止。
有人知道这里发生了什么吗?我怎样才能让它运行?
PS 我知道这可能还有很多其他的问题。我是一个初学者,我不需要它整洁或高效,我只需要它工作。
【问题讨论】:
-
凯莉,仅供参考,the timeline。我们不会提出问题,接受帮助,然后删除问题。这不是我们在这里滚动的方式。
-
请看What should I do when someone answers my question?。提示:它没有说 delete your question
-
我意识到这个问题有点愚蠢
标签: perl bioinformatics