예제 #1
0
 def __init__(self, filename, format):
     """Initialize the class."""
     self._handle = _open_for_random_access(filename)
     self._format = format
     # Load the parser class/function once an avoid the dict lookup in each
     # __getitem__ call:
     self._iterator = SeqIO._FormatToIterator[format]
예제 #2
0
    def __init__(self, filename, format, alphabet):
        """Initialize the class."""
        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
예제 #3
0
 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
예제 #4
0
 def __init__(self, filename, **kwargs):
     self._handle = _open_for_random_access(filename)
     self._kwargs = kwargs
예제 #5
0
 def __init__(self, filename, **kwargs):
     """Initialize the class."""
     self._handle = _open_for_random_access(filename)
     self._kwargs = kwargs