schrodinger.seam.io.chemio module

Transforms for reading and writing structures and molecules.

class schrodinger.seam.io.chemio.ReadStructuresFromFile(file_pattern: str, **kwargs)

Bases: apache_beam.typehints.decorators.WithTypeHints, apache_beam.transforms.display.HasDisplayData, Generic[apache_beam.transforms.ptransform.InputT, apache_beam.transforms.ptransform.OutputT]

Read a file (or files) containing a structure or a list of structures and return a PCollection of schrodinger.structure.Structure objects.

__init__(file_pattern: str, **kwargs) None
Args:
file_pattern: A file name or glob pattern. For example,

“foo.mae” or “foo*.mae”.

expand(pcoll)
annotations() Dict[str, Union[bytes, str, google.protobuf.message.Message]]
default_label() str
default_type_hints()
display_data() dict

Returns the display data associated to a pipeline component.

It should be reimplemented in pipeline components that wish to have static display data.

Returns:

Dict[str, Any]: A dictionary containing key:value pairs. The value might be an integer, float or string value; a DisplayDataItem for values that have more data (e.g. short value, label, url); or a HasDisplayData instance that has more display data that should be picked up. For example:

{
  'key1': 'string_value',
  'key2': 1234,
  'key3': 3.14159265,
  'key4': DisplayDataItem('apache.org', url='http://apache.org'),
  'key5': subComponent
}
classmethod from_runner_api(proto: Optional[beam_runner_api_pb2.PTransform], context: PipelineContext) Optional[PTransform]
get_resource_hints() Dict[str, bytes]
get_type_hints()

Gets and/or initializes type hints for this object.

If type hints have not been set, attempts to initialize type hints in this order: - Using self.default_type_hints(). - Using self.__class__ type hints.

get_windowing(inputs: Any) Windowing

Returns the window function to be associated with transform’s output.

By default most transforms just return the windowing function associated with the input PCollection (or the first input if several).

infer_output_type(unused_input_type)
property label
pipeline: Optional[Pipeline] = None
classmethod register_urn(urn, parameter_type, constructor=None)
runner_api_requires_keyed_input()
side_inputs: Sequence[pvalue.AsSideInput] = ()
to_runner_api(context: PipelineContext, has_parts: bool = False, **extra_kwargs: Any) beam_runner_api_pb2.FunctionSpec
to_runner_api_parameter(unused_context: PipelineContext) Tuple[str, Optional[Union[message.Message, bytes, str]]]
to_runner_api_pickled(unused_context: PipelineContext) Tuple[str, bytes]
type_check_inputs(pvalueish)
type_check_inputs_or_outputs(pvalueish, input_or_output)
type_check_outputs(pvalueish)
with_input_types(input_type_hint)

Annotates the input type of a PTransform with a type-hint.

Args:
input_type_hint (type): An instance of an allowed built-in type, a custom

class, or an instance of a TypeConstraint.

Raises:
TypeError: If input_type_hint is not a valid type-hint.

See apache_beam.typehints.typehints.validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_output_types(type_hint)

Annotates the output type of a PTransform with a type-hint.

Args:
type_hint (type): An instance of an allowed built-in type, a custom class,

or a TypeConstraint.

Raises:
TypeError: If type_hint is not a valid type-hint. See

validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_resource_hints(**kwargs) apache_beam.transforms.ptransform.PTransform

Adds resource hints to the PTransform.

Resource hints allow users to express constraints on the environment where the transform should be executed. Interpretation of the resource hints is defined by Beam Runners. Runners may ignore the unsupported hints.

Args:

**kwargs: key-value pairs describing hints and their values.

Raises:
ValueError: if provided hints are unknown to the SDK. See

apache_beam.transforms.resources for a list of known hints.

Returns:

PTransform: A reference to the instance of this particular PTransform object.

class schrodinger.seam.io.chemio.ReadAllStructuresFromFile(label: Optional[str] = None)

Bases: apache_beam.typehints.decorators.WithTypeHints, apache_beam.transforms.display.HasDisplayData, Generic[apache_beam.transforms.ptransform.InputT, apache_beam.transforms.ptransform.OutputT]

A PTransform for reading a PCollection of structure files.

expand(pcoll)
__init__(label: Optional[str] = None) None
annotations() Dict[str, Union[bytes, str, google.protobuf.message.Message]]
default_label() str
default_type_hints()
display_data() dict

Returns the display data associated to a pipeline component.

It should be reimplemented in pipeline components that wish to have static display data.

Returns:

Dict[str, Any]: A dictionary containing key:value pairs. The value might be an integer, float or string value; a DisplayDataItem for values that have more data (e.g. short value, label, url); or a HasDisplayData instance that has more display data that should be picked up. For example:

{
  'key1': 'string_value',
  'key2': 1234,
  'key3': 3.14159265,
  'key4': DisplayDataItem('apache.org', url='http://apache.org'),
  'key5': subComponent
}
classmethod from_runner_api(proto: Optional[beam_runner_api_pb2.PTransform], context: PipelineContext) Optional[PTransform]
get_resource_hints() Dict[str, bytes]
get_type_hints()

Gets and/or initializes type hints for this object.

If type hints have not been set, attempts to initialize type hints in this order: - Using self.default_type_hints(). - Using self.__class__ type hints.

get_windowing(inputs: Any) Windowing

Returns the window function to be associated with transform’s output.

By default most transforms just return the windowing function associated with the input PCollection (or the first input if several).

infer_output_type(unused_input_type)
property label
pipeline: Optional[Pipeline] = None
classmethod register_urn(urn, parameter_type, constructor=None)
runner_api_requires_keyed_input()
side_inputs: Sequence[pvalue.AsSideInput] = ()
to_runner_api(context: PipelineContext, has_parts: bool = False, **extra_kwargs: Any) beam_runner_api_pb2.FunctionSpec
to_runner_api_parameter(unused_context: PipelineContext) Tuple[str, Optional[Union[message.Message, bytes, str]]]
to_runner_api_pickled(unused_context: PipelineContext) Tuple[str, bytes]
type_check_inputs(pvalueish)
type_check_inputs_or_outputs(pvalueish, input_or_output)
type_check_outputs(pvalueish)
with_input_types(input_type_hint)

Annotates the input type of a PTransform with a type-hint.

Args:
input_type_hint (type): An instance of an allowed built-in type, a custom

class, or an instance of a TypeConstraint.

Raises:
TypeError: If input_type_hint is not a valid type-hint.

See apache_beam.typehints.typehints.validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_output_types(type_hint)

Annotates the output type of a PTransform with a type-hint.

Args:
type_hint (type): An instance of an allowed built-in type, a custom class,

or a TypeConstraint.

Raises:
TypeError: If type_hint is not a valid type-hint. See

validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_resource_hints(**kwargs) apache_beam.transforms.ptransform.PTransform

Adds resource hints to the PTransform.

Resource hints allow users to express constraints on the environment where the transform should be executed. Interpretation of the resource hints is defined by Beam Runners. Runners may ignore the unsupported hints.

Args:

**kwargs: key-value pairs describing hints and their values.

Raises:
ValueError: if provided hints are unknown to the SDK. See

apache_beam.transforms.resources for a list of known hints.

Returns:

PTransform: A reference to the instance of this particular PTransform object.

class schrodinger.seam.io.chemio.WriteStructuresToFile(file_name: str, **kwargs)

Bases: apache_beam.typehints.decorators.WithTypeHints, apache_beam.transforms.display.HasDisplayData, Generic[apache_beam.transforms.ptransform.InputT, apache_beam.transforms.ptransform.OutputT]

Write a PCollection of schrodinger.structure.Structure objects to a file.

The file format is determined by the file extension. See schrodinger.structure.StructureWriter for more details.

Raises

ValueError – if the file already exists

__init__(file_name: str, **kwargs) None
expand(pcoll)
annotations() Dict[str, Union[bytes, str, google.protobuf.message.Message]]
default_label() str
default_type_hints()
display_data() dict

Returns the display data associated to a pipeline component.

It should be reimplemented in pipeline components that wish to have static display data.

Returns:

Dict[str, Any]: A dictionary containing key:value pairs. The value might be an integer, float or string value; a DisplayDataItem for values that have more data (e.g. short value, label, url); or a HasDisplayData instance that has more display data that should be picked up. For example:

{
  'key1': 'string_value',
  'key2': 1234,
  'key3': 3.14159265,
  'key4': DisplayDataItem('apache.org', url='http://apache.org'),
  'key5': subComponent
}
classmethod from_runner_api(proto: Optional[beam_runner_api_pb2.PTransform], context: PipelineContext) Optional[PTransform]
get_resource_hints() Dict[str, bytes]
get_type_hints()

Gets and/or initializes type hints for this object.

If type hints have not been set, attempts to initialize type hints in this order: - Using self.default_type_hints(). - Using self.__class__ type hints.

get_windowing(inputs: Any) Windowing

Returns the window function to be associated with transform’s output.

By default most transforms just return the windowing function associated with the input PCollection (or the first input if several).

infer_output_type(unused_input_type)
property label
pipeline: Optional[Pipeline] = None
classmethod register_urn(urn, parameter_type, constructor=None)
runner_api_requires_keyed_input()
side_inputs: Sequence[pvalue.AsSideInput] = ()
to_runner_api(context: PipelineContext, has_parts: bool = False, **extra_kwargs: Any) beam_runner_api_pb2.FunctionSpec
to_runner_api_parameter(unused_context: PipelineContext) Tuple[str, Optional[Union[message.Message, bytes, str]]]
to_runner_api_pickled(unused_context: PipelineContext) Tuple[str, bytes]
type_check_inputs(pvalueish)
type_check_inputs_or_outputs(pvalueish, input_or_output)
type_check_outputs(pvalueish)
with_input_types(input_type_hint)

Annotates the input type of a PTransform with a type-hint.

Args:
input_type_hint (type): An instance of an allowed built-in type, a custom

class, or an instance of a TypeConstraint.

Raises:
TypeError: If input_type_hint is not a valid type-hint.

See apache_beam.typehints.typehints.validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_output_types(type_hint)

Annotates the output type of a PTransform with a type-hint.

Args:
type_hint (type): An instance of an allowed built-in type, a custom class,

or a TypeConstraint.

Raises:
TypeError: If type_hint is not a valid type-hint. See

validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_resource_hints(**kwargs) apache_beam.transforms.ptransform.PTransform

Adds resource hints to the PTransform.

Resource hints allow users to express constraints on the environment where the transform should be executed. Interpretation of the resource hints is defined by Beam Runners. Runners may ignore the unsupported hints.

Args:

**kwargs: key-value pairs describing hints and their values.

Raises:
ValueError: if provided hints are unknown to the SDK. See

apache_beam.transforms.resources for a list of known hints.

Returns:

PTransform: A reference to the instance of this particular PTransform object.

class schrodinger.seam.io.chemio.ReadMolsFromFile(file_pattern: str, silent=False, **kwargs)

Bases: apache_beam.typehints.decorators.WithTypeHints, apache_beam.transforms.display.HasDisplayData, Generic[apache_beam.transforms.ptransform.InputT, apache_beam.transforms.ptransform.OutputT]

Read a file containing a newline separated list of SMILES strings and return a PCollection of RDKit molecules.

Invalid SMILES strings are skipped. A warning is printed if silent is set to False.

__init__(file_pattern: str, silent=False, **kwargs) None
expand(pcoll)
annotations() Dict[str, Union[bytes, str, google.protobuf.message.Message]]
default_label() str
default_type_hints()
display_data() dict

Returns the display data associated to a pipeline component.

It should be reimplemented in pipeline components that wish to have static display data.

Returns:

Dict[str, Any]: A dictionary containing key:value pairs. The value might be an integer, float or string value; a DisplayDataItem for values that have more data (e.g. short value, label, url); or a HasDisplayData instance that has more display data that should be picked up. For example:

{
  'key1': 'string_value',
  'key2': 1234,
  'key3': 3.14159265,
  'key4': DisplayDataItem('apache.org', url='http://apache.org'),
  'key5': subComponent
}
classmethod from_runner_api(proto: Optional[beam_runner_api_pb2.PTransform], context: PipelineContext) Optional[PTransform]
get_resource_hints() Dict[str, bytes]
get_type_hints()

Gets and/or initializes type hints for this object.

If type hints have not been set, attempts to initialize type hints in this order: - Using self.default_type_hints(). - Using self.__class__ type hints.

get_windowing(inputs: Any) Windowing

Returns the window function to be associated with transform’s output.

By default most transforms just return the windowing function associated with the input PCollection (or the first input if several).

infer_output_type(unused_input_type)
property label
pipeline: Optional[Pipeline] = None
classmethod register_urn(urn, parameter_type, constructor=None)
runner_api_requires_keyed_input()
side_inputs: Sequence[pvalue.AsSideInput] = ()
to_runner_api(context: PipelineContext, has_parts: bool = False, **extra_kwargs: Any) beam_runner_api_pb2.FunctionSpec
to_runner_api_parameter(unused_context: PipelineContext) Tuple[str, Optional[Union[message.Message, bytes, str]]]
to_runner_api_pickled(unused_context: PipelineContext) Tuple[str, bytes]
type_check_inputs(pvalueish)
type_check_inputs_or_outputs(pvalueish, input_or_output)
type_check_outputs(pvalueish)
with_input_types(input_type_hint)

Annotates the input type of a PTransform with a type-hint.

Args:
input_type_hint (type): An instance of an allowed built-in type, a custom

class, or an instance of a TypeConstraint.

Raises:
TypeError: If input_type_hint is not a valid type-hint.

See apache_beam.typehints.typehints.validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_output_types(type_hint)

Annotates the output type of a PTransform with a type-hint.

Args:
type_hint (type): An instance of an allowed built-in type, a custom class,

or a TypeConstraint.

Raises:
TypeError: If type_hint is not a valid type-hint. See

validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_resource_hints(**kwargs) apache_beam.transforms.ptransform.PTransform

Adds resource hints to the PTransform.

Resource hints allow users to express constraints on the environment where the transform should be executed. Interpretation of the resource hints is defined by Beam Runners. Runners may ignore the unsupported hints.

Args:

**kwargs: key-value pairs describing hints and their values.

Raises:
ValueError: if provided hints are unknown to the SDK. See

apache_beam.transforms.resources for a list of known hints.

Returns:

PTransform: A reference to the instance of this particular PTransform object.

class schrodinger.seam.io.chemio.WriteMolsToFile(file_name: str, **kwargs)

Bases: apache_beam.typehints.decorators.WithTypeHints, apache_beam.transforms.display.HasDisplayData, Generic[apache_beam.transforms.ptransform.InputT, apache_beam.transforms.ptransform.OutputT]

Write a PCollection of RDKit molecules to a file as a newline separated list of SMILES strings.

Raises

ValueError – if the file already exists

__init__(file_name: str, **kwargs) None
expand(pcoll)
annotations() Dict[str, Union[bytes, str, google.protobuf.message.Message]]
default_label() str
default_type_hints()
display_data() dict

Returns the display data associated to a pipeline component.

It should be reimplemented in pipeline components that wish to have static display data.

Returns:

Dict[str, Any]: A dictionary containing key:value pairs. The value might be an integer, float or string value; a DisplayDataItem for values that have more data (e.g. short value, label, url); or a HasDisplayData instance that has more display data that should be picked up. For example:

{
  'key1': 'string_value',
  'key2': 1234,
  'key3': 3.14159265,
  'key4': DisplayDataItem('apache.org', url='http://apache.org'),
  'key5': subComponent
}
classmethod from_runner_api(proto: Optional[beam_runner_api_pb2.PTransform], context: PipelineContext) Optional[PTransform]
get_resource_hints() Dict[str, bytes]
get_type_hints()

Gets and/or initializes type hints for this object.

If type hints have not been set, attempts to initialize type hints in this order: - Using self.default_type_hints(). - Using self.__class__ type hints.

get_windowing(inputs: Any) Windowing

Returns the window function to be associated with transform’s output.

By default most transforms just return the windowing function associated with the input PCollection (or the first input if several).

infer_output_type(unused_input_type)
property label
pipeline: Optional[Pipeline] = None
classmethod register_urn(urn, parameter_type, constructor=None)
runner_api_requires_keyed_input()
side_inputs: Sequence[pvalue.AsSideInput] = ()
to_runner_api(context: PipelineContext, has_parts: bool = False, **extra_kwargs: Any) beam_runner_api_pb2.FunctionSpec
to_runner_api_parameter(unused_context: PipelineContext) Tuple[str, Optional[Union[message.Message, bytes, str]]]
to_runner_api_pickled(unused_context: PipelineContext) Tuple[str, bytes]
type_check_inputs(pvalueish)
type_check_inputs_or_outputs(pvalueish, input_or_output)
type_check_outputs(pvalueish)
with_input_types(input_type_hint)

Annotates the input type of a PTransform with a type-hint.

Args:
input_type_hint (type): An instance of an allowed built-in type, a custom

class, or an instance of a TypeConstraint.

Raises:
TypeError: If input_type_hint is not a valid type-hint.

See apache_beam.typehints.typehints.validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_output_types(type_hint)

Annotates the output type of a PTransform with a type-hint.

Args:
type_hint (type): An instance of an allowed built-in type, a custom class,

or a TypeConstraint.

Raises:
TypeError: If type_hint is not a valid type-hint. See

validate_composite_type_param() for further details.

Returns:

PTransform: A reference to the instance of this particular PTransform object. This allows chaining type-hinting related methods.

with_resource_hints(**kwargs) apache_beam.transforms.ptransform.PTransform

Adds resource hints to the PTransform.

Resource hints allow users to express constraints on the environment where the transform should be executed. Interpretation of the resource hints is defined by Beam Runners. Runners may ignore the unsupported hints.

Args:

**kwargs: key-value pairs describing hints and their values.

Raises:
ValueError: if provided hints are unknown to the SDK. See

apache_beam.transforms.resources for a list of known hints.

Returns:

PTransform: A reference to the instance of this particular PTransform object.