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
2d2fe527
Commit
2d2fe527
authored
Nov 03, 2016
by
Celine Mercier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added functions to add new taxa to a taxonomy with handling of
associated *.ldx files
parent
2504bf0f
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
722 additions
and
455 deletions
+722
-455
python/obitools3/obidms/_obitaxo.pxd
python/obitools3/obidms/_obitaxo.pxd
+2
-1
python/obitools3/obidms/_obitaxo.pyx
python/obitools3/obidms/_obitaxo.pyx
+13
-1
python/obitools3/obidms/capi/obitaxonomy.pxd
python/obitools3/obidms/capi/obitaxonomy.pxd
+1
-0
src/obidms_taxonomy.c
src/obidms_taxonomy.c
+696
-453
src/obidms_taxonomy.h
src/obidms_taxonomy.h
+10
-0
No files found.
python/obitools3/obidms/_obitaxo.pxd
View file @
2d2fe527
...
...
@@ -10,8 +10,9 @@ cdef class OBI_Taxonomy :
cdef
OBIDMS_taxonomy_p
_pointer
cdef
OBIDMS
_dms
cpdef
close
(
self
)
cpdef
write
(
self
,
str
prefix
)
cpdef
int
add_taxon
(
self
,
str
name
,
str
rank_name
,
int
parent_taxid
,
int
min_taxid
=*
)
cpdef
close
(
self
)
cdef
class
OBI_Taxon
:
...
...
python/obitools3/obidms/_obitaxo.pyx
View file @
2d2fe527
...
...
@@ -7,6 +7,7 @@ from .capi.obitaxonomy cimport obi_read_taxonomy, \
obi_write_taxonomy
,
\
obi_close_taxonomy
,
\
obi_taxo_get_taxon_with_taxid
,
\
obi_taxonomy_add_local_taxon
,
\
ecotx_t
...
...
@@ -38,6 +39,8 @@ cdef class OBI_Taxonomy :
if
type
(
ref
)
==
int
:
taxon_p
=
obi_taxo_get_taxon_with_taxid
(
self
.
_pointer
,
ref
)
if
taxon_p
==
NULL
:
raise
Exception
(
"Taxon not found"
)
taxon_capsule
=
PyCapsule_New
(
taxon_p
,
NULL
,
NULL
)
return
OBI_Taxon
(
taxon_capsule
)
else
:
...
...
@@ -55,7 +58,7 @@ cdef class OBI_Taxonomy :
# Yield each taxid
for
t
in
range
(
self
.
_pointer
.
taxa
.
count
):
taxon_p
=
<
ecotx_t
*>
(
taxa
+
t
)
# TODO not compiling for mysterious cython reasons
taxon_p
=
<
ecotx_t
*>
(
taxa
+
t
)
taxon_capsule
=
PyCapsule_New
(
taxon_p
,
NULL
,
NULL
)
yield
OBI_Taxon
(
taxon_capsule
)
...
...
@@ -64,6 +67,15 @@ cdef class OBI_Taxonomy :
if
obi_write_taxonomy
(
self
.
_dms
.
_pointer
,
self
.
_pointer
,
str2bytes
(
prefix
))
<
0
:
raise
Exception
(
"Error writing the taxonomy to binary files"
)
cpdef
int
add_taxon
(
self
,
str
name
,
str
rank_name
,
int
parent_taxid
,
int
min_taxid
=
10000000
)
:
cdef
int
taxid
taxid
=
obi_taxonomy_add_local_taxon
(
self
.
_pointer
,
str2bytes
(
name
),
str2bytes
(
rank_name
),
parent_taxid
,
min_taxid
)
if
taxid
<
0
:
raise
Exception
(
"Error adding a new taxon to the taxonomy"
)
else
:
return
taxid
cpdef
close
(
self
)
:
if
(
obi_close_taxonomy
(
self
.
_pointer
)
<
0
)
:
...
...
python/obitools3/obidms/capi/obitaxonomy.pxd
View file @
2d2fe527
...
...
@@ -56,3 +56,4 @@ cdef extern from "obidms_taxonomy.h" nogil:
ecotx_t
*
obi_taxo_get_superkingdom
(
ecotx_t
*
taxon
,
OBIDMS_taxonomy_p
taxonomy
)
int
obi_taxonomy_add_local_taxon
(
OBIDMS_taxonomy_p
tax
,
const
char
*
name
,
const
char
*
rank_name
,
int32_t
parent_taxid
,
int32_t
min_taxid
)
src/obidms_taxonomy.c
View file @
2d2fe527
This diff is collapsed.
Click to expand it.
src/obidms_taxonomy.h
View file @
2d2fe527
...
...
@@ -17,6 +17,10 @@
#include "obidms.h"
#define MIN_LOCAL_TAXID (10000000)
#define TAX_NAME_LEN (1024)
typedef
struct
{
int32_t
taxid
;
int32_t
rank
;
...
...
@@ -33,11 +37,14 @@ typedef struct ecotxnode {
int32_t
idx
;
struct
ecotxnode
*
parent
;
char
*
name
;
bool
local
;
}
ecotx_t
;
typedef
struct
{
int32_t
count
;
int32_t
ncbi_count
;
int32_t
local_count
;
int32_t
max_taxid
;
int32_t
buffer_size
;
ecotx_t
taxon
[
1
];
...
...
@@ -74,6 +81,8 @@ typedef struct {
typedef
struct
OBIDMS_taxonomy_t
{
char
tax_name
[
TAX_NAME_LEN
];
OBIDMS_p
dms
;
ecorankidx_t
*
ranks
;
econameidx_t
*
names
;
ecotxidx_t
*
taxa
;
...
...
@@ -109,3 +118,4 @@ int obi_write_taxonomy(OBIDMS_p dms, OBIDMS_taxonomy_p tax, const char* tax_name
OBIDMS_taxonomy_p
obi_read_taxdump
(
const
char
*
taxdump
);
int
obi_taxonomy_add_local_taxon
(
OBIDMS_taxonomy_p
tax
,
const
char
*
name
,
const
char
*
rank_name
,
int32_t
parent_taxid
,
int32_t
min_taxid
);
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