Exemple #1
0
def _temperature_conditions(temperature):
    txt = ''
    if temperature.control.type != temperature.control.UNSPECIFIED:
        txt += 'The reaction was run '
        txt += {
            temperature.control.CUSTOM:
            'under custom temperature conditions',
            temperature.control.AMBIENT:
            'under ambient temperature conditions',
            temperature.control.OIL_BATH:
            'in an oil bath',
            temperature.control.WATER_BATH:
            'in a water bath',
            temperature.control.SAND_BATH:
            'in a sand bath',
            temperature.control.ICE_BATH:
            'in an ice bath',
            temperature.control.DRY_ALUMINUM_PLATE:
            'using an aluminum heating block',
            temperature.control.MICROWAVE:
            'in a microwave reactor',
            temperature.control.DRY_ICE_BATH:
            'in a dry ice bath',
            temperature.control.AIR_FAN:
            'using a fan for temperautre control',
            temperature.control.LIQUID_NITROGEN:
            'using liquid nitrogen for temperature control',
        }[temperature.control.type]
        txt += f' {_parenthetical_if_def(temperature.control.details)}'
        setpoint = units.format_message(temperature.setpoint)
        if setpoint:
            txt += f' with a setpoint of {setpoint}'
    return txt + '.'
Exemple #2
0
def _pressure_conditions(pressure):
    txt = ''
    if pressure.atmosphere.type != pressure.atmosphere.UNSPECIFIED:
        txt += {
            pressure.atmosphere.CUSTOM: 'under a custom atmosphere',
            pressure.atmosphere.AIR: 'under air',
            pressure.atmosphere.NITROGEN: 'under nitrogen',
            pressure.atmosphere.ARGON: 'under argon',
            pressure.atmosphere.OXYGEN: 'under oxygen',
            pressure.atmosphere.HYDROGEN: 'under hydrogen',
        }[pressure.atmosphere.type]
        txt += f' {_parenthetical_if_def(pressure.atmosphere.details)}'
    if pressure.control.type != pressure.control.UNSPECIFIED:
        txt += ' '
        txt += {
            pressure.control.CUSTOM: 'using a custom pressure controller',
            pressure.control.AMBIENT: 'using ambient pressure',
            pressure.control.SEALED: 'after fully sealing the reaction vessel',
            pressure.control.PRESSURIZED: 'using pressurization',
        }[pressure.control.type]
        txt += f' {_parenthetical_if_def(pressure.control.details)}'
        setpoint = units.format_message(pressure.setpoint)
        if setpoint:
            txt += f' with a setpoint of {setpoint}'
    if txt:
        txt = 'The reaction was run ' + txt + '.'
    return txt
Exemple #3
0
def _pressure_conditions_html(
        pressure: reaction_pb2.PressureConditions) -> str:
    """Generates an HTML-ready description of pressure conditions.

    Args:
        pressure: PressureConditions message.

    Returns:
        String description of the pressure conditions.
    """
    txt = ""
    if pressure.atmosphere.type != pressure.atmosphere.UNSPECIFIED:
        txt += {
            pressure.atmosphere.CUSTOM: pressure.atmosphere.details,
            pressure.atmosphere.AIR: "in air",
            pressure.atmosphere.NITROGEN: "under nitrogen",
            pressure.atmosphere.ARGON: "under argon",
            pressure.atmosphere.OXYGEN: "under oxygen",
            pressure.atmosphere.HYDROGEN: "under hydrogen",
        }[pressure.atmosphere.type]
    if pressure.atmosphere.type != pressure.atmosphere.UNSPECIFIED:
        setpoint = units.format_message(pressure.setpoint)
        if setpoint:
            txt += f" ({setpoint})"
    return txt
Exemple #4
0
def _pressure_conditions(pressure: reaction_pb2.PressureConditions) -> str:
    """Generates a text description of pressure conditions.

    Args:
        pressure: PressureConditions message.

    Returns:
        String description of the pressure conditions.
    """
    txt = ""
    if pressure.atmosphere.type != pressure.atmosphere.UNSPECIFIED:
        txt += {
            pressure.atmosphere.CUSTOM: "under a custom atmosphere",
            pressure.atmosphere.AIR: "under air",
            pressure.atmosphere.NITROGEN: "under nitrogen",
            pressure.atmosphere.ARGON: "under argon",
            pressure.atmosphere.OXYGEN: "under oxygen",
            pressure.atmosphere.HYDROGEN: "under hydrogen",
        }[pressure.atmosphere.type]
        txt += f" {_parenthetical_if_def(pressure.atmosphere.details)}"
    if pressure.control.type != pressure.control.UNSPECIFIED:
        txt += " "
        txt += {
            pressure.control.CUSTOM: "using a custom pressure controller",
            pressure.control.AMBIENT: "using ambient pressure",
            pressure.control.SEALED: "after fully sealing the reaction vessel",
            pressure.control.PRESSURIZED: "using pressurization",
        }[pressure.control.type]
        txt += f" {_parenthetical_if_def(pressure.control.details)}"
        setpoint = units.format_message(pressure.setpoint)
        if setpoint:
            txt += f" with a setpoint of {setpoint}"
    if txt:
        txt = "The reaction was run " + txt + "."
    return txt
Exemple #5
0
def _pressure_conditions(pressure):
    txt = ''
    if pressure.atmosphere != pressure.Atmosphere.UNSPECIFIED:
        txt += {
            pressure.Atmosphere.CUSTOM: 'under a custom atmosphere',
            pressure.Atmosphere.AIR: 'under air',
            pressure.Atmosphere.NITROGEN: 'under nitrogen',
            pressure.Atmosphere.ARGON: 'under argon',
            pressure.Atmosphere.OXYGEN: 'under oxygen',
            pressure.Atmosphere.HYDROGEN: 'under hydrogen',
        }[pressure.atmosphere]
        txt += f' {_parenthetical_if_def(pressure.atmosphere_details)}'
    if pressure.type != pressure.PressureControl.UNSPECIFIED:
        txt += ' '
        txt += {
            pressure.PressureControl.CUSTOM:
            'using a custom pressure controller',
            pressure.PressureControl.AMBIENT: 'using ambient pressure',
            pressure.PressureControl.BALLOON:
            'using a balloon for pressure control',
            pressure.PressureControl.SEALED:
            'after fully sealing the reaction vessel',
            pressure.PressureControl.SEPTUM_WITH_NEEDLE:
            'using a needle to pierce the vessel septum',
            pressure.PressureControl.RELEASEVALVE:
            'using a pressure release valve',
            pressure.PressureControl.BPR: 'using a backpressure regulator',
        }[pressure.type]
        txt += f' {_parenthetical_if_def(pressure.details)}'
        setpoint = units.format_message(pressure.setpoint)
        if setpoint:
            txt += f' with a setpoint of {setpoint}'
    if txt:
        txt = 'The reaction was run ' + txt + '.'
    return txt
Exemple #6
0
def _temperature_conditions_html(temperature):
    txt = ''
    if (temperature.control.type == temperature.control.UNSPECIFIED
            or temperature.control.type == temperature.control.AMBIENT):
        return 'ambient temperature<br>'
    setpoint = units.format_message(temperature.setpoint)
    if setpoint:
        txt += f'{setpoint}'
    if txt:
        txt += '<br>'
    return txt
Exemple #7
0
def _amount(amount: reaction_pb2.Amount) -> Optional[str]:
    """Returns a string representing an Amount."""
    kind = amount.WhichOneof("kind")
    if not kind:
        return ""
    if kind == "unmeasured":
        unmeasured_amount = getattr(amount, kind)
        options = {
            reaction_pb2.UnmeasuredAmount.UNSPECIFIED: "unspecified",
            reaction_pb2.UnmeasuredAmount.CUSTOM: unmeasured_amount.details,
            reaction_pb2.UnmeasuredAmount.SATURATED: "saturated",
            reaction_pb2.UnmeasuredAmount.CATALYTIC: "catalytic",
            reaction_pb2.UnmeasuredAmount.TITRATED: "titrated",
        }
        return options[unmeasured_amount.type]
    return units.format_message(getattr(amount, kind))
Exemple #8
0
def _pressure_conditions_html(pressure):
    txt = ''
    if pressure.atmosphere.type != pressure.atmosphere.UNSPECIFIED:
        txt += {
            pressure.atmosphere.CUSTOM: pressure.atmosphere.details,
            pressure.atmosphere.AIR: 'in air',
            pressure.atmosphere.NITROGEN: 'under nitrogen',
            pressure.atmosphere.ARGON: 'under argon',
            pressure.atmosphere.OXYGEN: 'under oxygen',
            pressure.atmosphere.HYDROGEN: 'under hydrogen',
        }[pressure.atmosphere.type]
    if pressure.atmosphere.type != pressure.atmosphere.UNSPECIFIED:
        setpoint = units.format_message(pressure.setpoint)
        if setpoint:
            txt += f' ({setpoint})'
    if txt:
        txt += '<br>'
    return txt
Exemple #9
0
def _temperature_conditions_html(temperature):
    """Generates an HTML-ready description of temperature conditions.

    Args:
        temperature: TemperatureConditions message.

    Returns:
        String description of the temperature conditions.
    """
    txt = ''
    if temperature.control.type == temperature.control.UNSPECIFIED:
        return ''
    if temperature.control.type == temperature.control.AMBIENT:
        return 'ambient temperature'
    setpoint = units.format_message(temperature.setpoint)
    if setpoint:
        txt += f'{setpoint}'
    return txt
Exemple #10
0
def _temperature_conditions_html(
    temperature: reaction_pb2.TemperatureConditions, ) -> str:
    """Generates an HTML-ready description of temperature conditions.

    Args:
        temperature: TemperatureConditions message.

    Returns:
        String description of the temperature conditions.
    """
    txt = ""
    if temperature.control.type == temperature.control.UNSPECIFIED:
        return ""
    if temperature.control.type == temperature.control.AMBIENT:
        return "ambient temperature"
    setpoint = units.format_message(temperature.setpoint)
    if setpoint:
        txt += f"{setpoint}"
    return txt
Exemple #11
0
def _temperature_conditions(
        temperature: reaction_pb2.TemperatureConditions) -> str:
    """Generates a text description of temperature conditions.

    Args:
        temperature: TemperatureConditions message.

    Returns:
        String description of the temperature conditions.
    """
    txt = ""
    if temperature.control.type != temperature.control.UNSPECIFIED:
        txt += "The reaction was run "
        txt += {
            temperature.control.CUSTOM:
            "under custom temperature conditions",
            temperature.control.AMBIENT:
            "under ambient temperature conditions",
            temperature.control.OIL_BATH:
            "in an oil bath",
            temperature.control.WATER_BATH:
            "in a water bath",
            temperature.control.SAND_BATH:
            "in a sand bath",
            temperature.control.ICE_BATH:
            "in an ice bath",
            temperature.control.DRY_ALUMINUM_PLATE:
            "using an aluminum heating block",
            temperature.control.MICROWAVE:
            "in a microwave reactor",
            temperature.control.DRY_ICE_BATH:
            "in a dry ice bath",
            temperature.control.AIR_FAN:
            "using a fan for temperautre control",
            temperature.control.LIQUID_NITROGEN:
            "using liquid nitrogen for temperature control",
        }[temperature.control.type]
        txt += f" {_parenthetical_if_def(temperature.control.details)}"
        setpoint = units.format_message(temperature.setpoint)
        if setpoint:
            txt += f" with a setpoint of {setpoint}"
    return txt + "."
Exemple #12
0
def _compound_amount(compound):
    amount = compound.WhichOneof('amount')
    if not amount:
        return ''
    return units.format_message(getattr(compound, amount))
Exemple #13
0
def _compound_amount(compound):
    """Returns a string describing the compound amount, if defined."""
    kind = compound.amount.WhichOneof('kind')
    if not kind:
        return ''
    return units.format_message(getattr(compound.amount, kind))