Beispiel #1
0
    def fetch_version(self, version: str, target_filename: Path) -> None:
        """
        Takes care of the tool download.

        Overrides the ExternalAlgorithm methood. Downloads the VEP cache
        to the prebuild location specified by the corresponding
        ExternalAlgorithmStore and packs it into a tar.gz file.

        Parameters
        ----------
        version : str
            The tool version to be used.
        target_filename : Path
            The path to the local tar.gz file.
        """
        url = f"ftp://ftp.ensembl.org/pub/release-{self.revision}/variation/indexed_vep_cache/{self.species}_vep_{self.revision}_{self.grch}.tar.gz"
        download_file(url, target_filename.open("wb"))
Beispiel #2
0
def download_gunzip_and_attach(url, unzipped_filename, files_to_attach):
    import shutil
    import gzip
    import tempfile

    tf = tempfile.NamedTemporaryFile(suffix=".gz")
    download_file(url, tf)
    tf.flush()

    attach = b""
    for f in files_to_attach:
        attach += Path(f).read_bytes()

    with gzip.GzipFile(tf.name, "rb") as gz_in:
        with open(unzipped_filename, "wb") as op:
            shutil.copyfileobj(gz_in, op)
            op.write(attach)
Beispiel #3
0
 def df(url, filename):
     with open(filename, "wb") as op:
         download_file(url, op)
Beispiel #4
0
 def download(url=url, target_fn=target_fn):
     Path(target_fn).parent.mkdir(exist_ok=True, parents=True)
     target_fn.with_name(target_fn.name + ".url").write_text(url)
     with open(str(target_fn) + "_temp", "wb") as op:
         download_file(url, op)
     shutil.move(str(target_fn) + "_temp", target_fn)
Beispiel #5
0
 def __dump():
     download_file(self.url, outfile.open("wb"))
Beispiel #6
0
 def __dump():
     download_file(self.url, self.input_file.open("wb"))
Beispiel #7
0
 def get_set_from_url(self):
     url = f"https://data.broadinstitute.org/gsea-msigdb/msigdb/release/{self.version}/{self.name}.symbols.gmt"
     download_file(url, self._gmt.open("wb"))
    def test_download_file_with_filename_raises(self):
        from mbf_externals.util import download_file

        with pytest.raises(ValueError):
            download_file("http://ftp.ensembl.org", "out.file")