Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OBITools3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
2a1ea3ba
Commit
2a1ea3ba
authored
Jun 09, 2016
by
Celine Mercier
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setting NA values is now handled properly for OBI_SEQ, OBI_STR and
OBI_QUAL columns
parent
fc3641d7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
147 additions
and
129 deletions
+147
-129
python/obitools3/obidms/_obidmscolumn_qual.pyx
python/obitools3/obidms/_obidmscolumn_qual.pyx
+8
-10
python/obitools3/obidms/_obidmscolumn_seq.pyx
python/obitools3/obidms/_obidmscolumn_seq.pyx
+4
-5
python/obitools3/obidms/_obidmscolumn_str.pyx
python/obitools3/obidms/_obidmscolumn_str.pyx
+4
-5
python/obitools3/obidms/_obiseq.pxd
python/obitools3/obidms/_obiseq.pxd
+20
-20
python/obitools3/obidms/_obiseq.pyx
python/obitools3/obidms/_obiseq.pyx
+13
-13
src/obidmscolumn_qual.c
src/obidmscolumn_qual.c
+45
-34
src/obidmscolumn_seq.c
src/obidmscolumn_seq.c
+27
-21
src/obidmscolumn_str.c
src/obidmscolumn_str.c
+26
-21
No files found.
python/obitools3/obidms/_obidmscolumn_qual.pyx
View file @
2a1ea3ba
...
...
@@ -58,26 +58,24 @@ cdef class OBIDMS_column_qual(OBIDMS_column):
cdef
uint8_t
*
value_b
cdef
int
value_length
if
value
is
None
:
value_b
=
OBIQual_int_NA
value_length
=
0
if
obi_column_set_obiqual_int_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
OBIQual_int_NA
,
0
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
else
:
value_length
=
len
(
value
)
value_b
=
<
uint8_t
*>
malloc
(
value_length
*
sizeof
(
uint8_t
))
for
i
in
range
(
value_length
)
:
value_b
[
i
]
=
<
uint8_t
>
value
[
i
]
if
obi_column_set_obiqual_int_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
value_b
,
value_length
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
if
value
is
not
None
:
if
obi_column_set_obiqual_int_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
value_b
,
value_length
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
free
(
value_b
)
cpdef
set_str_line
(
self
,
index_t
line_nb
,
object
value
):
cdef
bytes
value_b
if
value
is
None
:
value_b
=
OBIQual_char_NA
if
obi_column_set_obiqual_int_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
OBIQual_int_NA
,
0
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
else
:
value_b
=
str2bytes
(
value
)
if
obi_column_set_obiqual_char_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
value_b
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
if
obi_column_set_obiqual_char_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
str2bytes
(
value
))
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
# TODO
...
...
python/obitools3/obidms/_obidmscolumn_seq.pyx
View file @
2a1ea3ba
...
...
@@ -31,13 +31,12 @@ cdef class OBIDMS_column_seq(OBIDMS_column):
return
result
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
):
cdef
bytes
value_b
if
value
is
None
:
value_b
=
OBISeq_NA
if
obi_column_set_obiseq_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
OBISeq_NA
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
else
:
value_b
=
str2bytes
(
value
)
if
obi_column_set_obiseq_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
value_b
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
if
obi_column_set_obiseq_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
str2bytes
(
value
))
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
# TODO choose alignment type (lcs or other) with supplementary argument
cpdef
align
(
self
,
...
...
python/obitools3/obidms/_obidmscolumn_str.pyx
View file @
2a1ea3ba
...
...
@@ -26,13 +26,12 @@ cdef class OBIDMS_column_str(OBIDMS_column):
return
result
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
):
cdef
bytes
value_b
if
value
is
None
:
value_b
=
OBIStr_NA
if
obi_column_set_obistr_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
OBIStr_NA
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
else
:
value_b
=
str2bytes
(
value
)
if
obi_column_set_obistr_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
value_b
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
if
obi_column_set_obistr_with_elt_idx_in_view
(
self
.
view
.
pointer
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
str2bytes
(
value
))
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
cdef
class
OBIDMS_column_multi_elts_str
(
OBIDMS_column_multi_elts
):
...
...
python/obitools3/obidms/_obiseq.pxd
View file @
2a1ea3ba
...
...
@@ -4,35 +4,35 @@ from ._obidms cimport OBIView_line
cdef
class
OBI_Seq
(
dict
)
:
cdef
str
id
cdef
str
definition
cdef
str
sequence
cdef
object
id
cdef
object
definition
cdef
object
sequence
cpdef
set_id
(
self
,
str
id
)
cpdef
get_id
(
self
)
cpdef
set_definition
(
self
,
str
definition
)
cpdef
get_definition
(
self
)
cpdef
get_sequence
(
self
)
cpdef
set_id
(
self
,
object
id
)
cpdef
object
get_id
(
self
)
cpdef
set_definition
(
self
,
object
definition
)
cpdef
object
get_definition
(
self
)
cpdef
object
get_sequence
(
self
)
cdef
class
OBI_Nuc_Seq
(
OBI_Seq
)
:
cdef
object
quality
#cpdef
str
reverse_complement(self)
cpdef
set_sequence
(
self
,
str
sequence
)
#cpdef
object
reverse_complement(self)
cpdef
set_sequence
(
self
,
object
sequence
)
cpdef
set_quality
(
self
,
object
quality
)
cpdef
get_quality
(
self
)
cpdef
object
get_quality
(
self
)
cdef
class
OBI_Nuc_Seq_Stored
(
OBIView_line
)
:
cpdef
set_id
(
self
,
str
id
)
cpdef
get_id
(
self
)
cpdef
set_definition
(
self
,
str
definition
)
cpdef
get_definition
(
self
)
cpdef
set_sequence
(
self
,
str
sequence
)
cpdef
get_sequence
(
self
)
cpdef
set_id
(
self
,
object
id
)
cpdef
object
get_id
(
self
)
cpdef
set_definition
(
self
,
object
definition
)
cpdef
object
get_definition
(
self
)
cpdef
set_sequence
(
self
,
object
sequence
)
cpdef
object
get_sequence
(
self
)
cpdef
set_quality
(
self
,
object
quality
)
cpdef
get_quality
(
self
)
cpdef
get_str_quality
(
self
)
cpdef
object
get_quality
(
self
)
cpdef
object
get_str_quality
(
self
)
# cpdef
str
reverse_complement(self)
# cpdef
object
reverse_complement(self)
python/obitools3/obidms/_obiseq.pyx
View file @
2a1ea3ba
...
...
@@ -9,20 +9,20 @@ from .capi.obiview cimport NUC_SEQUENCE_COLUMN, \
cdef
class
OBI_Seq
(
dict
)
:
def
__init__
(
self
,
str
id
,
str
seq
,
str
definition
=
None
)
:
def
__init__
(
self
,
object
id
,
object
seq
,
object
definition
=
None
)
:
self
.
set_id
(
id
)
self
.
set_sequence
(
seq
)
if
definition
is
not
None
:
self
.
set_definition
(
definition
)
cpdef
set_id
(
self
,
str
id
)
:
cpdef
set_id
(
self
,
object
id
)
:
self
.
id
=
id
self
[
bytes2str
(
ID_COLUMN
)]
=
id
cpdef
get_id
(
self
)
:
return
self
.
id
cpdef
set_definition
(
self
,
str
definition
)
:
cpdef
set_definition
(
self
,
object
definition
)
:
self
.
definition
=
definition
self
[
bytes2str
(
DEFINITION_COLUMN
)]
=
definition
...
...
@@ -38,7 +38,7 @@ cdef class OBI_Seq(dict) :
cdef
class
OBI_Nuc_Seq
(
OBI_Seq
)
:
cpdef
set_sequence
(
self
,
str
sequence
)
:
cpdef
set_sequence
(
self
,
object
sequence
)
:
self
.
sequence
=
sequence
self
[
bytes2str
(
NUC_SEQUENCE_COLUMN
)]
=
sequence
...
...
@@ -57,34 +57,34 @@ cdef class OBI_Nuc_Seq_Stored(OBIView_line) :
# TODO store the str version of column name macros
cpdef
set_id
(
self
,
str
id
)
:
cpdef
set_id
(
self
,
object
id
)
:
self
[
bytes2str
(
ID_COLUMN
)]
=
id
cpdef
get_id
(
self
)
:
cpdef
object
get_id
(
self
)
:
return
self
[
bytes2str
(
ID_COLUMN
)]
cpdef
set_definition
(
self
,
str
definition
)
:
cpdef
set_definition
(
self
,
object
definition
)
:
self
[
bytes2str
(
DEFINITION_COLUMN
)]
=
definition
cpdef
get_definition
(
self
)
:
cpdef
object
get_definition
(
self
)
:
return
self
[
bytes2str
(
DEFINITION_COLUMN
)]
cpdef
set_sequence
(
self
,
str
sequence
)
:
cpdef
set_sequence
(
self
,
object
sequence
)
:
self
[
bytes2str
(
NUC_SEQUENCE_COLUMN
)]
=
sequence
cpdef
get_sequence
(
self
)
:
cpdef
object
get_sequence
(
self
)
:
return
self
[
bytes2str
(
NUC_SEQUENCE_COLUMN
)]
cpdef
set_quality
(
self
,
object
quality
)
:
if
type
(
quality
)
==
list
:
if
(
type
(
quality
)
==
list
)
or
(
quality
is
None
)
:
self
[
bytes2str
(
QUALITY_COLUMN
)]
=
quality
else
:
# Quality is in str form
(((
self
.
view
).
columns
)[
bytes2str
(
QUALITY_COLUMN
)]).
set_str_line
(
self
.
index
,
quality
)
cpdef
get_quality
(
self
)
:
cpdef
object
get_quality
(
self
)
:
return
self
[
bytes2str
(
QUALITY_COLUMN
)]
cpdef
get_str_quality
(
self
)
:
cpdef
object
get_str_quality
(
self
)
:
return
((
self
.
view
).
columns
)[
bytes2str
(
QUALITY_COLUMN
)].
get_str_line
(
self
.
index
)
# def __str__(self) :
...
...
src/obidmscolumn_qual.c
View file @
2a1ea3ba
...
...
@@ -33,18 +33,21 @@ int obi_column_set_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t lin
int
i
;
int
ret_value
;
// TODO NA
int_value_length
=
strlen
(
value
);
int_value
=
(
uint8_t
*
)
malloc
(
int_value_length
*
sizeof
(
uint8_t
));
// Convert in uint8_t array to index in that format
for
(
i
=
0
;
i
<
int_value_length
;
i
++
)
int_value
[
i
]
=
((
uint8_t
)(
value
[
i
]))
-
QUALITY_ASCII_BASE
;
ret_value
=
obi_column_set_obiqual_int_with_elt_idx
(
column
,
line_nb
,
element_idx
,
int_value
,
int_value_length
);
free
(
int_value
);
if
(
value
==
OBIQual_char_NA
)
{
ret_value
=
obi_column_set_obiqual_int_with_elt_idx
(
column
,
line_nb
,
element_idx
,
OBIQual_int_NA
,
0
);
}
else
{
int_value_length
=
strlen
(
value
);
int_value
=
(
uint8_t
*
)
malloc
(
int_value_length
*
sizeof
(
uint8_t
));
// Convert in uint8_t array to index in that format
for
(
i
=
0
;
i
<
int_value_length
;
i
++
)
int_value
[
i
]
=
((
uint8_t
)(
value
[
i
]))
-
QUALITY_ASCII_BASE
;
ret_value
=
obi_column_set_obiqual_int_with_elt_idx
(
column
,
line_nb
,
element_idx
,
int_value
,
int_value_length
);
free
(
int_value
);
}
return
ret_value
;
}
...
...
@@ -58,32 +61,38 @@ int obi_column_set_obiqual_int_with_elt_idx(OBIDMS_column_p column, index_t line
if
(
obi_column_prepare_to_set_value
(
column
,
line_nb
)
<
0
)
return
-
1
;
// TODO NA
// Add the value in the indexer
idx
=
obi_index_uint8
(
column
->
indexer
,
value
,
value_length
);
if
(
idx
==
-
1
)
// An error occurred
if
(
value
==
OBIQual_int_NA
)
{
idx
=
OBIIdx_NA
;
}
else
{
if
(
obi_errno
==
OBI_READ_ONLY_INDEXER_ERROR
)
// Add the value in the indexer
idx
=
obi_index_uint8
(
column
->
indexer
,
value
,
value_length
);
if
(
idx
==
-
1
)
// An error occurred
{
// TODO PUT IN A COLUMN FUNCTION
// If the error is that the indexer is read-only, clone it
new_indexer_name
=
obi_build_indexer_name
((
column
->
header
)
->
name
,
(
column
->
header
)
->
version
);
if
(
new_indexer_name
==
NULL
)
return
-
1
;
column
->
indexer
=
obi_clone_indexer
(
column
->
indexer
,
new_indexer_name
);
// TODO Need to lock this somehow?
strcpy
((
column
->
header
)
->
indexer_name
,
new_indexer_name
);
free
(
new_indexer_name
);
obi_set_errno
(
0
);
// Add the value in the new indexer
idx
=
obi_index_uint8
(
column
->
indexer
,
value
,
value_length
);
if
(
idx
==
-
1
)
if
(
obi_errno
==
OBI_READ_ONLY_INDEXER_ERROR
)
{
// TODO PUT IN A COLUMN FUNCTION
// If the error is that the indexer is read-only, clone it
new_indexer_name
=
obi_build_indexer_name
((
column
->
header
)
->
name
,
(
column
->
header
)
->
version
);
if
(
new_indexer_name
==
NULL
)
return
-
1
;
column
->
indexer
=
obi_clone_indexer
(
column
->
indexer
,
new_indexer_name
);
// TODO Need to lock this somehow?
strcpy
((
column
->
header
)
->
indexer_name
,
new_indexer_name
);
free
(
new_indexer_name
);
obi_set_errno
(
0
);
// Add the value in the new indexer
idx
=
obi_index_uint8
(
column
->
indexer
,
value
,
value_length
);
if
(
idx
==
-
1
)
return
-
1
;
}
else
return
-
1
;
}
else
return
-
1
;
}
// Add the value's index in the column
*
(((
index_t
*
)
(
column
->
data
))
+
(
line_nb
*
((
column
->
header
)
->
nb_elements_per_line
))
+
element_idx
)
=
idx
;
...
...
@@ -100,7 +109,9 @@ char* obi_column_get_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t l
int_value
=
obi_column_get_obiqual_int_with_elt_idx
(
column
,
line_nb
,
element_idx
,
&
int_value_length
);
// TODO NA
// Check NA
if
(
int_value
==
OBIQual_int_NA
)
return
OBIQual_char_NA
;
value
=
(
char
*
)
malloc
((
int_value_length
+
1
)
*
sizeof
(
char
));
...
...
src/obidmscolumn_seq.c
View file @
2a1ea3ba
...
...
@@ -32,32 +32,38 @@ int obi_column_set_obiseq_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
if
(
obi_column_prepare_to_set_value
(
column
,
line_nb
)
<
0
)
return
-
1
;
// TODO NA
// Add the value in the indexer
idx
=
obi_index_dna_seq
(
column
->
indexer
,
value
);
if
(
idx
==
-
1
)
// An error occurred
if
(
value
==
OBISeq_NA
)
{
idx
=
OBIIdx_NA
;
}
else
{
if
(
obi_errno
==
OBI_READ_ONLY_INDEXER_ERROR
)
// Add the value in the indexer
idx
=
obi_index_dna_seq
(
column
->
indexer
,
value
);
if
(
idx
==
-
1
)
// An error occurred
{
// TODO PUT IN A COLUMN FUNCTION
// If the error is that the indexer is read-only, clone it
new_indexer_name
=
obi_build_indexer_name
((
column
->
header
)
->
name
,
(
column
->
header
)
->
version
);
if
(
new_indexer_name
==
NULL
)
return
-
1
;
column
->
indexer
=
obi_clone_indexer
(
column
->
indexer
,
new_indexer_name
);
// TODO Need to lock this somehow?
strcpy
((
column
->
header
)
->
indexer_name
,
new_indexer_name
);
free
(
new_indexer_name
);
obi_set_errno
(
0
);
// Add the value in the new indexer
idx
=
obi_index_dna_seq
(
column
->
indexer
,
value
);
if
(
idx
==
-
1
)
if
(
obi_errno
==
OBI_READ_ONLY_INDEXER_ERROR
)
{
// TODO PUT IN A COLUMN FUNCTION
// If the error is that the indexer is read-only, clone it
new_indexer_name
=
obi_build_indexer_name
((
column
->
header
)
->
name
,
(
column
->
header
)
->
version
);
if
(
new_indexer_name
==
NULL
)
return
-
1
;
column
->
indexer
=
obi_clone_indexer
(
column
->
indexer
,
new_indexer_name
);
// TODO Need to lock this somehow?
strcpy
((
column
->
header
)
->
indexer_name
,
new_indexer_name
);
free
(
new_indexer_name
);
obi_set_errno
(
0
);
// Add the value in the new indexer
idx
=
obi_index_dna_seq
(
column
->
indexer
,
value
);
if
(
idx
==
-
1
)
return
-
1
;
}
else
return
-
1
;
}
else
return
-
1
;
}
// Add the value's index in the column
*
(((
index_t
*
)
(
column
->
data
))
+
(
line_nb
*
((
column
->
header
)
->
nb_elements_per_line
))
+
element_idx
)
=
idx
;
...
...
src/obidmscolumn_str.c
View file @
2a1ea3ba
...
...
@@ -32,31 +32,36 @@ int obi_column_set_obistr_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
if
(
obi_column_prepare_to_set_value
(
column
,
line_nb
)
<
0
)
return
-
1
;
// TODO NA
// Add the value in the indexer
idx
=
obi_index_char_str
(
column
->
indexer
,
value
);
if
(
idx
==
-
1
)
// An error occurred
if
(
value
==
OBIStr_NA
)
{
idx
=
OBIIdx_NA
;
}
else
{
if
(
obi_errno
==
OBI_READ_ONLY_INDEXER_ERROR
)
// Add the value in the indexer
idx
=
obi_index_char_str
(
column
->
indexer
,
value
);
if
(
idx
==
-
1
)
// An error occurred
{
// TODO PUT IN A COLUMN FUNCTION
// If the error is that the indexer is read-only, clone it
new_indexer_name
=
obi_build_indexer_name
((
column
->
header
)
->
name
,
(
column
->
header
)
->
version
);
if
(
new_indexer_name
==
NULL
)
return
-
1
;
column
->
indexer
=
obi_clone_indexer
(
column
->
indexer
,
new_indexer_name
);
// TODO Need to lock this somehow?
strcpy
((
column
->
header
)
->
indexer_name
,
new_indexer_name
);
free
(
new_indexer_name
);
obi_set_errno
(
0
);
// Add the value in the new indexer
idx
=
obi_index_char_str
(
column
->
indexer
,
value
);
if
(
idx
==
-
1
)
if
(
obi_errno
==
OBI_READ_ONLY_INDEXER_ERROR
)
{
// TODO PUT IN A COLUMN FUNCTION
// If the error is that the indexer is read-only, clone it
new_indexer_name
=
obi_build_indexer_name
((
column
->
header
)
->
name
,
(
column
->
header
)
->
version
);
if
(
new_indexer_name
==
NULL
)
return
-
1
;
column
->
indexer
=
obi_clone_indexer
(
column
->
indexer
,
new_indexer_name
);
// TODO Need to lock this somehow?
strcpy
((
column
->
header
)
->
indexer_name
,
new_indexer_name
);
free
(
new_indexer_name
);
obi_set_errno
(
0
);
// Add the value in the new indexer
idx
=
obi_index_char_str
(
column
->
indexer
,
value
);
if
(
idx
==
-
1
)
return
-
1
;
}
else
return
-
1
;
}
else
return
-
1
;
}
// Add the value's index in the column
...
...
Celine Mercier
@mercier
mentioned in issue
#50 (closed)
·
Jun 10, 2016
mentioned in issue
#50 (closed)
mentioned in issue #50
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment