4747from sire import convert as _sire_convert
4848from sire import smiles as _sire_smiles
4949
50+ import sire .legacy .Base as _SireBase
5051import sire .legacy .Mol as _SireMol
5152import sire .legacy .System as _SireSystem
5253import sire .legacy .Vol as _SireVol
@@ -146,7 +147,7 @@ def supportedFormats():
146147 return _sire_convert .supported_formats ()
147148
148149
149- def to (obj , format = "biosimspace" , property_map = {}):
150+ def to (obj , format = "biosimspace" , property_map = {}, ** kwargs ):
150151 """
151152 Convert an object to a specified format.
152153
@@ -187,6 +188,13 @@ def to(obj, format="biosimspace", property_map={}):
187188 if not isinstance (property_map , dict ):
188189 raise TypeError ("'property_map' must be of type 'dict'." )
189190
191+ # Check for force_stereo_inference in kwargs.
192+ if "force_stereo_inference" in kwargs :
193+ force_stereo_inference = kwargs ["force_stereo_inference" ]
194+ if not isinstance (force_stereo_inference , bool ):
195+ raise TypeError ("'force_stereo_inference' must be of type 'bool'." )
196+ property_map ["force_stereo_inference" ] = _SireBase .wrap (force_stereo_inference )
197+
190198 # Special handling for OpenMM conversion. Currently this is a one-way (toOpenMM)
191199 # conversion only and is only supported for specific Sire and BioSimSpace types.
192200 if format == "openmm" :
@@ -508,7 +516,7 @@ def toOpenMM(obj, property_map={}):
508516 )
509517
510518
511- def toRDKit (obj , property_map = {}):
519+ def toRDKit (obj , force_stereo_inference = False , property_map = {}):
512520 """
513521 Convert an object to RDKit format.
514522
@@ -518,6 +526,11 @@ def toRDKit(obj, property_map={}):
518526 obj :
519527 The input object to convert.
520528
529+ bool : force_stereo_inference
530+ Whether to force inference of stereochemistry, overriding any
531+ stereochemistry present in the input object. This is useful when
532+ the object has been loaded from a file with invalid stereochemistry.
533+
521534 property_map : dict
522535 A dictionary that maps system "properties" to their user defined
523536 values. This allows the user to refer to properties with their
@@ -529,6 +542,15 @@ def toRDKit(obj, property_map={}):
529542 converted_obj :
530543 The object in OpenMM format.
531544 """
545+
546+ if not isinstance (force_stereo_inference , bool ):
547+ raise TypeError ("'force_stereo_inference' must be of type 'bool'." )
548+
549+ if not isinstance (property_map , dict ):
550+ raise TypeError ("'property_map' must be of type 'dict'." )
551+
552+ property_map ["force_stereo_inference" ] = _SireBase .wrap (force_stereo_inference )
553+
532554 return to (obj , format = "rdkit" , property_map = property_map )
533555
534556
0 commit comments