schrodinger.application.livedesign.entry_types module

class schrodinger.application.livedesign.entry_types.BaseEntryData(structure_map)

Bases: schrodinger.ui.qt.appframework2.validation.ValidationMixin

Abstract class for storing and validating common data for all types of systems in anticipation of export to LiveDesign.

name = ''
description = ''
min_structures = 1
__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getProperties()
Returns

a set of structure property names

Return type

set[str]

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

checkNumEntries(**kwargs)
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

class schrodinger.application.livedesign.entry_types.GenericEntities(structure_map)

Bases: schrodinger.application.livedesign.entry_types.BaseEntryData

Class representing data type of Generic Entities, stores all data related to Generic Entities export.

name = 'Generic Entities'
__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

getStructures()

Return the structures.

Returns

structures

Return type

List[structure.Structure]

getProperties() Set[str]

Get a set of property names for all the structures

Returns

a set of structure property names

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

checkNumEntries(**kwargs)
description = ''
formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

min_structures = 1
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

class schrodinger.application.livedesign.entry_types.BaseReceptorLigandData(structure_map)

Bases: schrodinger.application.livedesign.entry_types.BaseEntryData

Abstract class for storing and validating data for various formats of ligand-based systems in anticipation of export to LiveDesign.

min_nodes = 1
node_str = ''
target_str = ''
entry_singular = 'entry'
__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

getNumTargets()
Returns

the number of unique targets in the system

Return type

int

getRLMap()
Returns

a copy of the stored receptor ligand map

Return type

data_classes.ReceptorLigandMap

getProperties() Set[str]

Get a set of property names for all ligands in rl_map

Returns

a set of structure property names

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

checkNumEntries(**kwargs)
description = ''
formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

min_structures = 1
name = ''
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

class schrodinger.application.livedesign.entry_types.IndividualStructureBase(structure_map)

Bases: schrodinger.application.livedesign.entry_types.BaseReceptorLigandData

Class representing data types for which each structure in the input receptor-ligand map is either a single target or a single node structure.

getNumNodes()
Returns

the number of unique nodes in this system

Return type

int

checkNumNodes(**kwargs)
__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

checkNumEntries(**kwargs)
description = ''
entry_singular = 'entry'
formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getNumTargets()
Returns

the number of unique targets in the system

Return type

int

getProperties() Set[str]

Get a set of property names for all ligands in rl_map

Returns

a set of structure property names

getRLMap()
Returns

a copy of the stored receptor ligand map

Return type

data_classes.ReceptorLigandMap

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

min_nodes = 1
min_structures = 1
name = ''
node_str = ''
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

target_str = ''
class schrodinger.application.livedesign.entry_types.TargetlessBase(structure_map)

Bases: schrodinger.application.livedesign.entry_types.IndividualStructureBase

Base class for data types that do not have a target structure. Subclasses must redefine max_num_atoms.

Variables

max_num_atoms (int) – the maximum number of atoms per structure

max_num_atoms = 0
checkNumAtoms(**kwargs)
__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

checkNumEntries(**kwargs)
checkNumNodes(**kwargs)
description = ''
entry_singular = 'entry'
formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getNumNodes()
Returns

the number of unique nodes in this system

Return type

int

getNumTargets()
Returns

the number of unique targets in the system

Return type

int

getProperties() Set[str]

Get a set of property names for all ligands in rl_map

Returns

a set of structure property names

getRLMap()
Returns

a copy of the stored receptor ligand map

Return type

data_classes.ReceptorLigandMap

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

min_nodes = 1
min_structures = 1
name = ''
node_str = ''
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

target_str = ''
class schrodinger.application.livedesign.entry_types.OrganometallicCompounds(structure_map)

Bases: schrodinger.application.livedesign.entry_types.TargetlessBase

name = 'Organometallic Compounds'
description = 'Upload organometallic compounds. Each compound must be its own entry.'
max_num_atoms = 700
node_str = 'organometallic compound'
getNumNodes()
Returns

the number of unique nodes in this system

Return type

int

__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

checkNumAtoms(**kwargs)
checkNumEntries(**kwargs)
checkNumNodes(**kwargs)
entry_singular = 'entry'
formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getNumTargets()
Returns

the number of unique targets in the system

Return type

int

getProperties() Set[str]

Get a set of property names for all ligands in rl_map

Returns

a set of structure property names

getRLMap()
Returns

a copy of the stored receptor ligand map

Return type

data_classes.ReceptorLigandMap

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

min_nodes = 1
min_structures = 1
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

target_str = ''
class schrodinger.application.livedesign.entry_types.Ligands(structure_map)

Bases: schrodinger.application.livedesign.entry_types.TargetlessBase

name = 'Ligands'
description = 'Upload ligands. Each ligand must be in its own entry. Non-ligand structures will be ignored.'
node_str = 'ligand'
__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

max_num_atoms = 0
checkNumAtoms(**kwargs)
checkNumEntries(**kwargs)
checkNumNodes(**kwargs)
entry_singular = 'entry'
formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getNumNodes()
Returns

the number of unique nodes in this system

Return type

int

getNumTargets()
Returns

the number of unique targets in the system

Return type

int

getProperties() Set[str]

Get a set of property names for all ligands in rl_map

Returns

a set of structure property names

getRLMap()
Returns

a copy of the stored receptor ligand map

Return type

data_classes.ReceptorLigandMap

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

min_nodes = 1
min_structures = 1
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

target_str = ''
class schrodinger.application.livedesign.entry_types.DockedPoses(structure_map)

Bases: schrodinger.application.livedesign.entry_types.IndividualStructureBase

name = 'Docked Poses'
description = 'Upload docked poses based on the PV format. Selection should include one receptor, in its own entry, and docked ligands, each in a separate entry.'
node_str = 'ligand'
target_str = 'receptor'
checkNumNodes(**kwargs)
checkTargets(**kwargs)
__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

checkNumEntries(**kwargs)
entry_singular = 'entry'
formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getNumNodes()
Returns

the number of unique nodes in this system

Return type

int

getNumTargets()
Returns

the number of unique targets in the system

Return type

int

getProperties() Set[str]

Get a set of property names for all ligands in rl_map

Returns

a set of structure property names

getRLMap()
Returns

a copy of the stored receptor ligand map

Return type

data_classes.ReceptorLigandMap

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

min_nodes = 1
min_structures = 1
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

class schrodinger.application.livedesign.entry_types.Complexes(structure_map)

Bases: schrodinger.application.livedesign.entry_types.BaseReceptorLigandData

name = 'Receptor-Ligand Complexes'
description = 'Upload receptor-ligand complexes. Selection should include at least one entry, where each entry includes a receptor and at least one ligand.'
node_str = 'ligand'
target_str = 'receptor'
getNumNodes()
Returns

the number of unique nodes in this system

Return type

int

checkTargets(**kwargs)
checkLigands(**kwargs)
__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

checkNumEntries(**kwargs)
entry_singular = 'entry'
formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getNumTargets()
Returns

the number of unique targets in the system

Return type

int

getProperties() Set[str]

Get a set of property names for all ligands in rl_map

Returns

a set of structure property names

getRLMap()
Returns

a copy of the stored receptor ligand map

Return type

data_classes.ReceptorLigandMap

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

min_nodes = 1
min_structures = 1
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

class schrodinger.application.livedesign.entry_types.CovalentDockingComplexes(structure_map)

Bases: schrodinger.application.livedesign.entry_types.Complexes

name = 'Covalent Docking Complexes'
description = 'Upload covalent docking structures. Selection should include outputs from the covalent docking panel. Uploaded ligands will be the original (input) structures prior to covalent docking processing.'
__init__(structure_map)
Parameters

structure_map (dict[str, structure.Structure]) – a dictionary mapping unique strings to structures from some system

checkLigands(**kwargs)
checkNumEntries(**kwargs)
checkTargets(**kwargs)
entry_singular = 'entry'
formatSummaryMessage(*msgs)

Returns a formatted summary string. Takes the form of ‘msg1 (msg2, msg3…)’

Parameters

msgs (str) – messages to separate

Returns

Formatted string

Return type

str

getNumNodes()
Returns

the number of unique nodes in this system

Return type

int

getNumTargets()
Returns

the number of unique targets in the system

Return type

int

getProperties() Set[str]

Get a set of property names for all ligands in rl_map

Returns

a set of structure property names

getRLMap()
Returns

a copy of the stored receptor ligand map

Return type

data_classes.ReceptorLigandMap

getSamplePropertyValue(prop_name: Optional[str]) Optional[str]

Get a sample property value if one is available

Parameters

prop_name – Property name

Returns

Property value

getSummary()

Return a summary of the receptor and ligand data stored in this object.

Returns

a summary of the data stored on this object

Return type

str

min_nodes = 1
min_structures = 1
node_str = 'ligand'
reportValidation(results)

Present validation messages to the user. This is an implmentation of the ValidationMixin interface and does not need to be called directly.

This method assumes that error and question methods have been defined in the subclass, as in e.g. widget_mixins.MessageBoxMixin.

Parameters

results (validation.ValidationResults) – Set of validation results generated by validate

Returns

if True, there were no validation errors and the user decided to continue despite any warnings. If False, there was at least one validation error or the user decided to abort when faced with a warning.

runValidation(silent=False, validate_children=True, stop_on_fail=True)

Runs validation and reports the results (unless run silently).

Parameters
  • silent (bool) – run without any reporting (i.e. error messages to the user). This is useful if we want to programmatically test validity. Changes return value of this method from ValidationResults to a boolean.

  • validate_children (bool) – run validation on all child objects. See _validateChildren for documentation on what this entails.

  • stop_on_fail (bool) – stop validation when first failure is encountered

Returns

if silent is False, returns the validation results. If silent is True, returns a boolean generated by reportValidation.

Return type

ValidationResults or bool

target_str = 'receptor'
schrodinger.application.livedesign.entry_types.separate_complex(complex_st)

Given a receptor-ligand complex structure, separate the ligands from the receptors. Return a list of ‘receptor’ structures and a corresponding list of ligand structures. The receptors are the rest of the complex once the ligand has been removed.

Parameters

complex_st (structure.Structure) – a ligand-receptor complex

Returns

a receptor list and corresponding ligand list

Return type

tuple(list(structure.Structure), list(structure.Structure))

schrodinger.application.livedesign.entry_types.get_ligands(sts, unique_smiles=False)

Get a list of ligand smiles represented in sts

Parameters
  • sts (list(structure.Structure)) – the structures to analyze

  • unique_smiles (bool) – whether to only count sts with unique SMILES

Returns

list of smiles

Return type

list(str)

schrodinger.application.livedesign.entry_types.format_numbered_message(base_msg, number, singular_str, plural_str=None)

Given a specially-formatted message containing a numbered word, return the proper human-readable translation using the correct form of that word.

Example input:

base_msg = ‘I have {number} {variable_str}.’ n = 2 singular_str = egg

Example output:

‘I have 2 eggs.’

Parameters
  • base_msg (str) – the message to be formatted. Should contain two new-style formatting replacement points, {number} and {variable_str}, for the number and numbered word that should be added to the message

  • number (int) – the number to be added to the message

  • singular_str (str) – the singular word for the object being described

  • plural_str (str or NoneType) – optionally, the plural word for the object being described; by default, inflect will be used to pluralize