Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
OBITools3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
46ca693c
Commit
46ca693c
authored
Jul 24, 2020
by
Celine Mercier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cython: View: new method to print a view to a buffer (e.g. stdout)
parent
9a9afde1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
5 deletions
+49
-5
obiseq.pxd
python/obitools3/dms/obiseq.pxd
+4
-2
obiseq.pyx
python/obitools3/dms/obiseq.pyx
+4
-1
view.pxd
python/obitools3/dms/view/view.pxd
+6
-0
view.pyx
python/obitools3/dms/view/view.pyx
+35
-2
No files found.
python/obitools3/dms/obiseq.pxd
View file @
46ca693c
...
...
@@ -39,4 +39,6 @@ cdef class Nuc_Seq_Stored(Seq_Stored) :
cpdef set_quality_char(self, object new_qual, int offset=*)
cpdef object build_quality_array(self, list quality)
cpdef bytes build_reverse_complement(self)
cpdef str get_str(self)
\ No newline at end of file
cpdef str get_str(self)
cpdef repr_bytes(self)
\ No newline at end of file
python/obitools3/dms/obiseq.pyx
View file @
46ca693c
...
...
@@ -431,9 +431,12 @@ cdef class Nuc_Seq_Stored(Seq_Stored) :
return
len
(
self
.
_view
.
get_column
(
NUC_SEQUENCE_COLUMN
).
get_line
(
self
.
index
))
def
__repr__
(
self
)
:
return
bytes2str
(
self
.
repr_bytes
())
cpdef
repr_bytes
(
self
)
:
if
self
.
quality
is
None
:
formatter
=
FastaFormat
()
else
:
formatter
=
FastqFormat
()
return
bytes2str
(
formatter
(
self
)
)
return
formatter
(
self
)
python/obitools3/dms/view/view.pxd
View file @
46ca693c
...
...
@@ -20,6 +20,10 @@ cdef class View(OBIWrapper):
cdef DMS _dms
cdef inline Obiview_p pointer(self)
cpdef print_to_output(self,
object output,
bint noprogressbar=*)
cpdef delete_column(self,
object column_name,
...
...
@@ -61,6 +65,8 @@ cdef class Line :
cdef index_t _index
cdef View _view
cpdef repr_bytes(self)
cdef register_view_class(bytes view_type_name,
type view_class)
...
...
python/obitools3/dms/view/view.pyx
View file @
46ca693c
...
...
@@ -6,6 +6,8 @@ cdef dict __VIEW_CLASS__= {}
from
libc
.
stdlib
cimport
malloc
from
obitools3
.
apps
.
progress
cimport
ProgressBar
#
@UnresolvedImport
from
..
capi
.
obiview
cimport
Alias_column_pair_p
,
\
obi_new_view
,
\
obi_open_view
,
\
...
...
@@ -48,10 +50,13 @@ from ..capi.obidms cimport obi_import_view
from
obitools3
.
format
.
tab
import
TabFormat
from
cpython
.
exc
cimport
PyErr_CheckSignals
import
importlib
import
inspect
import
pkgutil
import
json
import
sys
cdef
class
View
(
OBIWrapper
)
:
...
...
@@ -184,7 +189,31 @@ cdef class View(OBIWrapper) :
for
column_name
in
self
.
keys
()
:
s
=
s
+
repr
(
self
[
column_name
])
+
'\n'
return
s
cpdef
print_to_output
(
self
,
object
output
,
bint
noprogressbar
=
False
)
:
cdef
int
i
cdef
Line
entry
self
.
checkIsActive
(
self
)
# Initialize the progress bar
if
noprogressbar
==
False
:
pb
=
ProgressBar
(
len
(
self
))
else
:
pb
=
None
i
=
0
for
entry
in
self
:
PyErr_CheckSignals
()
if
pb
is
not
None
:
pb
(
i
)
output
.
write
(
entry
.
repr_bytes
()
+
b
"
\n
"
)
i
+=
1
if
pb
is
not
None
:
pb
(
len
(
self
),
force
=
True
)
print
(
""
,
file
=
sys
.
stderr
)
def
keys
(
self
)
:
...
...
@@ -757,8 +786,12 @@ cdef class Line :
def
__repr__
(
self
)
:
return
bytes2str
(
self
).
repr_bytes
()
cpdef
repr_bytes
(
self
)
:
formatter
=
TabFormat
(
header
=
False
)
return
bytes2str
(
formatter
(
self
)
)
return
formatter
(
self
)
# View property getter
...
...
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