我尚且处于生物信息学的小白状态,前两天刚学习了perl的基础语法,之后通过对“Begin Perl for Bioinformatics ”书籍的学习,将生物信息学的基础数据处理和perl语言的编程有了基础的知识框架和应用了解。
一下是在学习过程中对DNA的基本信息统计写的一串小代码,之后可能会将自己在学习过程中发现的一些实用小工具整合成pm包,方便以后使用:
use warnings;
use strict;
my $filename;
my @DNA;
my $DNA;
# main:read the DNA file
sub clean_data{
$filename = <STDIN>;
chomp $filename;
unless(open(DNAFILE,$filename)){
die "Can't read the file and I'm exiting!\n";
}
@DNA = <DNAFILE>;
close DNAFILE;
print "Have read the file sucessfully!\n";
# modify the base sequence
$DNA = join('',@DNA);
$DNA =~ s/\s//g;
return $DNA;
}
# the base number counter and percentage analysis
sub base_counter {
my
@DNA = split('',$DNA);
my $count_of_A = 0;
my $count_of_T = 0;
my $count_of_C = 0;
my $count_of_G