Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def generate_exports():
"""Print export commands for setting environment variables."""
env = []
for name in list_installed_genomes():
try:
g = Genome(name)
env_name = re.sub(r"[^\w]+", "_", name).upper()
env.append(f"export {env_name}={g.filename}")
except FastaIndexingError:
pass
return env
def __init__(self, name, genomes_dir=None):
self.genomes_dir = get_genomes_dir(genomes_dir, check_exist=False)
self.name = self._parse_name(name)
self.filename = self._parse_filename(name)
super(Genome, self).__init__(self.filename)
# file paths
self.genome_file = self.filename
self.genome_dir = os.path.dirname(self.filename)
self.index_file = self.filename + ".fai"
self.sizes_file = self.genome_file + ".sizes"
self.gaps_file = os.path.join(self.genome_dir, self.name + ".gaps.bed")
self.readme_file = os.path.join(self.genome_dir, "README.txt")
# genome attributes
self.sizes = {}
self.gaps = {}
metadata = self._read_metadata()
self.tax_id = metadata.get("tax_id")
self.assembly_accession = metadata.get("assembly_accession")
mask=mask,
regex=regex,
invert_match=invert_match,
localname=localname,
bgzip=bgzip,
**kwargs,
)
genome_found = True
# Export installed genome(s)
generate_env()
# Generates a Fasta object, index, gaps and sizes file
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)