Package tfasta :: Module tfasta_templates :: Class FastaTemplate
[hide private]
[frames] | no frames]

Class FastaTemplate

source code

This class encapsulates template information for parsing fasta files. Wraps a regular expression (regex) used to parse the first line of a fasta record and also a tuple of strings (fields) that name the information contained in the first line of the fasta record.

Instance Methods [hide private]
 
__init__(self, regex, fields) source code
_sre.SRE_Match
match(self, astring)
Returns a _sre.SRE_Match object describing the results of using self._regex to search string.
source code
 
set_regex(self, rgx)
Sets the regex property to rgx, a _sre.SRE_Pattern.
source code
 
set_fields(self, ary)
Sets the fields property to ary, a tuple of strings.
source code
_sre.SRE_Pattern
get_regex(self)
Returns the regex property.
source code
tuple
get_fields(self)
Returns the fields property.
source code
str
get_field(self, n)
Given the int index n, return the field at that index.
source code
Properties [hide private]
_sre.SRE_Pattern regex
Returns the regex property.
tuple fields
Returns the fields property.
Method Details [hide private]

__init__(self, regex, fields)
(Constructor)

source code 
Parameters:
  • regex (_sre.SRE_Pattern) - the compiled _sre.SRE_Pattern with which to parse the file
  • fields (tuple) - a tuple of strings containing names of the fields found by parsing the first line of the fasta record

match(self, astring)

source code 

Returns a _sre.SRE_Match object describing the results of using self._regex to search string.

Parameters:
  • astring (str) - a string generally containing a line of the fasta file being processed
Returns: _sre.SRE_Match
_sre.SRE_Match object describing the results of using self._regex to search string

set_regex(self, rgx)

source code 

Sets the regex property to rgx, a _sre.SRE_Pattern.

Parameters:
  • rgx (_sre.SRE_Pattern) - a compiled regular expression of the re module

set_fields(self, ary)

source code 

Sets the fields property to ary, a tuple of strings.

Parameters:
  • ary (tuple) - a tuple of strings naming the fields of the type of fasta records

get_regex(self)

source code 

Returns the regex property.

Returns: _sre.SRE_Pattern
the regex property

get_fields(self)

source code 

Returns the fields property.

Returns: tuple
the fields propery

get_field(self, n)

source code 

Given the int index n, return the field at that index.

Returns: str
the name of the field in the fields property at the index n

Property Details [hide private]

regex

Returns the regex property.

Get Method:
get_regex(self) - Returns the regex property.
Set Method:
set_regex(self, rgx) - Sets the regex property to rgx, a _sre.SRE_Pattern.
Type:
_sre.SRE_Pattern

fields

Returns the fields property.

Get Method:
get_fields(self) - Returns the fields property.
Set Method:
set_fields(self, ary) - Sets the fields property to ary, a tuple of strings.
Type:
tuple