bontus has asked for the wisdom of the Perl Monks concerning the following question:
My current task involves string alignments, for which I found a very promising C/C++ library that I would like to call from my Perl code. The library can be found here: https://github.com/mengyao/Complete-Striped-Smith-Waterman-Library
and an example for C++ usage can be found here:
https://github.com/mengyao/Complete-Striped-Smith-Waterman-Library/blob/master/src/example.cpp
What I had in mind is, to create either a subroutine or a separate module that passes the sequences (query and ref in the example) to the C function. Several variables can then store the returned results. Unfortunately, I do not even get the first part running with only one variable being returned (disclaimer: I am not a C programmer and Inline sounds cool, but is also new to me).
Based on the C++ package, I wrote the following piece to get a general understanding of what is going on, which results in "Undefined subroutine &main::do_SSW called at ./somePerl.pl line 8.". FYI, the CIGAR string is a compact format to display alignments, see:
http://genome.sph.umich.edu/wiki/SAM#What_is_a_CIGAR.3F
Many thanks in advance, any help is greatly appreciated.#!/usr/bin/perl use warnings; use Inline CPP => Config => AUTO_INCLUDE => '#include "ssw_cpp.h"'; my $ref = "CAGCCTTTCTGACCCGGAAATCAAAATAGGCACAACAAA"; my $seq = "CTGAGCCGGTAAATC"; my $cigar = do_SSW($seq,$ref); print "$cigar\n"; __END__ __CPP__ static string do_SSW(const string query, const string ref) { StripedSmithWaterman::Aligner aligner; StripedSmithWaterman::Filter filter; StripedSmithWaterman::Alignment alignment; aligner.Align(query.c_str(), ref.c_str(), ref.size(), filter, &ali +gnment); return alignment.cigar_string; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Including existing C or CPP library using Inline
by syphilis (Archbishop) on Mar 11, 2014 at 22:38 UTC | |
by bontus (Novice) on Mar 12, 2014 at 22:05 UTC | |
by syphilis (Archbishop) on Mar 12, 2014 at 23:30 UTC | |
by bontus (Novice) on Mar 21, 2014 at 18:24 UTC | |
by syphilis (Archbishop) on Mar 22, 2014 at 07:49 UTC | |
|