def get_machine_run_flowcell_id(runid_and_flowcellid):
    """return machine-id, run-id and flowcell-id from full string.
    Expected string format is machine-runid_flowcellid

    >>> get_machine_run_flowcell_id("HS002-SR-R00224_BC9A6MACXX")
    ('HS002', 'HS002-SR-R00224', 'BC9A6MACXX')
    >>> get_machine_run_flowcell_id("/path/to/seq/HS002-SR-R00224_BC9A6MACXX")
    ('HS002', 'HS002-SR-R00224', 'BC9A6MACXX')
    >>> get_machine_run_flowcell_id("HS002_SR_R00224_BC9A6MACXX")
    Traceback (most recent call last):
      ...
    AssertionError: Wrong format: HS002_SR_R00224_BC9A6MACXX
    """

    # strip away path
    runid_and_flowcellid = runid_and_flowcellid.rstrip("/").split('/')[-1]
    assert runid_and_flowcellid.count("_") == 1, (
        "Wrong format: {}".format(runid_and_flowcellid))
    runid, flowcellid = runid_and_flowcellid.split("_")
    machineid = runid.split("-")[0]
    return machineid, runid, flowcellid