24小时热门版块排行榜    

查看: 854  |  回复: 3

xmy0523

新虫 (小有名气)

[交流] 【求助】请教一个Perl语言的编程,谢谢! 已有2人参与

请教各位大侠,下面的第2题怎么做啊?是Bioinformatics, biocomputing and Perl那本书上的,第4章的题目。 谢谢!
1. Define a hash called %genomespeak, which associates the following abbreviations
with the phrase in parentheses: AA (amino acid), BAC (bacterial artificial
chromosome), BLAST (basic local alignment search tool), cDNA (complementary
DNA), DNA (deoxyribonucleic acid), EST (expressed sequence tag),
Exercises 69
FISH (fluorescence in situ hybridization), mRNA (messenger RNA), rDNA
(recombinant DNA), RNA (ribonucleic acid), STS (sequence tagged site), SNP
(single nucleotide polymorphism) and YAC (yeast artificial chromosome)7.
2. Create a small file, called abbrevs, with the following contents:
DNA
SNP
rDNA
AA
BLAST
RNA
YAC
mRNA
Write a program to process abbrevs and display the correct phrase from
the %genomespeak hash for each abbreviation.
回复此楼
奋斗并快乐着!
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

holmescn

金虫 (正式写手)

★ ★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
余泽成(金币+3):谢谢参与应助! 2011-01-05 20:36:14
这个很easy的题目阿,你到底有没有认真看书阿。
CODE:
#!/usr/bin/perl -w

use strict;

my %genomespeak = ("AA" => "amino acid", "BAC" => "bacterial artificial chromosome",
    "BLAST" => "basic local alignment search tool", "cDNA" => "complementary DNA",
    "DNA" => "deoxyribonucleic acid", "EST" => "expressed sequence tag",
    "FISH" => "fluorescence in situ hybridization", "mRNA" => "messenger RNA",-
    "rDNA" => "recombinant DNA", "RNA" => "ribonucleic acid",-
    "STS" => "sequence tagged site", "SNP" => "single nucleotide polymorphism",
    "YAC" => "yeast artificial chromosome");

open(IN, "< abbrevs") or die("$!");

while(){
    chop;
    print($genomespeak{$_}, "\n");
}
close(IN);

2楼2011-01-05 09:41:07
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xmy0523

新虫 (小有名气)

引用回帖:
Originally posted by holmescn at 2011-01-04 18:41:07:
这个很easy的题目阿,你到底有没有认真看书阿。
[code]
#!/usr/bin/perl -w

use strict;

my %genomespeak = ("AA" => "amino acid", "BAC" => "bacterial arti ...

怎么运行了说: No such fiel or directory at xxx.plx line 13?  就是open 那行。
我是初学者,刚看完第4章,你用到的几个命令都还没学过啊。努力看书去。非常谢谢啊!
奋斗并快乐着!
3楼2011-01-05 10:56:01
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

holmescn

金虫 (正式写手)

★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
余泽成(金币+1):辛苦了! 2011-01-07 11:10:48
把最后给的那个缩写列表保存到abbrevs这个文件里,然后再试

煤电过的应该就只有chop这个吧。这个是去掉末尾的回车的。
4楼2011-01-05 22:44:47
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 xmy0523 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见