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

Class StructureReader

                 object --+    
                          |    
_ReaderWriterContextManager --+
                              |
                             StructureReader

Read structures from files of various types.

The format is automatically determined from the extension of the specified file, or can be specified via the format option.

Example usage:

   # Read the first structure in a file:
   st = structure.StructureReader('myfile.pdb').next()

   # Read all structures from a file:
   for st in structure.StructureReader('myfile.sdf'):
       <do something with st>

   # Start reading at the second structure entry in the file
   for st in structure.StructureReader('myfile.sdf', index=2):
       <do something with st>

   # Assign iterator to a variable and read first 2 structures:
   st_reader = structure.StructureReader('myfile.mae')
   st1 = st_reader.next()
   st2 = st_reader.next()
Instance Methods [hide private]
 
__init__(self, filename=None, index=1, error_handler=None, format=None, ignore_errors=False, input_string=None)
The format is determined from the file extension if no format is specified.
 
_set_iterator(self, filename, index, error_handler, format, ignore_errors, input_string)
Set the iterator attribute.
 
__iter__(self)
 
next(self)
 
close(self)
 
getReadErrors(self)
Return any queued read errors.
 
clearReadErrors(self)
Clear any queued read errors.

Inherited from _ReaderWriterContextManager: __enter__, __exit__

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

Static Methods [hide private]
 
fromString(input_string, index=1, error_handler=None, format='maestro', ignore_errors=False)
Create a StructureReader from an input string.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename=None, index=1, error_handler=None, format=None, ignore_errors=False, input_string=None)
(Constructor)

 

The format is determined from the file extension if no format is specified.

Parameters:
  • filename (str) - The filename to read.
  • index (int) - The index of the first structure to read.
  • error_handler (int) - The handle of the mmerr object to use for error logging. Defaults to schrodinger.infra.mm.error_handler.
  • format (str) - The format of the file, either 'pdb', 'sd', 'mol2', 'maestro' or 'maestro_text' (determined from file extension by default).
  • ignore_errors (bool) - If True, bad structures will be skipped instead of raising an exception. Currently only used by the SD reader.
  • input_string (str) - Use of this argument is pending deprecation. Please use the StructureReader.fromString static method instead. If this is specified then the structure will be read from this string and the filename will be ignored. The format must be specified. Currently this is only supported for Maestro and SD format.
Overrides: object.__init__

fromString(input_string, index=1, error_handler=None, format='maestro', ignore_errors=False)
Static Method

 

Create a StructureReader from an input string. Currently this is only supported for Maestro and SD format.

Parameters:
  • input_string (str) - The string representation of the Structure.
  • index (int) - The index of the first structure to read.
  • error_handler (int) - The handle of the mmerr object to use for error logging. Defaults to schrodinger.infra.mm.error_handler.
  • format (str) - The format of the file, either SD ('sd') or MAESTRO ('maestro'). Defaults to MAESTRO.
  • ignore_errors (bool) - If True, bad structures will be skipped instead of raising an exception. Currently only used by the SD reader.