Back to index

python-biopython  1.60
Namespaces | Functions | Variables
Bio.KEGG Namespace Reference

Namespaces

namespace  Compound
namespace  Enzyme
namespace  Map

Functions

def _wrap_kegg
def _write_kegg

Variables

int KEGG_ITEM_LENGTH = 12
int KEGG_LINE_LENGTH = 80
 KEGG_DATA_LENGTH = KEGG_LINE_LENGTH-KEGG_ITEM_LENGTH
list _default_wrap = lambdaindent:[indent, "", (" ", "", 1, 0)]

Function Documentation

def Bio.KEGG._wrap_kegg (   line,
  max_width = KEGG_DATA_LENGTH,
  wrap_rule = _default_wrap 
) [private]
Wraps the input line  for KEGG output.

Arguments:

o info - String holding the information we want wrapped
for KEGG output.
o max_width - Maximum width of a line.
o wrap_rule - A wrap rule (see above) for deciding how to split
strings that must be wrapped.

Definition at line 23 of file __init__.py.

00023 
00024 def _wrap_kegg(line, max_width = KEGG_DATA_LENGTH, wrap_rule = _default_wrap):
00025     """Wraps the input line  for KEGG output.
00026 
00027     Arguments:
00028     
00029     o info - String holding the information we want wrapped
00030     for KEGG output.
00031     o max_width - Maximum width of a line.
00032     o wrap_rule - A wrap rule (see above) for deciding how to split
00033     strings that must be wrapped.
00034     """
00035     s = ""
00036     wrapped_line = ""
00037     indent =  " " * wrap_rule[0]
00038     connect = wrap_rule[1]
00039     rules =   wrap_rule[2:]
00040     while 1:
00041         if len(line) <= max_width:
00042             wrapped_line = wrapped_line + line
00043             s = s + wrapped_line
00044             break
00045         else:
00046             did_split = 0
00047             for rule in rules:
00048                 to = max_width
00049                 if not rule[2]:
00050                     to = to + len(rule[0])
00051                 split_idx = line.rfind(rule[0], 0, to)
00052                 if split_idx > -1:
00053                     if rule[2] and rule[3]:
00054                         split_idx = split_idx + len(rule[0])
00055                     wrapped_line = wrapped_line + line[0:split_idx] + "\n"
00056                     if not rule[3]:
00057                         split_idx = split_idx + len(rule[0])
00058                     line = indent + rule[1] + line[split_idx:]
00059                     did_split = 1
00060                     break
00061             if not did_split:
00062                 wrapped_line = wrapped_line + line[0:max_width] + "\n"
00063                 line = indent + connect + line[max_width:]
00064     return s
00065 

Here is the caller graph for this function:

def Bio.KEGG._write_kegg (   item,
  info,
  indent = KEGG_ITEM_LENGTH 
) [private]
Write a indented KEGG record item.

Arguments:

o item - The name of the item to be written.
o info - The (wrapped) information to write.
o indent - Width of item field.

Definition at line 66 of file __init__.py.

00066 
00067 def _write_kegg(item, info, indent = KEGG_ITEM_LENGTH):
00068     """Write a indented KEGG record item.
00069     
00070     Arguments:
00071     
00072     o item - The name of the item to be written.
00073     o info - The (wrapped) information to write.
00074     o indent - Width of item field.
00075     """
00076     s = ""
00077     for line in info:
00078         partial_lines = line.splitlines()
00079         for l in partial_lines:
00080             s = s + item.ljust(indent) + l + "\n"
00081             if item is not "":  # ensure item is only written on first line
00082                 item = ""
00083     return s

Here is the caller graph for this function:


Variable Documentation

list Bio.KEGG._default_wrap = lambdaindent:[indent, "", (" ", "", 1, 0)]

Definition at line 21 of file __init__.py.

Definition at line 18 of file __init__.py.

Definition at line 16 of file __init__.py.

Definition at line 17 of file __init__.py.