Package csb :: Package bio :: Package io :: Module fasta :: Class BaseSequenceParser

[frames] | no frames]

# Class BaseSequenceParser

source code

    object --+
             |
            BaseSequenceParser

Known Subclasses:
  - SequenceParser

FASTA parser template. Subclasses must implement the way FASTA strings are handled by overriding `BaseSequenceParser.read_sequence`.

Nested Classes
| __metaclass__ Metaclass for defining Abstract Base Classes (ABCs).

Instance Methods

__init__(self, product=<class 'csb.bio.sequence.Sequence'>, product_type=Protein) x.__init__(...) initializes x; see help(type(x)) for signature | source code

SequenceCollection

parse_file(self, fasta_file) Read FASTA sequences from a (m)FASTA file | source code

SequenceCollection

parse_string(self, fasta_string) Read FASTA sequences from an (m)FASTA-formatted string | source code

iterator

read(self, fasta_file) Read FASTA sequences from an (m)FASTA file. | source code

AbstractSequence

read_sequence(self, string) Parse a single FASTA string | source code

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

Class Variables
| __abstractmethods__ = ``frozenset([``'``read_sequence``'``])``

Properties
class | product_factory Factory used to build sequence products
enum item | product_type Default sequence type of the products - a member of SequenceTypes
Inherited from `object`: `__class__`

Method Details

### __init__(self, product=<class 'csb.bio.sequence.Sequence'>, product_type=Protein)
(Constructor)

source code

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  - `product` (type) - sequence product factory (an AbstractSequence subclass)
  - `product_type` (EnumItem) - default SequenceTypes member for the products
Overrides: object.__init__
  (inherited documentation)

### parse_file(self, fasta_file)

source code

Read FASTA sequences from a (m)FASTA file

Parameters:
  - `fasta_file` (str, file) - input FASTA file name or opened stream
Returns: SequenceCollection
  a list of Sequences
Raises:
  - `SequenceFormatError` - on parse error

### parse_string(self, fasta_string)

source code

Read FASTA sequences from an (m)FASTA-formatted string

Parameters:
  - `fasta_string` (str) - FASTA string to parse
Returns: SequenceCollection
  a list of Sequences
Raises:
  - `SequenceFormatError` - on parse error

### read(self, fasta_file)

source code

Read FASTA sequences from an (m)FASTA file.

Parameters:
  - `fasta_file` (str, file) - input FASTA file name or opened stream
Returns: iterator
  efficient cursor over all Sequences (parse on demand)
Raises:
  - `SequenceFormatError` - on parse error

### read_sequence(self, string)

source code

Parse a single FASTA string

Returns: AbstractSequence
  a new sequence, created with BaseSequenceParser.product_factory
Raises:
  - `SequenceFormatError` - on parse error

Property Details

### product_factory

Factory used to build sequence products

Get Method:
  unreachable.product_factory(self) - Factory used to build sequence products
Type:
  class

### product_type

Default sequence type of the products - a member of SequenceTypes

Get Method:
  unreachable.product_type(self) - Default sequence type of the products - a member of SequenceTypes
Type:
  enum item