eccLib 1.1.0
Python library for bioinformatics written in C
Loading...
Searching...
No Matches
Data Structures | Functions
reader

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.
 

Detailed Description

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.

Function Documentation

◆ file_enter()

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.

Parameters
selfthe file object
argsarguments passed to enter
Here is the call graph for this function:

◆ file_exit()

PyObject * file_exit ( struct file self,
PyObject *  args,
PyObject *  kwds 
)

exit method for file objects

Parameters
selfthe file object
argsarguments passed to exit
kwdskeyword arguments passed to exit
Here is the call graph for this function:

◆ free_reader()

void free_reader ( struct reader self)

Free the reader object.

Parameters
selfthe reader object
Here is the caller graph for this function:

◆ initialize_reader()

bool initialize_reader ( const struct file self,
struct reader reader 
)

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

Parameters
selfthe file object
readerthe allocated reader object
Returns
true on success, false on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ next_line()

line_out next_line ( struct reader *restrict  self,
bool(*)(const char *, size_t)  valid 
)

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.

Parameters
selfthe reader object
Returns
the next line from the reader object
Warning
the returned line token buffer may be owned by the reader object
Here is the call graph for this function:
Here is the caller graph for this function: