Skip to content

Commit

Permalink
Addition of download_pairwise_alignments_from_ucsc_seperate_files.py …
Browse files Browse the repository at this point in the history
…script in ucsc_pairwise_alignments_custom_scripts/0.1
  • Loading branch information
fgypas committed Jun 8, 2018
1 parent b258d12 commit a0884d1
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ucsc_pairwise_alignments_custom_scripts/0.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM python:3.6.5

##### METADATA #####
LABEL base.image="python:3.6.5"
LABEL version="2"
LABEL version="3"
LABEL software="ucsc_pairwise_alignments_custom_scripts"
LABEL software.version="0.1"
LABEL software.description="Custom scripts for ucsc alignments"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/usr/bin/env python

__version__ = "0.1"
__author__ = "Foivos Gypas"
__contact__ = "[email protected]"
__doc__ = "Download pairwise alignments from ucsc"

# _____________________________________________________________________________
# -----------------------------------------------------------------------------
# import needed (external) modules
# -----------------------------------------------------------------------------

import sys
import os
from argparse import ArgumentParser, RawTextHelpFormatter

# _____________________________________________________________________________
# -----------------------------------------------------------------------------
# Main function
# -----------------------------------------------------------------------------


def main():
""" Main function """

parser = ArgumentParser(
description=__doc__,
formatter_class=RawTextHelpFormatter
)

parser.add_argument(
"--organism",
dest="organism",
help="Reference organism (e.g. hg38, hg19, mm10)",
required=True,
metavar="FILE"
)

parser.add_argument(
"--organism_to_download",
dest="organism_to_download",
help="Name of pairwise alignment organism",
required=True
)

parser.add_argument(
"--out",
dest="out",
help="Output directory",
required=True,
metavar="FILE"
)

parser.add_argument(
"--verbose",
action="store_true",
dest="verbose",
default=False,
required=False,
help="Verbose"
)

parser.add_argument(
'--version',
action='version',
version=__version__
)

# _________________________________________________________________________
# -------------------------------------------------------------------------
# get the arguments
# -------------------------------------------------------------------------
try:
options = parser.parse_args()
except(Exception):
parser.print_help()

if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)

start = "rsync://hgdownload.soe.ucsc.edu/goldenPath/" + options.organism + "/vs"
f_s_l = options.organism_to_download
f_s = f_s_l[0].upper() + f_s_l[1:]
output_dir = os.path.join(options.out, options.organism + "_to_" + f_s_l)
# file_name = options.organism + "." + f_s_l + ".net.axt.gz"
if not os.path.exists(output_dir):
os.makedirs(output_dir)

download_link = start + f_s + "/axtNet/"

try:
if options.verbose:
sys.stdout.write("Downloading " + download_link + os.linesep)
os.system("rsync -a -P " + download_link + " " + output_dir)
except:
sys.stderr.write("Could not download " + download_link + os.linesep)

# _____________________________________________________________________________
# -----------------------------------------------------------------------------
# Call the Main function and catch Keyboard interrups
# -----------------------------------------------------------------------------


if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
sys.stderr.write("User interrupt!" + os.linesep)
sys.exit(0)

0 comments on commit a0884d1

Please sign in to comment.