求小修改一下,小程序
我这有个perl的程序,比较简单,是统计字符百分比的程序。我的文件全是由ACGT四个字母组成的,除此之外没有别的字母,共18亿个字母。现在的问题是运行这个代码,报错:out of memory。就是内存不够用,怎么修改一下啊?文件中字母少的时候是可以用的。求!#!/usr/bin/perl
use strict;
use warnings;
open IN,"1.txt";
open OUT,">2.txt";
my $dna = <IN>;
my $revcom = $dna;
$revcom =~ tr /acgt/ACGT/;
my $gc = $revcom =~ tr/GC//;
my $gc_content = sprintf( "%.2F", $gc / length($revcom) * 100 );
my $at = $revcom =~ tr/AT//;
my $at_content = sprintf( "%.2F", $at / length($revcom) * 100 );
my $ALL = $revcom =~ tr/ACGT//;
my $A = $revcom =~ tr/A//;
my $C = $revcom =~ tr/C//;
my $G = $revcom =~ tr/G//;
my $T = $revcom =~ tr/T//;
print OUT "GC数量:$gc\n";
print OUT "GC含量:${gc_content}%\n";
print OUT "AT数量:$at\n";
print OUT "AT含量:${at_content}%\n";
print OUT "A总数: $A\n";
print OUT "C总数: $C\n";
print OUT "G总数: $G\n";
print OUT "T总数: $T\n";
print OUT "ACGT总数: $ALL\n";
close OUT;
close IN;
这个程序的问题,是我的数据在18亿个字符,提示信息是是超出内存(out of memory).