def get_unitcell(structure):
    """Wrapper to get the unit cell from different structure classes"""
    from javelin.unitcell import UnitCell
    try:
        return structure.unitcell
    except AttributeError:
        try:
            return UnitCell(structure.lattice.abcABG())
        except AttributeError:
            try:
                from ase.geometry import cell_to_cellpar
                return UnitCell(cell_to_cellpar(structure.cell))
            except (ImportError, AttributeError):
                raise ValueError('Unable to get unit cell from structure')
