How can I fix it?
By giving better examples :) I had assumed on the basis of the sample supplied, that the overlapping sections were identical as in both cases supplied. I think javafans make that same assumption.
You'd need to accumulate the overlaps in a third array in the while, and then add another for loop to process them is the same way as @heads & @tails. (There obviously scope there for making the for loop a subroutine.
I'm done for today, but I'll be back tonight.
| [reply] [Watch: Dir/Any] |
#! perl -slw
use strict;
use Data::Dump qw[ pp ];
my $k = 15;
my %repo = (
"readA" => "AAACATGAAAAGAAATGATGAAACAGA",
"readB" => "AAATCATGAAACAGAGCCTCATCTCCC ",
);
my @order = ( "readB_1","readA_2");
#my $k = 25;
#my %repo = (
# "readA" => "GCTGAGGCAGGAGAATTGCTTGAACCTGGGAGGCA",
# "readB" => "TACTCAGGAGGCTGAGGCAGGAGAATTGCTTGAAC",
# "readC" => "GCTGAGGCAGGAGAATTGCTTGAACTTAGGGGATG",
# "readD" => "TACTCGGGAGGCTGAGGCAGGAGAATTGCTTGAAC",
#);
#my @order = ( "readA_1", "readB_2", "readC_1", "readD_2");
sub muster {
local $^W;
my( $bits ) = @_;
my $muster = '';
for my $p ( 0 .. length( $bits->[0] )-1 ) {
my %uniq;
++$uniq{ substr $bits->[ $_ ], $p, 1 } for 0 .. $#$bits;
if( keys %uniq > 1 ) {
$muster .= '(' . join( ',', keys %uniq ) . ')';
}
else {
$muster .= each %uniq;
}
}
return $muster;
}
my( @heads, @bodys, @tails );
while( @order ) {
my( $s1, $p1, $s2, $p2 ) = map split( '_', shift @order ), 1 .. 2;
( $s1, $s2 ) = ( $s2, $s1 ) if $p1 > $p2;
push @heads, substr $repo{ $s2 }, 0, length( $repo{ $s2 } ) - $k;
push @bodys, substr $repo{ $s2 }, -$k;
push @tails, substr $repo{ $s1 }, $k;
push @bodys, substr $repo{ $s1 }, 0, $k;
}
my $head = muster( \@heads );
my $body = muster( \@bodys );
my $tail = muster( \@tails );
print $head, $body, $tail;
__END__
TACTC(A,G)GGAGGAGAATTGCTTGAACCTGGGAGGCA(T,C)T(A,G)GG(A,G)G(A,G)(T,C)(A
+,G)
TACTC(A,G)GGAGGCTGAGGCAGGAGAATTGCTTGAAC(T,C)T(A,G)GG(A,G)G(A,G)(T,C)(A
+,G)
AAACATGAAAAGAAAT(C,G)ATGAAACAGAGCCTCATCTCCC
AAACATGAAAAGAAAT(G,C)ATGAAACAGAGCCTCATCTCCC
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [Watch: Dir/Any] [d/l] |