RETVAL = newRV_noinc((SV*)returned_av);
OUTPUT:
RETVAL
+
+
+char*
+edlibAlignmentToCigar(unsigned char *alignment, int length(alignment), int format)
EDLIB_TASK_PATH/;
our %EXPORT_TAGS =
- (all => [ @constants, qw/align distance/ ], constants => \@constants);
+ (all => [ @constants, qw/align distance to_cigar/ ], constants => \@constants);
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = ( @{ $EXPORT_TAGS{'constants'} } );
our $VERSION = '0.001';
align($q, $t, $k)->{editDistance}
}
+sub to_cigar {
+ my ($align, $format) = @_;
+ $align = pack 'C*', @$align;
+ $format //= EDLIB_CIGAR_STANDARD();
+ edlibAlignmentToCigar($align, $format);
+}
+
1;
__END__
say "Start locations are: @{$align->{startLocations}}";
say "End locations are: @{$align->{endLocations}}";
say "Alignment path is: @{$align->{alignment}}";
-
+ say "Alignment path (in CIGAR format): ", to_cigar $align->{alignment};
+ say "Alignment path (in extended CIGAR format): ",
+ to_cigar $align->{alignment}, EDLIB_CIGAR_EXTENDED;
=head1 DESCRIPTION
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 11;
BEGIN { use_ok('Text::Levenshtein::Edlib', ':all') };
is_deeply $r->{endLocations}, [6], 'align->{endLocations}';
is_deeply $r->{startLocations}, [0], 'align->{startLocations}';
is_deeply $r->{alignment}, [3, 0, 0, 0, 3, 0, 2], 'align->{alignment}';
+
+my $cigar;
+$cigar = to_cigar $r->{alignment};
+is $cigar, '6M1D', 'to_cigar';
+$cigar = to_cigar $r->{alignment}, EDLIB_CIGAR_EXTENDED;
+is $cigar, '1X3=1X1=1D', 'to_cigar (extended)';