Extract the sources in a temporary folder.
    :arg filename, name of the zip file containing the data from MapQTL
    which will be extracted
    :arg extract_dir, folder in which to extract the archive.

def extract_zip(filename, extract_dir):
    """ Extract the sources in a temporary folder.
    :arg filename, name of the zip file containing the data from MapQTL
    which will be extracted
    :arg extract_dir, folder in which to extract the archive.
    """
    LOG.info("Extracting %s in %s " % (filename, extract_dir))
    if not os.path.exists(extract_dir):
        try:
            os.mkdir(extract_dir)
        except IOError as err:  # pragma: no cover
            LOG.info("Could not generate the folder %s" % extract_dir)
            LOG.debug("Error: %s" % err)
            return

    if zipfile.is_zipfile(filename):
        try:
            zfile = zipfile.ZipFile(filename, "r")
            for name in zfile.namelist():
                if os.path.dirname(name):
                    curdir = os.path.join(extract_dir, os.path.dirname(name))
                    if not os.path.exists(curdir):
                        os.mkdir(curdir)
                        continue
                outfile = open(os.path.join(extract_dir, name), 'wb')
                outfile.write(zfile.read(name))
                outfile.flush()
                outfile.close()
            zfile.close()
        except IOError as err:  # pragma: no cover
            LOG.info("Error while extracting the zip archive.")
            LOG.debug("Error: %s" % err)
    else:
        try:  # pragma: no cover  We only have zipfile to test with
            tar = tarfile.open(filename)
            tar.extractall(extract_dir)
            tar.close()
        except tarfile.ReadError as err:  # pragma: no cover
            LOG.info("Error while extracting the tarball.")
            LOG.debug("Error: %s" % err)

    return extract_dir