Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.SeqIO.Interfaces.SequenceWriter Class Reference
Inheritance diagram for Bio.SeqIO.Interfaces.SequenceWriter:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def clean
def write_file

Public Attributes

 handle

Private Member Functions

def _get_seq_string

Detailed Description

This class should be subclassed.

Interlaced file formats (e.g. Clustal) should subclass directly.

Sequential file formats (e.g. Fasta, GenBank) should subclass
the SequentialSequenceWriter class instead.

Definition at line 134 of file Interfaces.py.


Constructor & Destructor Documentation

def Bio.SeqIO.Interfaces.SequenceWriter.__init__ (   self,
  handle 
)
Creates the writer object.

Use the method write_file() to actually record your sequence records.

Reimplemented in Bio.SeqIO.Interfaces.SequentialSequenceWriter, and Bio.SeqIO.PhdIO.PhdWriter.

Definition at line 142 of file Interfaces.py.

00142 
00143     def __init__(self, handle):
00144         """Creates the writer object.
00145 
00146         Use the method write_file() to actually record your sequence records."""
00147         self.handle = handle

Here is the call graph for this function:


Member Function Documentation

def Bio.SeqIO.Interfaces.SequenceWriter._get_seq_string (   self,
  record 
) [private]
Use this to catch errors like the sequence being None.

Definition at line 148 of file Interfaces.py.

00148 
00149     def _get_seq_string(self, record):
00150         """Use this to catch errors like the sequence being None."""
00151         try:
00152             #The tostring() method is part of the Seq API, we could instead
00153             #use str(record.seq) but that would give a string "None" if the
00154             #sequence was None, and unpredicatable output if an unexpected
00155             #object was present.
00156             return record.seq.tostring()
00157         except AttributeError:
00158             if record.seq is None:
00159                 #We could silently treat this as an empty sequence, Seq(""),
00160                 #but that would be an implict assumption we should avoid.
00161                 raise TypeError("SeqRecord (id=%s) has None for its sequence." \
00162                                 % record.id)
00163             else:
00164                 raise TypeError("SeqRecord (id=%s) has an invalid sequence." \
00165                                 % record.id)

Here is the caller graph for this function:

def Bio.SeqIO.Interfaces.SequenceWriter.clean (   self,
  text 
)
Use this to avoid getting newlines in the output.

Definition at line 166 of file Interfaces.py.

00166 
00167     def clean(self, text):
00168         """Use this to avoid getting newlines in the output."""
00169         return text.replace("\n", " ").replace("\r", " ").replace("  ", " ")
    

Here is the caller graph for this function:

def Bio.SeqIO.Interfaces.SequenceWriter.write_file (   self,
  records 
)
Use this to write an entire file containing the given records.

records - A list or iterator returning SeqRecord objects

Should return the number of records (as an integer).

This method can only be called once.

Reimplemented in Bio.SeqIO.SffIO.SffWriter, and Bio.SeqIO.Interfaces.SequentialSequenceWriter.

Definition at line 170 of file Interfaces.py.

00170 
00171     def write_file(self, records):
00172         """Use this to write an entire file containing the given records.
00173 
00174         records - A list or iterator returning SeqRecord objects
00175 
00176         Should return the number of records (as an integer).
00177 
00178         This method can only be called once."""
00179         #Note when implementing this, your writer class should NOT close the
00180         #file at the end, but the calling code should.
00181         raise NotImplementedError("This object should be subclassed")
00182         #####################################################
00183         # You SHOULD subclass this                          #
00184         #####################################################

Here is the caller graph for this function:


Member Data Documentation


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