Back to index

python-biopython  1.60
Classes | Functions
Bio.GenBank.Record Namespace Reference

Classes

class  Record
class  Reference
class  Feature
class  Qualifier

Functions

def _wrapped_genbank
def _indent_genbank

Detailed Description

Hold GenBank data in a straightforward format.

classes:
o Record - All of the information in a GenBank record.
o Reference - hold reference data for a record.
o Feature - Hold the information in a Feature Table.
o Qualifier - Qualifiers on a Feature.
17-MAR-2009: added support for WGS and WGS_SCAFLD lines.  Ying Huang & Iddo Friedberg

Function Documentation

def Bio.GenBank.Record._indent_genbank (   information,
  indent 
) [private]
Write out information with the specified indent.

Unlike _wrapped_genbank, this function makes no attempt to wrap
lines -- it assumes that the information already has newlines in the
appropriate places, and will add the specified indent to the start of
each line.

Definition at line 75 of file Record.py.

00075 
00076 def _indent_genbank(information, indent):
00077     """Write out information with the specified indent.
00078 
00079     Unlike _wrapped_genbank, this function makes no attempt to wrap
00080     lines -- it assumes that the information already has newlines in the
00081     appropriate places, and will add the specified indent to the start of
00082     each line.
00083     """
00084     # split the info into lines based on line breaks
00085     info_parts = information.split("\n")
00086 
00087     # the first line will have no indent
00088     output_info = info_parts[0] + "\n"
00089     for info_part in info_parts[1:]:
00090         output_info += " " * indent + info_part + "\n"
00091 
00092     return output_info

Here is the caller graph for this function:

def Bio.GenBank.Record._wrapped_genbank (   information,
  indent,
  wrap_space = 1,
  split_char = " " 
) [private]
Write a line of GenBank info that can wrap over multiple lines.

This takes a line of information which can potentially wrap over
multiple lines, and breaks it up with carriage returns and
indentation so it fits properly into a GenBank record.

Arguments:

o information - The string holding the information we want
wrapped in GenBank method.

o indent - The indentation on the lines we are writing.

o wrap_space - Whether or not to wrap only on spaces in the
information.

o split_char - A specific character to split the lines on. By default
spaces are used.

Definition at line 13 of file Record.py.

00013 
00014 def _wrapped_genbank(information, indent, wrap_space = 1, split_char = " "):
00015     """Write a line of GenBank info that can wrap over multiple lines.
00016 
00017     This takes a line of information which can potentially wrap over
00018     multiple lines, and breaks it up with carriage returns and
00019     indentation so it fits properly into a GenBank record.
00020 
00021     Arguments:
00022 
00023     o information - The string holding the information we want
00024     wrapped in GenBank method.
00025 
00026     o indent - The indentation on the lines we are writing.
00027 
00028     o wrap_space - Whether or not to wrap only on spaces in the
00029     information.
00030 
00031     o split_char - A specific character to split the lines on. By default
00032     spaces are used.
00033     """
00034     info_length = Record.GB_LINE_LENGTH - indent
00035 
00036     if not information:
00037         #GenBank files use "." for missing data
00038         return ".\n"
00039 
00040     if wrap_space:
00041         info_parts = information.split(split_char)
00042     else:
00043         cur_pos = 0
00044         info_parts = []
00045         while cur_pos < len(information):
00046             info_parts.append(information[cur_pos: cur_pos + info_length])
00047             cur_pos += info_length
00048             
00049     # first get the information string split up by line
00050     output_parts = []
00051     cur_part = ""
00052     for info_part in info_parts:
00053         if len(cur_part) + 1 + len(info_part) > info_length:
00054             if cur_part:
00055                 if split_char != " ":
00056                     cur_part += split_char
00057                 output_parts.append(cur_part)
00058             cur_part = info_part
00059         else:
00060             if cur_part == "":
00061                 cur_part = info_part
00062             else:
00063                 cur_part += split_char + info_part
00064 
00065     # add the last bit of information to the output
00066     if cur_part:
00067         output_parts.append(cur_part)
00068 
00069     # now format the information string for return
00070     output_info = output_parts[0] + "\n"
00071     for output_part in output_parts[1:]:
00072         output_info += " " * indent + output_part + "\n"
00073 
00074     return output_info            
        

Here is the caller graph for this function: