Back to index

python-biopython  1.60
Public Member Functions | Static Public Attributes | Private Member Functions
Bio.GenBank._BaseGenBankConsumer Class Reference
Inheritance diagram for Bio.GenBank._BaseGenBankConsumer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def __getattr__

Static Public Attributes

list remove_space_keys = ["translation"]

Private Member Functions

def _unhandled
def _split_keywords
def _split_accessions
def _split_taxonomy
def _clean_location
def _remove_newlines
def _normalize_spaces
def _remove_spaces
def _convert_to_python_numbers

Detailed Description

Abstract GenBank consumer providing useful general functions (PRIVATE).

This just helps to eliminate some duplication in things that most
GenBank consumers want to do.

Definition at line 461 of file __init__.py.


Constructor & Destructor Documentation

Reimplemented in Bio.GenBank._RecordConsumer.

Definition at line 473 of file __init__.py.

00473 
00474     def __init__(self):
00475         pass

Here is the caller graph for this function:


Member Function Documentation

Definition at line 479 of file __init__.py.

00479 
00480     def __getattr__(self, attr):
00481         return self._unhandled

Here is the call graph for this function:

def Bio.GenBank._BaseGenBankConsumer._clean_location (   self,
  location_string 
) [private]
Clean whitespace out of a location string.

The location parser isn't a fan of whitespace, so we clean it out
before feeding it into the parser.

Definition at line 527 of file __init__.py.

00527 
00528     def _clean_location(self, location_string):
00529         """Clean whitespace out of a location string.
00530 
00531         The location parser isn't a fan of whitespace, so we clean it out
00532         before feeding it into the parser.
00533         """
00534         #Originally this imported string.whitespace and did a replace
00535         #via a loop.  It's simpler to just split on whitespace and rejoin
00536         #the string - and this avoids importing string too.  See Bug 2684.
00537         return ''.join(location_string.split())

Here is the caller graph for this function:

def Bio.GenBank._BaseGenBankConsumer._convert_to_python_numbers (   self,
  start,
  end 
) [private]
Convert a start and end range to python notation.

In GenBank, starts and ends are defined in "biological" coordinates,
where 1 is the first base and [i, j] means to include both i and j.

In python, 0 is the first base and [i, j] means to include i, but
not j. 

So, to convert "biological" to python coordinates, we need to 
subtract 1 from the start, and leave the end and things should
be converted happily.

Definition at line 561 of file __init__.py.

00561 
00562     def _convert_to_python_numbers(self, start, end):
00563         """Convert a start and end range to python notation.
00564 
00565         In GenBank, starts and ends are defined in "biological" coordinates,
00566         where 1 is the first base and [i, j] means to include both i and j.
00567 
00568         In python, 0 is the first base and [i, j] means to include i, but
00569         not j. 
00570 
00571         So, to convert "biological" to python coordinates, we need to 
00572         subtract 1 from the start, and leave the end and things should
00573         be converted happily.
00574         """
00575         new_start = start - 1
00576         new_end = end
00577 
00578         return new_start, new_end

Here is the caller graph for this function:

def Bio.GenBank._BaseGenBankConsumer._normalize_spaces (   self,
  text 
) [private]
Replace multiple spaces in the passed text with single spaces.

Definition at line 548 of file __init__.py.

00548 
00549     def _normalize_spaces(self, text):
00550         """Replace multiple spaces in the passed text with single spaces.
00551         """
00552         # get rid of excessive spaces
00553         text_parts = text.split(" ")
00554         text_parts = filter(None, text_parts)
00555         return ' '.join(text_parts)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.GenBank._BaseGenBankConsumer._remove_newlines (   self,
  text 
) [private]
Remove any newlines in the passed text, returning the new string.

Definition at line 538 of file __init__.py.

00538 
00539     def _remove_newlines(self, text):
00540         """Remove any newlines in the passed text, returning the new string.
00541         """
00542         # get rid of newlines in the qualifier value
00543         newlines = ["\n", "\r"]
00544         for ws in newlines:
00545             text = text.replace(ws, "")
00546 
00547         return text

Here is the caller graph for this function:

def Bio.GenBank._BaseGenBankConsumer._remove_spaces (   self,
  text 
) [private]
Remove all spaces from the passed text.

Definition at line 556 of file __init__.py.

00556 
00557     def _remove_spaces(self, text):
00558         """Remove all spaces from the passed text.
00559         """
00560         return text.replace(" ", "")

Here is the caller graph for this function:

def Bio.GenBank._BaseGenBankConsumer._split_accessions (   self,
  accession_string 
) [private]
Split a string of accession numbers into a list.

Definition at line 496 of file __init__.py.

00496 
00497     def _split_accessions(self, accession_string):
00498         """Split a string of accession numbers into a list.
00499         """
00500         # first replace all line feeds with spaces
00501         # Also, EMBL style accessions are split with ';'
00502         accession = accession_string.replace("\n", " ").replace(";"," ")
00503 
00504         return [x.strip() for x in accession.split() if x.strip()]

Here is the caller graph for this function:

def Bio.GenBank._BaseGenBankConsumer._split_keywords (   self,
  keyword_string 
) [private]
Split a string of keywords into a nice clean list.

Definition at line 482 of file __init__.py.

00482 
00483     def _split_keywords(self, keyword_string):
00484         """Split a string of keywords into a nice clean list.
00485         """
00486         # process the keywords into a python list
00487         if keyword_string == "" or keyword_string == ".":
00488             keywords = ""
00489         elif keyword_string[-1] == '.':
00490             keywords = keyword_string[:-1]
00491         else:
00492             keywords = keyword_string
00493         keyword_list = keywords.split(';')
00494         clean_keyword_list = [x.strip() for x in keyword_list]
00495         return clean_keyword_list

Here is the caller graph for this function:

def Bio.GenBank._BaseGenBankConsumer._split_taxonomy (   self,
  taxonomy_string 
) [private]
Split a string with taxonomy info into a list.

Definition at line 505 of file __init__.py.

00505 
00506     def _split_taxonomy(self, taxonomy_string):
00507         """Split a string with taxonomy info into a list.
00508         """
00509         if not taxonomy_string or taxonomy_string==".":
00510             #Missing data, no taxonomy
00511             return []
00512         
00513         if taxonomy_string[-1] == '.':
00514             tax_info = taxonomy_string[:-1]
00515         else:
00516             tax_info = taxonomy_string
00517         tax_list = tax_info.split(';')
00518         new_tax_list = []
00519         for tax_item in tax_list:
00520             new_items = tax_item.split("\n")
00521             new_tax_list.extend(new_items)
00522         while '' in new_tax_list:
00523             new_tax_list.remove('')
00524         clean_tax_list = [x.strip() for x in new_tax_list]
00525 
00526         return clean_tax_list

Here is the caller graph for this function:

def Bio.GenBank._BaseGenBankConsumer._unhandled (   self,
  data 
) [private]

Definition at line 476 of file __init__.py.

00476 
00477     def _unhandled(self, data):
00478         pass

Here is the caller graph for this function:


Member Data Documentation

list Bio.GenBank._BaseGenBankConsumer.remove_space_keys = ["translation"] [static]

Definition at line 471 of file __init__.py.


The documentation for this class was generated from the following file: