- 论坛徽章:
- 0
|
写了一个,你试试- #!/usr/bin/perl
- use strict;
- use warnings;
- my @allcdss=(2,8,12,16,18,25,28,35,80,90,102,110,120,125);
- my @allcuts;
- {
- local $/ = \100;
- my ($min,$max) = (0,0);
- my $left = '';
- while (defined (my $line = <DATA>)) {
- $line =~ s/\n//g;
- $min = $max - length($left);
- $max = $max + length($line);
- $line = $left . $line;
-
- print "$min $max \n";
- my @allcdss_tmp = grep { $_ > $min && $_ <= $max } @allcdss;
- if (@allcdss_tmp) {
- my $template = cut2fmt($min,@allcdss_tmp);
- print $template,"\n";
- my @fields = unpack($template,$line);
- if ($allcdss_tmp[-1] != $max) {
- $left = pop @fields;
- }
- push @allcuts,@fields;
- } else {
- $left = $line;
- next;
- }
-
- last if $allcdss_tmp[-1] == $allcdss[-1];
- }
- }
- print "@allcuts\n";
- sub cut2fmt {
- my $minpos = shift;
- my(@positions) = @_;
- print "@positions\n";
- my $template = ($positions[0] != $minpos) ? 'x' . ($positions[0] - $minpos - 1) : '';
- my $cut_string = 1;
-
- my $lastpos = shift @positions;
- foreach my $place (@positions) {
- if ($cut_string % 2 == 1) {
- my $dist = $place - $lastpos;
- $template .= ($dist > 0) ? 'A' . ($dist + 1) : '';
- } else {
- my $dist = $place - $lastpos;
- $template .= ($dist > 0) ? 'x' . ($dist - 1) : '';
- }
- $lastpos = $place;
- $cut_string++;
- }
-
- $template .= 'A*';
- return $template;
- }
- __DATA__
- AGAACAATATCTCTGATGAACATAGATGCAAAAATCCTCAACAACATACTAGCTAAATAATCCAACAACT
- CATCAAAAGGATAATACACCATGATCAAGTGGGTTCATCCTAGAGATGCAGGGATGGTTTAACACATGCA
- AGTCAATAAATATGATACATCACATAAACGGAATTAAAACAAAAACCACATGATCATCTCAATAGATGCA
- GGAAAAGCATTTGATAAAATCTAGCAGCCCTTTATGATAAAACCCCTCAAGAAACTAGGTAAAGAAGGGG
复制代码 |
|