in reply to BioPerl: Annotate mismatches in an alignment
I've no idea about the Bio stuff but here's a way to compare the alignments by XOR'ing them. Identical characters XOR'ed together result in NULL (\x00) so look for non-NULLs to spot where they differ. I use a regex match with a zero-width look-ahead so that pos finds that the regex pointer is looking at the mis-aligned character, not the one behind it. Offsets in strings are zero-based in Perl and note that your last mis-alignment is at character 13, not 12.
$ perl -Mstrict -Mwarnings -E ' my $ref = q{AATTTGGGCTACT}; my $qry = q{AAATTCGGCTACA}; my $xor = $ref ^ $qry; my @offsets; push @offsets, pos $xor while $xor =~ m{(?=[^\x00])}g; say join q{ }, map { ( $_ + 1 ) . substr $qry, $_, 1 } @offsets;' 3A 6C 13A $
I hope this is helpful
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: BioPerl: Annotate mismatches in an alignment
by r36atd (Initiate) on Oct 03, 2014 at 13:26 UTC |