Package schrodinger :: Module structure :: Class MaestroReaderWithPositions
[hide private]
[frames] | no frames]

Class MaestroReaderWithPositions

                 object --+            
                          |            
_ReaderWriterContextManager --+        
                              |        
                   FormatReader --+    
                                  |    
                      MaestroReader --+
                                      |
                                     MaestroReaderWithPositions

A class for rapid random access to the structures in a Maestro file. Structures are read from a user-specified sequence of file positions (offsets). Here is one how one might use it to sort an input structure by glide score ('r_i_glide_gscore'):

   # Read input file, accumulating a list of glide scores and file
   # positions:
   reader = structure.MaestroReader('input.mae')
   position_list = []
   for st in reader:
       position_list.append((st.property['r_i_glide_gscore'],
               reader.last_position))

   # Sort by glide score:
   position_list.sort()

   # Obtain a list of file positions from the sorted list:
   positions = [record[1] for record in position_list]

   # Read input file in sorted order and write the structures to output:
   reader = structure.MaestroReaderWithPositions('input.mae', positions)
   writer = structure.MaestroWriter('output.mae')
   for st in reader:
       writer.append(st)
Instance Methods [hide private]
 
__init__(self, filename, positions, error_handler=None)
Like MaestroReader.__init__(), except here there is no optional index argument; instead, the user must supply a 'positions' argument, which must be an iterable giving file offsets for the structures to be read.
 
next(self)
Return the next requested Structure object from the file.

Inherited from MaestroReader: __del__, __iter__, close, getErrorHandler, read, seek

Inherited from MaestroReader (private): _open

Inherited from FormatReader: clearReadErrors, getReadErrors, startErrorQueuing, stopErrorQueuing

Inherited from _ReaderWriterContextManager: __enter__, __exit__

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

Class Variables [hide private]

Inherited from MaestroReader: read_mode

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename, positions, error_handler=None)
(Constructor)

 

Like MaestroReader.__init__(), except here there is no optional index argument; instead, the user must supply a 'positions' argument, which must be an iterable giving file offsets for the structures to be read.

Parameters:
  • filename - The filename to read.
  • index - The index of the first structure to read.
  • error_handler - The handle of the mmerr object to use for error logging. Defaults to schrodinger.infra.mm.error_handler.
  • input_string - A string with the contents of a Maestro format file. If provided, the filename argument is ignored.
Overrides: object.__init__

next(self)

 

Return the next requested Structure object from the file. Set self.last_position to the file offset it was read from.

Raises:
  • StopIteration - on EOF or zero size file.
Overrides: MaestroReader.next