eccLib 1.1.0
Python library for bioinformatics written in C
|
A module providing a C "base classes" for FastaReader, GtfReader and GtfFile, FastaFile. More...
Data Structures | |
struct | reader |
Reader base struct. More... | |
struct | file |
File base struct. More... | |
struct | line_out |
A simple that hold a string, and potentially it's Python parent object. More... | |
Functions | |
void | free_reader (struct reader *self) |
Free the reader object. | |
PyObject * | file_enter (struct file *self, PyObject *args) |
enter method for file objects | |
PyObject * | file_exit (struct file *self, PyObject *args, PyObject *kwds) |
exit method for file objects | |
bool | initialize_reader (const struct file *self, struct reader *reader) |
Initialize the reader object based on the file object. | |
line_out | next_line (struct reader *restrict self, bool(*valid)(const char *, size_t)) |
Fetches the next line from the reader object. | |
A module providing a C "base classes" for FastaReader, GtfReader and GtfFile, FastaFile.
For maintainability and to avoid duplicating code, plenty of similar functionality was generalized from GtfReader into this module. Through the magic of pointers, basic polymorphism is achieved. For example: both FastaReader and GtfReader are derived from the reader struct. They both have that struct as the first field, meaning functions taking in reader* as arguments can use them.
PyObject * file_enter | ( | struct file * | self, |
PyObject * | args | ||
) |
enter method for file objects
This function opens the file and ensures the file is ready for reader creation.
self | the file object |
args | arguments passed to enter |
PyObject * file_exit | ( | struct file * | self, |
PyObject * | args, | ||
PyObject * | kwds | ||
) |
exit method for file objects
self | the file object |
args | arguments passed to exit |
kwds | keyword arguments passed to exit |
void free_reader | ( | struct reader * | self | ) |
Free the reader object.
self | the reader object |
Initialize the reader object based on the file object.
This function does all the sanity checks, resets the FILE object, and initializes the reader object
self | the file object |
reader | the allocated reader object |
Fetches the next line from the reader object.
This function returns a line_out structure containing the next line from the reader object. Unfortunately, the line may contain the '
' character. Use Py_XDECREF to release the returned structure.
self | the reader object |