Skip to content

Commit

Permalink
For release 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lemieuxl committed Apr 12, 2017
2 parents 9960fe1 + d487c12 commit e14d694
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 120 deletions.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Usage
[--report-background BACKGROUND]
Execute the genome-wide imputation pipeline. This script is part of the
'genipe' package, version 1.3.2.
'genipe' package, version 1.3.3.
optional arguments:
-h, --help show this help message and exit
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/tutorial_SKAT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ the console:
{continuous,discrete} [--skat-o] --pheno-name NAME
Uses the SKAT R package to analyze user defined gene sets. This script is part
of the 'genipe' package, version 1.3.2.
of the 'genipe' package, version 1.3.3.
optional arguments:
-h, --help show this help message and exit
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/tutorial_cox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ in the console:
NAME
Performs a survival regression on imputed data using Cox's proportional hazard
model. This script is part of the 'genipe' package, version 1.3.2.
model. This script is part of the 'genipe' package, version 1.3.3.
optional arguments:
-h, --help show this help message and exit
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/tutorial_extract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ analysis in the console:
[--rate FLOAT] [--info FLOAT]
Extract imputed markers located in a specific genomic region. This script is
part of the 'genipe' package, version 1.3.2.
part of the 'genipe' package, version 1.3.3.
optional arguments:
-h, --help show this help message and exit
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/tutorial_linear.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ analysis in the console:
--pheno-name NAME
Performs a linear regression (ordinary least squares) on imputed data. This
script is part of the 'genipe' package, version 1.3.2.
script is part of the 'genipe' package, version 1.3.3.
optional arguments:
-h, --help show this help message and exit
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/tutorial_logistic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ regression analysis in the console:
--pheno-name NAME
Performs a logistic regression on imputed data using a GLM with a binomial
distribution. This script is part of the 'genipe' package, version 1.3.2.
distribution. This script is part of the 'genipe' package, version 1.3.3.
optional arguments:
-h, --help show this help message and exit
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/tutorial_mixedlm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ effects analysis in the console:
Performs a linear mixed effects regression on imputed data using a random
intercept for each group. A p-value approximation is performed so that
computation time is acceptable for imputed data. This script is part of the
'genipe' package, version 1.3.2.
'genipe' package, version 1.3.3.
optional arguments:
-h, --help show this help message and exit
Expand Down
259 changes: 147 additions & 112 deletions genipe/tools/genipe_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from glob import glob
from urllib.request import urlretrieve
from tempfile import TemporaryDirectory
from distutils.spawn import find_executable
from urllib.error import HTTPError, URLError
from subprocess import check_call, CalledProcessError

Expand Down Expand Up @@ -105,42 +106,42 @@ def main(args=None):
os.path.join(args.path, "bin", "plink"),
)
if not has_plink:
logger.info("Downloading Plink")
logger.info("Getting Plink")
get_plink(
os_name=os_name,
arch=architecture,
path=os.path.join(args.path, "bin"),
)
else:
logger.info("Plink already downloaded")
logger.info("Plink already present")

# Downloading impute2
has_impute2 = check_files(
os.path.join(args.path, "bin", "impute2"),
)
if not has_impute2:
logger.info("Downloading impute2")
logger.info("Getting impute2")
get_impute2(
os_name=os_name,
arch=architecture,
path=os.path.join(args.path, "bin"),
)
else:
logger.info("Impute2 already downloaded")
logger.info("Impute2 already present")

# Downloading shapeit
has_shapeit = check_files(
os.path.join(args.path, "bin", "shapeit"),
)
if not has_shapeit:
logger.info("Downloading shapeit")
logger.info("Getting shapeit")
get_shapeit(
os_name=os_name,
arch=architecture,
path=os.path.join(args.path, "bin"),
)
else:
logger.info("Shapeit already downloaded")
logger.info("Shapeit already present")

# Downloading the reference
has_hg19 = check_files(
Expand Down Expand Up @@ -382,43 +383,54 @@ def get_plink(os_name, arch, path):
arch (str): the architecture of the system
path (str): the path where to put Plink
"""
# The url for each platform
url = "http://pngu.mgh.harvard.edu/~purcell/plink/dist/{filename}"

# Getting the name of the file to download
filename = ""
if os_name == "Darwin":
filename = "plink-1.07-mac-intel.zip"
elif os_name == "Linux":
filename = "plink-1.07-x86_64.zip"
if filename == "":
raise GenipeError("Problem choosing a file to download for "
"{} {} bits".format(os_name, arch))

# Downloading Plink in a temporary directory
logger.info(" - " + filename)
with TemporaryDirectory() as tmpdir:
zip_path = os.path.join(tmpdir, filename)
download_file(url.format(filename=filename), zip_path)

# Unzipping Plink
logger.info(" - Extracting file")
with zipfile.ZipFile(zip_path, "r") as z:
z.extractall(tmpdir)

# Finding the plink file
plink_file = glob(os.path.join(tmpdir, "*", "plink"))
if len(plink_file) != 1 or not os.path.isfile(plink_file[0]):
raise GenipeError("Unable to locate Plink")
plink_file = plink_file[0]

# Moving the file
shutil.move(plink_file, path)
plink_path = os.path.join(path, "plink")
Note
====
If the binary is in the system path, it is copied to the destination
path. Otherwise, we download it.
# Making the script executable
os.chmod(plink_path, stat.S_IRWXU)
"""
system_plink = find_executable("plink")
if system_plink is not None:
logger.info(" - Copying Plink from {}".format(system_plink))
shutil.copy(system_plink, path, follow_symlinks=True)

else:
# The url for each platform
url = "http://zzz.bwh.harvard.edu/plink/dist/{filename}"

# Getting the name of the file to download
filename = ""
if os_name == "Darwin":
filename = "plink-1.07-mac-intel.zip"
elif os_name == "Linux":
filename = "plink-1.07-x86_64.zip"
if filename == "":
raise GenipeError("Problem choosing a file to download for "
"{} {} bits".format(os_name, arch))

# Downloading Plink in a temporary directory
logger.info(" - " + filename)
with TemporaryDirectory() as tmpdir:
zip_path = os.path.join(tmpdir, filename)
download_file(url.format(filename=filename), zip_path)

# Unzipping Plink
logger.info(" - Extracting file")
with zipfile.ZipFile(zip_path, "r") as z:
z.extractall(tmpdir)

# Finding the plink file
plink_file = glob(os.path.join(tmpdir, "*", "plink"))
if len(plink_file) != 1 or not os.path.isfile(plink_file[0]):
raise GenipeError("Unable to locate Plink")
plink_file = plink_file[0]

# Moving the file
shutil.move(plink_file, path)
plink_path = os.path.join(path, "plink")

# Making the script executable
os.chmod(plink_path, stat.S_IRWXU)


def get_impute2(os_name, arch, path):
Expand All @@ -429,42 +441,53 @@ def get_impute2(os_name, arch, path):
arch (str): the architecture of the system
path (str): the path where to put impute2
"""
# The url for each platform
url = "https://mathgen.stats.ox.ac.uk/impute/{filename}"

# Getting the name of the file to download
filename = ""
if os_name == "Darwin":
filename = "impute_v2.3.2_MacOSX_Intel.tgz"
elif os_name == "Linux":
filename = "impute_v2.3.2_x86_64_static.tgz"
if filename == "":
raise GenipeError("Problem choosing a file to download for "
"{} {} bits".format(os_name, arch))

# Downloading Impute2 in a temporary directory
logger.info(" - " + filename)
with TemporaryDirectory() as tmpdir:
tar_path = os.path.join(tmpdir, filename)
download_file(url.format(filename=filename), tar_path)

# Extracting impute2
logger.info(" - Extracting file")
untar_file(tmpdir, tar_path)

# Finding the impute2 file
impute2_file = glob(os.path.join(tmpdir, "*", "impute2"))
if len(impute2_file) != 1 or not os.path.isfile(impute2_file[0]):
raise GenipeError("Unable to locate impute2")
impute2_file = impute2_file[0]

# Moving the file
shutil.move(impute2_file, path)
impute2_path = os.path.join(path, "impute2")
Note
====
If the binary is in the system path, it is copied to the destination
path. Otherwise, we download it.
# Making the script executable
os.chmod(impute2_path, stat.S_IRWXU)
"""
system_impute2 = find_executable("impute2")
if system_impute2 is not None:
logger.info(" - Copying impute2 from {}".format(system_impute2))
shutil.copy(system_impute2, path, follow_symlinks=True)

else:
# The url for each platform
url = "https://mathgen.stats.ox.ac.uk/impute/{filename}"

# Getting the name of the file to download
filename = ""
if os_name == "Darwin":
filename = "impute_v2.3.2_MacOSX_Intel.tgz"
elif os_name == "Linux":
filename = "impute_v2.3.2_x86_64_static.tgz"
if filename == "":
raise GenipeError("Problem choosing a file to download for "
"{} {} bits".format(os_name, arch))

# Downloading Impute2 in a temporary directory
logger.info(" - " + filename)
with TemporaryDirectory() as tmpdir:
tar_path = os.path.join(tmpdir, filename)
download_file(url.format(filename=filename), tar_path)

# Extracting impute2
logger.info(" - Extracting file")
untar_file(tmpdir, tar_path)

# Finding the impute2 file
impute2_file = glob(os.path.join(tmpdir, "*", "impute2"))
if len(impute2_file) != 1 or not os.path.isfile(impute2_file[0]):
raise GenipeError("Unable to locate impute2")
impute2_file = impute2_file[0]

# Moving the file
shutil.move(impute2_file, path)
impute2_path = os.path.join(path, "impute2")

# Making the script executable
os.chmod(impute2_path, stat.S_IRWXU)


def get_shapeit(os_name, arch, path):
Expand All @@ -475,42 +498,54 @@ def get_shapeit(os_name, arch, path):
arch (str): the architecture of the system
path (str): the path where to put shapeit
"""
# The url for each platform
url = "https://mathgen.stats.ox.ac.uk/genetics_software/shapeit/{filename}"

# Getting the name of the file to download
filename = ""
if os_name == "Darwin":
filename = "shapeit.v2.r837.MacOSX.tgz"
elif os_name == "Linux":
filename = "shapeit.v2.r837.GLIBCv2.12.Linux.static.tgz"
if filename == "":
raise GenipeError("Problem choosing a file to download for "
"{} {} bits".format(os_name, arch))

# Downloading shapeit in a temporary directory
logger.info(" - " + filename)
with TemporaryDirectory() as tmpdir:
tar_path = os.path.join(tmpdir, filename)
download_file(url.format(filename=filename), tar_path)

# Extracting shapeit
logger.info(" - Extracting file")
untar_file(tmpdir, tar_path)

# Finding the shapeit file
shapeit_file = glob(os.path.join(tmpdir, "*", "shapeit"))
if len(shapeit_file) != 1 or not os.path.isfile(shapeit_file[0]):
raise GenipeError("Unable to locate shapeit")
shapeit_file = shapeit_file[0]

# Moving the file
shutil.move(shapeit_file, path)
shapeit_path = os.path.join(path, "shapeit")
Note
====
If the binary is in the system path, it is copied to the destination
path. Otherwise, we download it.
# Making the script executable
os.chmod(shapeit_path, stat.S_IRWXU)
"""
system_shapeit = find_executable("shapeit")
if system_shapeit is not None:
logger.info(" - Copying shapeit from {}".format(system_shapeit))
shutil.copy(system_shapeit, path, follow_symlinks=True)

else:
# The url for each platform
url = ("https://mathgen.stats.ox.ac.uk/genetics_software/"
"shapeit/{filename}")

# Getting the name of the file to download
filename = ""
if os_name == "Darwin":
filename = "shapeit.v2.r837.MacOSX.tgz"
elif os_name == "Linux":
filename = "shapeit.v2.r837.GLIBCv2.12.Linux.static.tgz"
if filename == "":
raise GenipeError("Problem choosing a file to download for "
"{} {} bits".format(os_name, arch))

# Downloading shapeit in a temporary directory
logger.info(" - " + filename)
with TemporaryDirectory() as tmpdir:
tar_path = os.path.join(tmpdir, filename)
download_file(url.format(filename=filename), tar_path)

# Extracting shapeit
logger.info(" - Extracting file")
untar_file(tmpdir, tar_path)

# Finding the shapeit file
shapeit_file = glob(os.path.join(tmpdir, "*", "shapeit"))
if len(shapeit_file) != 1 or not os.path.isfile(shapeit_file[0]):
raise GenipeError("Unable to locate shapeit")
shapeit_file = shapeit_file[0]

# Moving the file
shutil.move(shapeit_file, path)
shapeit_path = os.path.join(path, "shapeit")

# Making the script executable
os.chmod(shapeit_path, stat.S_IRWXU)


def download_file(url, path):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

MAJOR = 1
MINOR = 3
MICRO = 2
MICRO = 3
VERSION = "{0}.{1}.{2}".format(MAJOR, MINOR, MICRO)


Expand Down

0 comments on commit e14d694

Please sign in to comment.