Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Returns
-------
str
path to _.tar.gz
References
----------
1. Ensembl, Assembly Information Endpoint,
https://rest.ensembl.org/documentation/info/assembly_info
2. Ensembl, Assembly Map Endpoint,
http://rest.ensembl.org/documentation/info/assembly_map
"""
if not create_dir(self._resources_dir):
return ""
chroms = [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
one_chrom_shared_genes,
two_chrom_shared_genes,
):
cytobands = self._resources.get_cytoBand_hg19()
individuals_filename = ""
individuals_plot_title = ""
for individual in individuals:
individuals_filename += individual.get_var_name() + "_"
individuals_plot_title += individual.name + " / "
individuals_filename = individuals_filename[:-1]
individuals_plot_title = individuals_plot_title[:-3]
if create_dir(self._output_dir):
plot_chromosomes(
one_chrom_shared_dna,
two_chrom_shared_dna,
cytobands,
os.path.join(
self._output_dir, "shared_dna_{}.png".format(individuals_filename)
),
"{} shared DNA".format(individuals_plot_title),
37,
)
if len(one_chrom_shared_dna) > 0:
file = "shared_dna_one_chrom_{}_GRCh37.csv".format(individuals_filename)
save_df_as_csv(
one_chrom_shared_dna,
self._output_dir,
compress : bool
compress with gzip
timeout : int
seconds for timeout of download request
Returns
-------
str
path to downloaded file, empty str if error
"""
if compress and filename[-3:] != ".gz":
filename += ".gz"
destination = os.path.join(self._resources_dir, filename)
if not create_dir(os.path.relpath(os.path.dirname(destination))):
return ""
if not os.path.exists(destination):
try:
# get file if it hasn't already been downloaded
# http://stackoverflow.com/a/7244263
with urllib.request.urlopen(
url, timeout=timeout
) as response, atomic_write(destination, mode="wb") as f:
self._print_download_msg(destination)
data = response.read() # a `bytes` object
if compress:
self._write_data_to_gzip(f, data)
else:
f.write(data)
import random
from atomicwrites import atomic_write
import numpy as np
from matplotlib import patches
import matplotlib.pyplot as plt
import pandas as pd
from snps import SNPs
from snps.resources import Resources
from snps.utils import Parallelizer, save_df_as_csv, create_dir
OUTPUT_DIR = "output"
# create output directory for this example
create_dir(OUTPUT_DIR)
# assume script is being run from examples dir
r = Resources(resources_dir="../../resources")
# setup logger to output to file in output directory
logging.basicConfig(
filename="{}".format(os.path.join(OUTPUT_DIR, "xy-chrom-snp-ratios.txt")),
format="%(asctime)s#%(message)s",
filemode="w",
level=logging.INFO,
)
logger = logging.getLogger()
def get_xy_chrom_snp_ratios(task):