Package Bio :: Package SeqIO :: Module FastaIO :: Class FastaWriter
[hide private]
[frames] | no frames]

Class FastaWriter

source code

                     object --+        
                              |        
      Interfaces.SequenceWriter --+    
                                  |    
Interfaces.SequentialSequenceWriter --+
                                      |
                                     FastaWriter

Class to write Fasta format files.
Instance Methods [hide private]
 
__init__(self, handle, wrap=60, record2title=None)
Create a Fasta writer.
source code
 
write_record(self, record)
Write a single Fasta record to the file.
source code

Inherited from Interfaces.SequentialSequenceWriter: write_file, write_footer, write_header, write_records

Inherited from Interfaces.SequenceWriter: clean

Inherited from Interfaces.SequenceWriter (private): _get_seq_string

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, handle, wrap=60, record2title=None)
(Constructor)

source code 

Create a Fasta writer.

Arguements:

  • handle - Handle to an output file, e.g. as returned by open(filename, "w")
  • wrap - Optional line length used to wrap sequence lines. Defaults to wrapping the sequence at 60 characters Use zero (or None) for no wrapping, giving a single long line for the sequence.
  • record2title - Optional function to return the text to be used for the title line of each record. By default a combination of the record.id and record.description is used. If the record.description starts with the record.id, then just the record.description is used.

You can either use:

handle = open(filename, "w")
writer = FastaWriter(handle)
writer.write_file(myRecords)
handle.close()

Or, follow the sequential file writer system, for example:

handle = open(filename, "w")
writer = FastaWriter(handle)
writer.write_header() # does nothing for Fasta files
...
Multiple writer.write_record() and/or writer.write_records() calls
...
writer.write_footer() # does nothing for Fasta files
handle.close()
Overrides: object.__init__

write_record(self, record)

source code 
Write a single Fasta record to the file.
Overrides: Interfaces.SequentialSequenceWriter.write_record