obiview.pxd 19.1 KB
Newer Older
Celine Mercier committed
1 2 3
#cython: language_level=3

from .obitypes           cimport const_char_p, \
4
                                 OBIType_t, \
Celine Mercier committed
5
                                 obiversion_t, \
6 7 8 9
                                 obiint_t, \
                                 obibool_t, \
                                 obichar_t, \
                                 obifloat_t, \
10 11
                                 index_t, \
                                 time_t
Celine Mercier committed
12
from ..capi.obidms       cimport OBIDMS_p
Celine Mercier committed
13 14 15
from ..capi.obidmscolumn cimport OBIDMS_column_p, \
                                 Column_reference_t, \
                                 Column_reference_p
Celine Mercier committed
16

17
from libc.stdint cimport uint8_t, int32_t
18

Celine Mercier committed
19 20 21

cdef extern from "obiview.h" nogil:

22 23 24
    extern const_char_p VIEW_TYPE_NUC_SEQS
    extern const_char_p NUC_SEQUENCE_COLUMN
    extern const_char_p ID_COLUMN
25
    extern const_char_p DEFINITION_COLUMN
26
    extern const_char_p QUALITY_COLUMN
27
    extern const_char_p COUNT_COLUMN
28
    extern const_char_p TAXID_COLUMN
29 30 31 32
    extern const_char_p MERGED_TAXID_COLUMN
    extern const_char_p MERGED_PREFIX
    extern const_char_p TAXID_DIST_COLUMN
    extern const_char_p MERGED_COLUMN
Celine Mercier committed
33

34 35 36 37 38 39 40
    struct Alias_column_pair_t :
        Column_reference_t    column_refs
        const_char_p          alias
    
    ctypedef Alias_column_pair_t* Alias_column_pair_p


41
    struct Obiview_infos_t :
42
        time_t              creation_date
43 44
        const_char_p        name
        const_char_p        created_from
45
        const_char_p        view_type
46 47
        bint                all_lines
        Column_reference_t  line_selection
48 49
        index_t             line_count
        int                 column_count
50
        Alias_column_pair_p column_references
Celine Mercier committed
51
        const_char_p        comments
52 53 54 55

    ctypedef Obiview_infos_t* Obiview_infos_p


56 57 58 59 60 61
    struct Obiview_t :
        Obiview_infos_p     infos
        OBIDMS_p            dms
        bint                read_only
        OBIDMS_column_p     line_selection
        OBIDMS_column_p     columns
62 63 64
        int                 nb_predicates
        # TODO declarations for column dictionary and predicate function array?
        
65
    ctypedef Obiview_t* Obiview_p
66 67


68
    Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const_char_p view_name, Obiview_p view_to_clone, index_t* line_selection, const_char_p comments, bint quality_column, bint create_default_columns)
69

Celine Mercier committed
70
    Obiview_p obi_new_view(OBIDMS_p dms, const_char_p view_name, Obiview_p view_to_clone, index_t* line_selection, const_char_p comments)
Celine Mercier committed
71
    
Celine Mercier committed
72
    Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const_char_p view_name, const_char_p view_to_clone_name, index_t* line_selection, const_char_p comments)
Celine Mercier committed
73

74 75 76 77 78 79
    Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const_char_p view_name, const_char_p view_to_clone_name, index_t* line_selection, const_char_p comments)
    
    Obiview_p obi_clone_view(OBIDMS_p dms, Obiview_p view_to_clone, const char* view_name, index_t* line_selection, const char* comments)

    Obiview_p obi_clone_view_from_name(OBIDMS_p dms, const char* view_to_clone_name, const char* view_name, index_t* line_selection, const char* comments)
    
80
    Obiview_infos_p obi_view_map_file(OBIDMS_p dms, const char* view_name, bint finished)
81 82 83

    int obi_view_unmap_file(OBIDMS_p dms, Obiview_infos_p view_infos)

Celine Mercier committed
84 85 86 87 88
    Obiview_p obi_open_view(OBIDMS_p dms, const_char_p view_name)
    
    int obi_view_add_column(Obiview_p view,
                            const_char_p column_name,
                            obiversion_t version_number,
89
                            const_char_p alias,
90
                            OBIType_t data_type,
Celine Mercier committed
91 92
                            index_t nb_lines,
                            index_t nb_elements_per_line,
93
                            char* elements_names,
94
                            bint  elt_names_formatted,
95
                            bint tuples,
96
                            bint to_eval,
Celine Mercier committed
97
                            const_char_p indexer_name,
Celine Mercier committed
98 99
                            const_char_p associated_column_name,
                            obiversion_t associated_column_version,
Celine Mercier committed
100 101 102 103
                            const_char_p comments,
                            bint create)

    int obi_view_delete_column(Obiview_p view, const_char_p column_name)
104
            
Celine Mercier committed
105 106 107 108
    OBIDMS_column_p obi_view_get_column(Obiview_p view, const_char_p column_name)

    OBIDMS_column_p* obi_view_get_pointer_on_column_in_view(Obiview_p view, const_char_p column_name)

109
    int obi_view_create_column_alias(Obiview_p view, const_char_p current_name, const_char_p alias)    
Celine Mercier committed
110
    
111 112 113 114
    int obi_view_write_comments(Obiview_p view, const_char_p comments)

    int obi_view_add_comment(Obiview_p view, const_char_p key, const_char_p value)

Celine Mercier committed
115
    int obi_save_and_close_view(Obiview_p view)
116 117 118 119

    int obi_clean_unfinished_views(OBIDMS_p dms)

    int obi_rollback_view(Obiview_p view)
120

121 122
    int obi_delete_view(OBIDMS_p dms, const char* view_name)

123 124 125 126

    # OBI_INT
    int obi_set_int_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                    OBIDMS_column_p column_p, 
127 128 129 130
                                                    index_t line_nb, 
                                                    const_char_p element_name, 
                                                    obiint_t value)

131 132
    int obi_set_int_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                   OBIDMS_column_p column_p, 
133 134 135 136
                                                   index_t line_nb, 
                                                   index_t element_idx, 
                                                   obiint_t value)
    
137 138
    obiint_t obi_get_int_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                         OBIDMS_column_p column_p, 
139 140 141
                                                         index_t line_nb, 
                                                         const_char_p element_name)
    
142 143
    obiint_t obi_get_int_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                        OBIDMS_column_p column_p, 
144 145 146
                                                        index_t line_nb, 
                                                        index_t element_idx)

147 148 149 150

    # OBI_BOOL
    int obi_set_bool_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                     OBIDMS_column_p column_p, 
151 152 153 154
                                                     index_t line_nb, 
                                                     const_char_p element_name, 
                                                     obibool_t value)

155 156
    int obi_set_bool_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                    OBIDMS_column_p column_p, 
157 158 159 160
                                                    index_t line_nb, 
                                                    index_t element_idx, 
                                                    obibool_t value)
    
161 162
    obibool_t obi_get_bool_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                           OBIDMS_column_p column_p, 
163 164 165
                                                           index_t line_nb, 
                                                           const_char_p element_name)
    
166 167
    obibool_t obi_get_bool_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                          OBIDMS_column_p column_p, 
168 169 170
                                                          index_t line_nb, 
                                                          index_t element_idx)

171 172 173 174

    # OBI_CHAR
    int obi_set_char_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                     OBIDMS_column_p column_p, 
175 176 177 178
                                                     index_t line_nb, 
                                                     const_char_p element_name, 
                                                     obichar_t value)

179 180
    int obi_set_char_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                    OBIDMS_column_p column_p, 
181 182 183 184
                                                    index_t line_nb, 
                                                    index_t element_idx, 
                                                    obichar_t value)
    
185 186
    obichar_t obi_get_char_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                           OBIDMS_column_p column_p, 
187 188 189
                                                           index_t line_nb, 
                                                           const_char_p element_name)
    
190 191
    obichar_t obi_get_char_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                          OBIDMS_column_p column_p, 
192 193 194
                                                          index_t line_nb, 
                                                          index_t element_idx)

195 196 197 198

    # OBI_FLOAT
    int obi_set_float_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                      OBIDMS_column_p column_p, 
199 200 201 202
                                                      index_t line_nb, 
                                                      const_char_p element_name, 
                                                      obifloat_t value)

203 204
    int obi_set_float_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                     OBIDMS_column_p column_p, 
205 206 207 208
                                                     index_t line_nb, 
                                                     index_t element_idx, 
                                                     obifloat_t value)
    
209 210
    obifloat_t obi_get_float_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                             OBIDMS_column_p column_p, 
211 212 213
                                                             index_t line_nb, 
                                                             const_char_p element_name)
    
214 215
    obifloat_t obi_get_float_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                            OBIDMS_column_p column_p, 
216 217 218
                                                            index_t line_nb, 
                                                            index_t element_idx)

219 220 221 222

    # OBI_QUAL
    int obi_set_qual_char_with_elt_idx_and_col_p_in_view(Obiview_p view, 
                                                         OBIDMS_column_p column_p, 
223 224
                                                         index_t line_nb, 
                                                         index_t element_idx, 
225 226
                                                         const char* value,
                                                         int offset)
227

228 229
    int obi_set_qual_int_with_elt_idx_and_col_p_in_view(Obiview_p view, 
                                                        OBIDMS_column_p column_p, 
230 231 232 233 234
                                                        index_t line_nb, 
                                                        index_t element_idx, 
                                                        const uint8_t* value, 
                                                        int value_length)

235 236
    char* obi_get_qual_char_with_elt_idx_and_col_p_in_view(Obiview_p view, 
                                                           OBIDMS_column_p column_p, 
237
                                                           index_t line_nb, 
238 239
                                                           index_t element_idx,
                                                           int offset)
240

241 242
    const uint8_t* obi_get_qual_int_with_elt_idx_and_col_p_in_view(Obiview_p view, 
                                                                   OBIDMS_column_p column_p, 
243 244 245 246
                                                                   index_t line_nb, 
                                                                   index_t element_idx, 
                                                                   int* value_length)

247 248
    int obi_set_qual_char_with_elt_name_and_col_p_in_view(Obiview_p view, 
                                                          OBIDMS_column_p column_p, 
249 250
                                                          index_t line_nb, 
                                                          const char* element_name, 
251 252
                                                          const char* value,
                                                          int offset)
253

254 255
    int obi_set_qual_int_with_elt_name_and_col_p_in_view(Obiview_p view, 
                                                         OBIDMS_column_p column_p, 
256 257 258 259 260
                                                         index_t line_nb, 
                                                         const char* element_name, 
                                                         const uint8_t* value, 
                                                         int value_length)

261 262
    char* obi_get_qual_char_with_elt_name_and_col_p_in_view(Obiview_p view, 
                                                            OBIDMS_column_p column_p, 
263
                                                            index_t line_nb, 
264 265
                                                            const char* element_name,
                                                            int offset)
266

267 268
    const uint8_t* obi_get_qual_int_with_elt_name_and_col_p_in_view(Obiview_p view, 
                                                                    OBIDMS_column_p column_p, 
269 270 271 272
                                                                    index_t line_nb, 
                                                                    const char* element_name, 
                                                                    int* value_length)

273 274 275 276

    # OBI_STR
    int obi_set_str_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                    OBIDMS_column_p column_p, 
277 278 279 280
                                                    index_t line_nb, 
                                                    const_char_p element_name, 
                                                    const_char_p value)

281 282
    int obi_set_str_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                   OBIDMS_column_p column_p, 
283 284 285 286
                                                   index_t line_nb, 
                                                   index_t element_idx, 
                                                   const_char_p value)
    
287 288
    const_char_p obi_get_str_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                           OBIDMS_column_p column_p, 
289 290 291
                                                           index_t line_nb, 
                                                           const_char_p element_name)
    
292 293
    const_char_p obi_get_str_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                            OBIDMS_column_p column_p, 
294 295 296
                                                            index_t line_nb, 
                                                            index_t element_idx)

297 298 299 300

    # OBI_SEQ
    int obi_set_seq_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                    OBIDMS_column_p column_p, 
301 302 303 304
                                                    index_t line_nb, 
                                                    const_char_p element_name, 
                                                    const_char_p value)

305 306
    int obi_set_seq_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                   OBIDMS_column_p column_p, 
307 308 309 310
                                                   index_t line_nb, 
                                                   index_t element_idx, 
                                                   const_char_p value)
    
311 312
    char* obi_get_seq_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                      OBIDMS_column_p column_p, 
313 314 315
                                                      index_t line_nb, 
                                                      const_char_p element_name)
    
316 317
    char* obi_get_seq_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                     OBIDMS_column_p column_p, 
318 319
                                                     index_t line_nb, 
                                                     index_t element_idx)
Celine Mercier committed
320

321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
    
    # OBI_IDX
    int obi_set_index_with_elt_name_and_col_p_in_view(Obiview_p view, 
                                                     OBIDMS_column_p column_p, 
                                                     index_t line_nb, 
                                                     const_char_p element_name, 
                                                     index_t value)

    int obi_set_index_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                     OBIDMS_column_p column_p, 
                                                     index_t line_nb, 
                                                     index_t element_idx, 
                                                     index_t value)
    
    index_t obi_get_index_with_elt_name_and_col_p_in_view(Obiview_p view,
                                                          OBIDMS_column_p column_p, 
                                                          index_t line_nb, 
                                                          const_char_p element_name)

    index_t obi_get_index_with_elt_idx_and_col_p_in_view(Obiview_p view,
                                                         OBIDMS_column_p column_p, 
                                                         index_t line_nb, 
                                                         index_t element_idx)
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369

    # ARRAY
    int obi_set_array_with_col_p_in_view(Obiview_p view, 
                                         OBIDMS_column_p column, 
                                         index_t line_nb, 
                                         const void* value, 
                                         uint8_t elt_size, 
                                         int32_t value_length)
    
    const void* obi_get_array_with_col_p_in_view(Obiview_p view, 
                                                 OBIDMS_column_p column, 
                                                 index_t line_nb, 
                                                 int32_t* value_length_p)

    int obi_set_array_with_col_name_in_view(Obiview_p view, 
                                            const char* column_name, 
                                            index_t line_nb, 
                                            const void* value, 
                                            uint8_t elt_size, 
                                            int32_t value_length)

    const void* obi_get_array_with_col_name_in_view(Obiview_p view, 
                                                    const char* column_name, 
                                                    index_t line_nb, 
                                                    int32_t* value_length_p)