Return species properties defined in the XHTML notes.

    Older SBML models often define additional properties in the XHTML notes
    section because structured methods for defining properties had not been
    developed. This will try to parse the following properties: ``PUBCHEM ID``,
    ``CHEBI ID``, ``FORMULA``, ``KEGG ID``, ``CHARGE``.

    Args:
        entry: :class:`SBMLSpeciesEntry`.

def parse_xhtml_species_notes(entry):
    """Return species properties defined in the XHTML notes.

    Older SBML models often define additional properties in the XHTML notes
    section because structured methods for defining properties had not been
    developed. This will try to parse the following properties: ``PUBCHEM ID``,
    ``CHEBI ID``, ``FORMULA``, ``KEGG ID``, ``CHARGE``.

    Args:
        entry: :class:`SBMLSpeciesEntry`.
    """
    properties = {}
    if entry.xml_notes is not None:
        cobra_notes = dict(parse_xhtml_notes(entry))

        for key in ('pubchem_id', 'chebi_id'):
            if key in cobra_notes:
                properties[key] = cobra_notes[key]

        if 'formula' in cobra_notes:
            properties['formula'] = cobra_notes['formula']

        if 'kegg_id' in cobra_notes:
            properties['kegg'] = cobra_notes['kegg_id']

        if 'charge' in cobra_notes:
            try:
                value = int(cobra_notes['charge'])
            except ValueError:
                logger.warning(
                    'Unable to parse charge for {} as an'
                    ' integer: {}'.format(
                        entry.id, cobra_notes['charge']))
                value = cobra_notes['charge']
            properties['charge'] = value

    return properties