How to use the genomepy.utils.glob_ext_files function in genomepy

To help you get started, we’ve selected a few genomepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vanheeringen-lab / genomepy / genomepy / functions.py View on Github external
g = None
    if genome_found:
        g = Genome(localname, genomes_dir=genomes_dir)

    # Check if any annotation flags are given, if annotation already exists, or if downloading is forced
    if any(
        [
            annotation,
            only_annotation,
            skip_sanitizing,
            kwargs.get("to_annotation"),
            kwargs.get("ucsc_annotation_type"),
        ]
    ):
        annotation = True
    annotation_found = len(glob_ext_files(out_dir, "gtf")) >= 1
    if (not annotation_found or force) and annotation:
        # Download annotation from provider
        p = ProviderBase.create(provider)
        p.download_annotation(name, genomes_dir, localname=localname, **kwargs)

        # Sanitize annotation if needed (requires genome)
        annotation_found = len(glob_ext_files(out_dir, "gtf")) >= 1
        if genome_found and annotation_found and not skip_sanitizing:
            sanitize_annotation(g)

    if genome_found:
        # Run all active plugins (requires genome)
        for plugin in get_active_plugins():
            plugin.after_genome_download(g, threads, force)
github vanheeringen-lab / genomepy / genomepy / genome.py View on Github external
def _parse_filename(self, name):
        """
        accepts path to a fasta file, path to a fasta folder, or
        the name of a genome (e.g. hg38).

        returns the abspath to the fasta file
        """
        path_name = os.path.abspath(os.path.expanduser(name))
        if os.path.isfile(path_name):
            return path_name

        default_genome_dir = os.path.join(self.genomes_dir, self.name)
        for f in glob_ext_files(path_name) + glob_ext_files(default_genome_dir):
            if self.name + ".fa" in os.path.basename(f):
                return f

        raise FileNotFoundError(
            f"could not find {self.name}.fa(.gz) in genome_dir {default_genome_dir}"
        )
github vanheeringen-lab / genomepy / genomepy / functions.py View on Github external
Ensembl only: Always download the toplevel genome. Ignores potential primary assembly.

        version : int , optional
            Ensembl only: Specify release version. Default is latest.

        to_annotation : text , optional
            URL only: direct link to annotation file.
            Required if this is not the same directory as the fasta.
    """
    genomes_dir = get_genomes_dir(genomes_dir, check_exist=False)
    localname = get_localname(name, localname)
    out_dir = os.path.join(genomes_dir, localname)

    # Check if genome already exists, or if downloading is forced
    genome_found = (
        len([f for f in glob_ext_files(out_dir) if f"{localname}.fa" in f]) >= 1
    )
    if (not genome_found or force) and not only_annotation:
        # Download genome from provider
        p = ProviderBase.create(provider)
        p.download_genome(
            name,
            genomes_dir,
            mask=mask,
            regex=regex,
            invert_match=invert_match,
            localname=localname,
            bgzip=bgzip,
            **kwargs,
        )
        genome_found = True