in reply to Re^5: Including existing C or CPP library using Inline
in thread Including existing C or CPP library using Inline
#!/usr/bin/perl use warnings; use Inline CPP => Config => BUILD_NOISY => 1, CLEAN_AFTER_BUILD => 0, TYPEMAPS => './stringtype.map'; use Inline CPP; my $seq = "CTGAGCCGGTAAATC"; my $ref = "CTGTGCCATGCGACTGGTACAATC"; my $cigar = do_SSW($seq,$ref); print "$cigar\n"; __END__ __CPP__ using namespace std; #include <string> #include "ssw_cpp.h" #include "ssw_cpp.cpp" #include "ssw.c" #include "ssw.h" char *do_SSW(string queryC, string refC) { StripedSmithWaterman::Aligner aligner; StripedSmithWaterman::Filter filter; StripedSmithWaterman::Alignment alignment; aligner.Align(queryC.c_str(), refC.c_str(), refC.size(), filter, & +alignment); string s = alignment.cigar_string.c_str(); char *a = new char[s.size()+1]; a[s.size()] = 0; memcpy(a,s.c_str(),s.size()); return a; }
Having solved this problem, I am of course facing the next one: since the C++ alignment object contains more information and cannot be fully passed back to Perl right away, I am now trying to find a way to do so. My backup plan is to just concatenate all this information and then split the returned string in Perl.
Anyhow, again thanks a lot! René
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Including existing C or CPP library using Inline
by davido (Cardinal) on Mar 23, 2014 at 17:05 UTC |