def __init__(self, filename, format, alphabet): self._handle = _open_for_random_access(filename) self._alphabet = alphabet self._format = format # Load the parser class/function once an avoid the dict lookup in each # __getitem__ call: i = SeqIO._FormatToIterator[format] # The following alphabet code is a bit nasty... duplicates logic in # Bio.SeqIO.parse() if alphabet is None: def _parse(handle): """Dynamically generated parser function (PRIVATE).""" return next(i(handle)) else: # TODO - Detect alphabet support ONCE at __init__ def _parse(handle): """Dynamically generated parser function (PRIVATE).""" try: return next(i(handle, alphabet=alphabet)) except TypeError: return next(SeqIO._force_alphabet(i(handle), alphabet)) self._parse = _parse
def __init__(self, filename, format, alphabet): self._handle = _open_for_random_access(filename) self._alphabet = alphabet self._format = format #Load the parser class/function once an avoid the dict lookup in each #__getitem__ call: i = SeqIO._FormatToIterator[format] #The following alphabet code is a bit nasty... duplicates logic in #Bio.SeqIO.parse() if alphabet is None: def _parse(handle): """Dynamically generated parser function (PRIVATE).""" return next(i(handle)) else: #TODO - Detect alphabet support ONCE at __init__ def _parse(handle): """Dynamically generated parser function (PRIVATE).""" try: return next(i(handle, alphabet=alphabet)) except TypeError: return next(SeqIO._force_alphabet(i(handle), alphabet)) self._parse = _parse
def __init__(self, filename, **kwargs): self._handle = _open_for_random_access(filename) self._kwargs = kwargs