- 论坛徽章:
- 0
|
本帖最后由 萌情公方 于 2014-07-21 17:03 编辑
现在我想从fasta序列中,每一百个字母作为一行输出,但是我的代码运行的结果总是不对,请大神帮忙看看吧:
源文件
>1 dna:chromosome chromosome:Zv9:1:1:60348388:1 REF
TTCTTCTGGGGAAAGTCTGATTTGATTTATTTCCCTTTTAAGATCAATATTATTAGCCCC
ATGTGTTGAAGAACAAATCTCTCTGTTAAACAGAAATTGGGGGGGAAAATAAACAGGGGG
......
我的结果
1
AAAACTGGGGAAAGTCTGATTTGATTTATTTCCCTTTTAAGATCAATATTATTAGCCCC
ATGTGTTGAAGAACAAATAAAACTGTTAAACAGAAATTGG
GGGGGAAAATAAACAGGGGG
GCAAATAATTCTGACTACAATTAAAAAAAAGATATATTATACTATGCATATCTCCTCTG
TTGTGTTGTAGATAGACG
AGCTGAAAAACTGTGGTCGTTTGATTTTTTCTTTGCATTATT
AAACGCAAATGTAATAAAAATATTAAATTTTGCATTCATATTCATTATAGATGTTGT
TAT
以上只是示例- #!/usr/bin/perl -w
- use strict;
- my $input = shift;
- open (FA,"$input")||die"$!\n";
- $/=">";<FA>;$/="\n";
- while(<FA>){
- chomp;
- my $id=$1 if(/(\w+)\s+(\S+\s)+\w+/);
- $/=">";
- print "$id\n";
- my $seq=<FA>;
- chomp $seq;
- for(my $i=1;$i<=length($seq);$i+=100) {
- my $display .=substr($seq,$i,100)."\n";
- print "$display";}
- }close FA;
复制代码 |
|