forked from iosonofabio/seqanpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseqanpy.i
108 lines (89 loc) · 2.81 KB
/
seqanpy.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* Created on: 26/01/2014
* Author: Fabio Zanini
* Contents: SWIG file for the seqanpy Python wrapper of SeqAn
*/
%module seqanpy
%{
#define SWIG_FILE_WITH_INIT
#include "seqanpy.h"
%}
/* STL types */
%include "std_string.i"
/* SEQANPY */
/* convert any Python input to string before passing down to C++ (duck typing) */
%pythonprepend align_global %{
seq1 = ''.join(seq1)
seq2 = ''.join(seq2)
%}
%pythonprepend align_overlap %{
seq1 = ''.join(seq1)
seq2 = ''.join(seq2)
%}
%pythonprepend align_ladder %{
seq1 = ''.join(seq1)
seq2 = ''.join(seq2)
%}
%pythonprepend align_local %{
seq1 = ''.join(seq1)
seq2 = ''.join(seq2)
%}
/* "output" string pointers */
%typemap(in, numinputs=0) std::string *aliout1(std::string temp) {
$1 = &temp;
}
%typemap(in, numinputs=0) std::string *aliout2(std::string temp) {
$1 = &temp;
}
%typemap(argout) std::string *aliout1 {
PyObject *alipy = PyString_FromString((*$1).c_str());
/* $result should be the C++ return value (score) */
PyObject *score = $result;
$result = PyTuple_New(3);
PyTuple_SetItem($result, 0, score);
PyTuple_SetItem($result, 1, alipy);
/* NOTE: all Python objects are still in use at the end,
so no need to reduce their refcount */
}
%typemap(argout) std::string *aliout2 {
PyObject *alipy = PyString_FromString((*$1).c_str());
/* $result should already be a tuple by now */
PyTuple_SetItem($result, 2, alipy);
}
/* Documentation */
%feature("autodoc", "0");
%feature("docstring") align_global
"Global alignment of two sequences.
Parameters:
seq1: string with the first seq
seq2: string with the second seq
band: make banded alignment, maximal shear between the sequences (-1 to turn off)
score_...: scores for the alignment
";
%feature("docstring") align_overlap
"Align a subsequence onto a longer, reference one.
Parameters:
seq1: string with the reference seq
seq2: string with the subsequence (end gaps are free)
band: make banded alignment, maximal shear between the sequences (-1 to turn off)
score_...: scores for the alignment
Note: band counts also gaps at the edges, so it must be used with care.
";
%feature("docstring") align_ladder
"Align two sequences where the second is an overlapping extension of the first.
Parameters:
seq1: string to be extended (end gaps are free)
seq2: string to use for extension (start gaps are free)
band: make banded alignment, maximal shear between the sequences (-1 to turn off)
score_...: scores for the alignment
Note: band counts also gaps at the edges, so it must be used with care.
";
%feature("docstring") align_local
"Local alignment of two strings.
Parameters:
seq1: string with the first seq
seq2: string with the second seq
score_...: scores for the alignment
";
/* HEADER */
%include "seqanpy.h"