我有一个格式如下所示的大文本文件 -
ID SNP
FT SNP 433
FT /note="refAllele: T SNPstrains: 7083_1#5=C 7414_8#8=C 7480_8#49=C "
FT /colour=1
FT SNP 442
FT /note="refAllele: T SNPstrains: 7065_8#2=C 7065_8#94=C 7083_1#2=C 7083_1#3=C 7083_1#41=C 7083_1#42=C 7083_1#43=C "
FT /colour=1
FT SNP 460
FT /note="refAllele: T SNPstrains: 7564_8#14=C "
FT /colour=1
FT SNP 703
FT /note="refAllele: G SNPstrains: 7521_5#39=A (non-synonymous) (AA Ala->Thr) "
FT /colour=2
FT SNP 937
FT /note="refAllele: G SNPstrains: 7414_8#30=T (non-synonymous) (AA Val->Leu) "
FT /colour=2
FT SNP 1269
FT /note="refAllele: G SNPstrains: 7480_7#22=A (synonymous) 7480_7#62=A (synonymous) "
FT /colour=3
FT SNP 1804
FT /note="refAllele: T SNPstrains: 7414_7#66=A (non-synonymous) (AA Ser->Thr) 7414_8#44=A (non-synonymous) (AA Ser->Thr) 7521_6#54=A (non-synonymous) (AA Ser->Thr) "
FT /colour=2
这是我使用的代码 -
$file="input file";
open IN, "$file";
open OUT, ">output file";
print OUT "Coordinate No of Strains AA Change\n";
while(<IN>){
if(m/^FT\s+SNP\s+(\d+)/){
$SNP=$1;
}elsif(m/^FT\s+\/note="(.*)"/){
$line=$1;
$count = ($line =~ tr/=/=/);
$line =~ m/\((AA \w+->\w+)\)\s*$/;
$change = $1 || "";
}elsif(m/^FT\s+\/colour=(\d+)/){
print OUT "$SNP $count $change\n" if $cod{$1} eq "non";
}
}
目的是有一个类似于下面的输出文件(对于文本文件的上述部分)
Coordinates No of Strains AA Change
703 1 AA Ala->Thr
937 1 AA Val->Leu
1804 3 AA Ser->Thr
但是,当我将代码应用于文本文件时,我收到一个错误:Use of uninitialised values ($count or $change) in concatenation (.) or string at line 23。有问题的行是
print OUT "$SNP $count $change\n" if $cod{$1} eq "non";
该错误是指包含的行
FT /colour=2
即,显示非同义突变的行,例如示例文本中的第 13 行。
请注意,我是编程新手,大部分代码不是我编写的。任何帮助,将不胜感激!
提前谢谢了。