This function appends an Assay object to a study in an ISA file
    Typically, you should use the exploreISA function to check the contents
    of the ISA file and retrieve the assay and study number you are interested in!
    :param assay: The Assay
    :type assay: ISA Assay object
    :param studyNum: The Study number (notice it's not zero-based index).
    :type studyNum: int
    :param pathToISATABFile: The path to the ISATAB file
    :type pathToISATABFile: string
    :raise FileNotFoundError: If pathToISATABFile does not contain file 'i_Investigation.txt'.

def appendAssayToStudy(assay, studyNum, pathToISATABFile):
    """
    This function appends an Assay object to a study in an ISA file
    Typically, you should use the exploreISA function to check the contents
    of the ISA file and retrieve the assay and study number you are interested in!
    :param assay: The Assay
    :type assay: ISA Assay object
    :param studyNum: The Study number (notice it's not zero-based index).
    :type studyNum: int
    :param pathToISATABFile: The path to the ISATAB file
    :type pathToISATABFile: string
    :raise FileNotFoundError: If pathToISATABFile does not contain file 'i_Investigation.txt'.
    """
    from isatools import isatab
    try:
        isa = isatab.load(pathToISATABFile, skip_load_tables=True)
        std = isa.studies[studyNum - 1]
        lngth = len(std.assays)
        base  = os.path.basename(assay.filename)
        fname = os.path.splitext(base)[0]
        fname = fname + str(lngth)
        ext   = os.path.splitext(base)[1]
        fname = fname + ext
        assay.filename = fname
        isa.studies[studyNum - 1].assays.append(assay)
        isatab.dump(isa_obj=isa, output_path=pathToISATABFile)
    except FileNotFoundError as err:
        raise err