#!/usr/bin/perl -w
# @Date : 2017-03-28 00:41:52
# @Author : Shixiang Wang (w_shixiang@163.com)
# @Link : http://blog.sciencenet.cn/home.php?mod=space&uid=3238131
# exe 4-2 stores an integer in a variable and then prints it out
$integers = 1234;
print $integers;
# exe 4-3 Print DNA in lowercase; print the DNA in uppercase
$DNAs = 'ACGTacgtACTCgtac';
$DNAs =~ tr/acgt/ACGT/;
print $DNAs,"\n";
$DNAs =~ tr/ACTG/acgt/;
print $DNAs,"\n";
# exe 4-4 Use the string directives \U and \L for upper- and lowercase.
$DNAs1 = 'ACGTacgtACTCgtac';
print "\U$DNAs1\n";
print "\L$DNAs1\n";
# exe 4-5 1 Reverse transcribe RNA to DNA
$RNAs = 'ACGUacGuugac';
$RNAs =~ tr/uU/tT/;
print $RNAs,"\n";
# exe 4-5 2
$RNAs = 'ACGUacGuugac';
$RNAs =~ s/u/t/g;
$RNAs =~ s/U/T/g;
print $RNAs,"\n";
# exe 4-6
# Read two files of data, and print the content of the first followed by the contents of the second.
# I will use pep data twice.
$File_name = 'NM_021964fragment.pep';
open(PROTEINFILE, $File_name);
@protein = <PROTEINFILE>;
close PROTEINFILE;
$File_name = 'NM_021964fragment.pep';
open(PROTEINFILE, $File_name);
@protein1 = <PROTEINFILE>;
print @protein,@protein1;
close PROTEINFILE;
# exe4-7
# Write a program to read a file, and then print its lines in reverse order, the last line first.
print "\n\n\n";
print $protein1[2];
print $protein1[1];
print $protein1[0];
# method 2
print "method2\n";
while(@protein1){
print pop @protein1;
}
# method 3
print "method3\n";
print reverse @protein
Beginning Perl for Bioinformatics-chapter4 习题
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- A Mutable Grammar For Perl 6 Rules Rules 就像 perl5的 regexe...
- Day 12 神句文档 The team contends that these bear more than a...