Commit ba898bd 1 parent f19eba7 commit ba898bd Copy full SHA for ba898bd
File tree 1 file changed +12
-21
lines changed
1 file changed +12
-21
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,20 @@ pub struct PyFastxReader {
28
28
#[ pymethods]
29
29
impl PyFastxReader {
30
30
fn __repr__ ( & self ) -> PyResult < String > {
31
- Ok ( "<FastxParser >" . to_string ( ) )
31
+ Ok ( "<FastxReader >" . to_string ( ) )
32
32
}
33
33
34
- fn __iter__ ( slf : PyRefMut < Self > , py : Python < ' _ > ) -> PyResult < FastxReaderIterator > {
35
- Ok ( FastxReaderIterator { t : slf. into_py ( py) } )
34
+ fn __iter__ ( slf : PyRefMut < Self > ) -> PyRefMut < Self > {
35
+ slf
36
+ }
37
+
38
+ fn __next__ ( mut slf : PyRefMut < Self > ) -> PyResult < Option < Record > > {
39
+ if let Some ( rec) = slf. reader . next ( ) {
40
+ let record = py_try ! ( rec) ;
41
+ Ok ( Some ( Record :: from_sequence_record ( & record) ) )
42
+ } else {
43
+ Ok ( None )
44
+ }
36
45
}
37
46
}
38
47
@@ -74,24 +83,6 @@ impl Record {
74
83
}
75
84
}
76
85
77
- #[ pyclass]
78
- pub struct FastxReaderIterator {
79
- t : PyObject ,
80
- }
81
-
82
- #[ pymethods]
83
- impl FastxReaderIterator {
84
- fn __next__ ( slf : PyRef < Self > , py : Python < ' _ > ) -> PyResult < Option < Record > > {
85
- let mut parser: PyRefMut < PyFastxReader > = slf. t . extract ( py) ?;
86
- if let Some ( rec) = parser. reader . next ( ) {
87
- let record = py_try ! ( rec) ;
88
- Ok ( Some ( Record :: from_sequence_record ( & record) ) )
89
- } else {
90
- Ok ( None )
91
- }
92
- }
93
- }
94
-
95
86
// TODO: what would be really nice is to detect the type of pyobject so it would on file object etc
96
87
// not for initial release though
97
88
You can’t perform that action at this time.
0 commit comments