非ATGC行的删除
有如下的数据结构,我们知道DNA中碱基只有四种,ATGC,但是因为测序过程中的种种原因,可能出现R,M等情况,也就是所谓的兼并碱基,可参考前面的标准核酸表。如下面中第三行中有一个R,但是我们在分析的过程中,希望把这样的行给去掉。
#!/usr/bin/perl# Only remain ATGC line and delete other lineuse strict;use warnings;my @informations;my $information;my @cout=qw/1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19/;my $cout;my $flag=0;open(WITH,"without-without_repeat_information.txt")||die("can not open!");open(OUT,">OnlyATGC.txt");while(<WITH>){chomp;@informations=split;foreach $cout(@cout){if ($informations[$cout] =~ /[^ATGC]/){$flag=$flag+1;}else{next;}}if($flag==0){print OUT "$_\n"; }else{$flag=0;}}