biopython v1.71.0 Bio.ParserSupport

Code to support writing parsers (DEPRECATED).

Classes:

  • AbstractParser Base class for parsers.
  • AbstractConsumer Base class of all Consumers.
  • TaggingConsumer Consumer that tags output with its event. For debugging

Functions:

  • safe_readline Read a line from a handle, with check for EOF.
  • safe_peekline Peek at next line, with check for EOF.
  • read_and_call Read a line from a handle and pass it to a method.
  • read_and_call_while Read many lines, as long as a condition is met.
  • read_and_call_until Read many lines, until a condition is met.
  • attempt_read_and_call Like read_and_call, but forgiving of errors.
  • is_blank_line Test whether a line is blank.

Link to this section Summary

Functions

Attempt read line and call method

Check if a line is blank

Read line and pass it to the method

Read line and pass it to the method until condition is true

Read line and pass it to the method while condition is true

Peek at the next line if present, otherwise raises ValueError

Read a line, otherwise raises ValueError

Link to this section Functions

Link to this function attempt_read_and_call()

Attempt read line and call method.

Similar to read_and_call, but returns a boolean specifying whether the line has passed the checks. Does not raise exceptions.

See docs for read_and_call for a description of the function arguments.

Link to this function is_blank_line()

Check if a line is blank.

Return whether a line is blank. allow_spaces specifies whether to allow whitespaces in a blank line. A true value signifies that a line containing whitespaces as well as end-of-line characters should be considered blank.

Link to this function read_and_call()

Read line and pass it to the method.

Read a line from uhandle, check it, and pass it to the method. Raises a ValueError if the line does not pass the checks.

start, end, contains, blank, and has_re specify optional conditions that the line must pass. start and end specifies what the line must begin or end with (not counting EOL characters). contains specifies a substring that must be found in the line. If blank is a true value, then the line must be blank. has_re should be a regular expression object with a pattern that the line must match somewhere.

Link to this function read_and_call_until()

Read line and pass it to the method until condition is true.

Read a line from uhandle and pass it to the method until some condition is true. Returns the number of lines that were read.

See the docstring for read_and_call for a description of the parameters.

Link to this function read_and_call_while()

Read line and pass it to the method while condition is true.

Read a line from uhandle and pass it to the method as long as some condition is true. Returns the number of lines that were read.

See the docstring for read_and_call for a description of the parameters.

Link to this function safe_peekline()

Peek at the next line if present, otherwise raises ValueError.

Peek at the next line in an UndoHandle and return it. If there are no more lines to peek, I will raise a ValueError.

Link to this function safe_readline()

Read a line, otherwise raises ValueError.

Read a line from an UndoHandle and return it. If there are no more lines to read, I will raise a ValueError.