在perl中怎么遍历哈希

有一个fasta格式的文件,怎么创建一个id和序列对应的哈希,并对哈希进行遍历,结果输入到一个文件中

请先 登录 后评论

1 个回答

omicsgene - 生物信息
擅长:重测序,遗传进化,转录组,GWAS

不明白你要干啥,你是有一些基因ID,想把对应的基因序列提取出来到一个新文件,还是只是把fasta序列中的ID提取出来?问问题要明确,不要让人歧义:


perl遍历hash:



while(($key, $value) = each(%HASH)) {
    # do something with $key and $value
}
#-----------------------------
foreach $key (keys %HASH) {
    $value = $HASH{$key};
    # do something with $key and $value
}
#-----------------------------
# %food_color per the introduction
while(($food, $color) = each(%food_color)) {
    print "$food is $color.\n";
}
# Banana is yellow.
#
# Apple is red.
#
# Carrot is orange.
#
# Lemon is yellow.
 
foreach $food (keys %food_color) {
    my $color = $food_color{$food};
    print "$food is $color.\n";
}


处理fasta序列可以使用bioperl:


文章链接:https://www.omicsclass.com/article/179


请先 登录 后评论
  • 1 关注
  • 0 收藏,6047 浏览
  • 小学生 提出于 2018-07-24 22:17

相似问题