Back to index

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

List of all members.

Public Member Functions

def __init__
def write_header
def write_footer
def write_record
def write_records
def write_file
def clean

Public Attributes

 handle

Private Attributes

 _header_written
 _record_written
 _footer_written

Detailed Description

This class should be subclassed.

It is intended for sequential file formats with an (optional)
header, repeated records, and an (optional) footer.

In this case (as with interlaced file formats), the user may
simply call the write_file() method and be done.

However, they may also call the write_header(), followed
by multiple calls to write_record() and/or write_records()
followed finally by write_footer().

Users must call write_header() and write_footer() even when
the file format concerned doesn't have a header or footer.
This is to try and make life as easy as possible when
switching the output format.

Note that write_header() cannot require any assumptions about
the number of records.

Definition at line 185 of file Interfaces.py.


Constructor & Destructor Documentation

Creates the writer object.

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

Reimplemented from Bio.SeqIO.Interfaces.SequenceWriter.

Reimplemented in Bio.SeqIO.PhdIO.PhdWriter.

Definition at line 206 of file Interfaces.py.

00206 
00207     def __init__(self, handle):
00208         self.handle = handle
00209         self._header_written = False
00210         self._record_written = False
00211         self._footer_written = False


Member Function Documentation

def Bio.SeqIO.Interfaces.SequenceWriter.clean (   self,
  text 
) [inherited]
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:

Use this to write an entire file containing the given records.

records - A list or iterator returning SeqRecord objects

This method can only be called once.  Returns the number of records
written.

Reimplemented from Bio.SeqIO.Interfaces.SequenceWriter.

Definition at line 262 of file Interfaces.py.

00262 
00263     def write_file(self, records):
00264         """Use this to write an entire file containing the given records.
00265 
00266         records - A list or iterator returning SeqRecord objects
00267 
00268         This method can only be called once.  Returns the number of records
00269         written.
00270         """
00271         self.write_header()
00272         count = self.write_records(records)
00273         self.write_footer()
00274         return count

Here is the call graph for this function:

Definition at line 218 of file Interfaces.py.

00218 
00219     def write_footer(self):
00220         assert self._header_written, "You must call write_header() first"
00221         assert self._record_written, "You have not called write_record() or write_records() yet"
00222         assert not self._footer_written, "You have aleady called write_footer()"
00223         self._footer_written = True

Here is the caller graph for this function:

Definition at line 212 of file Interfaces.py.

00212 
00213     def write_header(self):
00214         assert not self._header_written, "You have aleady called write_header()"
00215         assert not self._record_written, "You have aleady called write_record() or write_records()"
00216         assert not self._footer_written, "You have aleady called write_footer()"
00217         self._header_written = True
        

Here is the caller graph for this function:

Write a single record to the output file.

record - a SeqRecord object

Once you have called write_header() you can call write_record()
and/or write_records() as many times as needed.  Then call
write_footer() and close().

Reimplemented in Bio.SeqIO.QualityIO.FastqIlluminaWriter, Bio.SeqIO.QualityIO.FastqSolexaWriter, Bio.SeqIO.QualityIO.QualPhredWriter, Bio.SeqIO.QualityIO.FastqPhredWriter, Bio.SeqIO.FastaIO.FastaWriter, Bio.SeqIO.PhdIO.PhdWriter, and Bio.SeqIO.TabIO.TabWriter.

Definition at line 224 of file Interfaces.py.

00224 
00225     def write_record(self, record):
00226         """Write a single record to the output file.
00227 
00228         record - a SeqRecord object
00229 
00230         Once you have called write_header() you can call write_record()
00231         and/or write_records() as many times as needed.  Then call
00232         write_footer() and close()."""
00233         assert self._header_written, "You must call write_header() first"
00234         assert not self._footer_written, "You have already called write_footer()"
00235         self._record_written = True
00236         raise NotImplementedError("This object should be subclassed")
00237         #####################################################
00238         # You SHOULD subclass this                          #
00239         #####################################################

Here is the call graph for this function:

Here is the caller graph for this function:

Write multiple record to the output file.

records - A list or iterator returning SeqRecord objects

Once you have called write_header() you can call write_record()
and/or write_records() as many times as needed.  Then call
write_footer() and close().

Returns the number of records written.

Definition at line 240 of file Interfaces.py.

00240 
00241     def write_records(self, records):
00242         """Write multiple record to the output file.
00243 
00244         records - A list or iterator returning SeqRecord objects
00245 
00246         Once you have called write_header() you can call write_record()
00247         and/or write_records() as many times as needed.  Then call
00248         write_footer() and close().
00249 
00250         Returns the number of records written.
00251         """
00252         #Default implementation:
00253         assert self._header_written, "You must call write_header() first"
00254         assert not self._footer_written, "You have already called write_footer()"
00255         count = 0
00256         for record in records:
00257             self.write_record(record)
00258             count += 1
00259         #Mark as true, even if there where no records
00260         self._record_written = True
00261         return count

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 210 of file Interfaces.py.

Definition at line 208 of file Interfaces.py.

Reimplemented from Bio.SeqIO.Interfaces.SequenceWriter.

Definition at line 207 of file Interfaces.py.


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