#!/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éIn reply to Re^6: Including existing C or CPP library using Inline
by bontus
in thread Including existing C or CPP library using Inline
by bontus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |