Module wormutils.chemlabel
Functions
def chemlabel(name, charge_sign_at_end=False)-
Expand source code
def chemlabel(name, charge_sign_at_end=False): """ Format a chemical formula to display subscripts and superscripts in HTML (e.g., Plotly plots) Example, "CH3COO-" becomes "CH<sub>3</sub>COO<sup>-</sup>" Parameters ---------- name : str A chemical formula. charge_sign_at_end : bool, default False Display charge with sign after the number (e.g. SO4 2-)? Returns ------- A formatted chemical formula string. """ # format only the first part of the name if it has "_(input)" if len(name.split("_(input)"))==2: if name.split("_(input)")[1] == '': name = name.split("_(input)")[0] input_flag=True else: input_flag = False name = _html_chemname_format(name, charge_sign_at_end=charge_sign_at_end) # add " (input)" to the end of the name if input_flag: name = name+" (input)" return(name)Format a chemical formula to display subscripts and superscripts in HTML (e.g., Plotly plots) Example, "CH3COO-" becomes "CH3COO-"
Parameters
name:str- A chemical formula.
charge_sign_at_end:bool, defaultFalse- Display charge with sign after the number (e.g. SO4 2-)?
Returns
A formatted chemical formula string.