Mercurial > repos > yating-l > hubarchivecreator
annotate util/subtools.py @ 85:a65e52152476 draft default tip
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
| author | yating-l | 
|---|---|
| date | Mon, 06 Nov 2017 13:13:01 -0500 | 
| parents | 4ca7cbf2d9b8 | 
| children | 
| rev | line source | 
|---|---|
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 1 #!/usr/bin/python | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 2 # -*- coding: utf8 -*- | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 3 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 4 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 5 This class handles the subprocess calls of the different tools used | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 6 in HubArchiveCreator | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 7 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 8 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 9 import logging | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 10 import os | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 11 import subprocess | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 12 import sys | 
| 51 
364b8db8de17
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
 yating-l parents: 
0diff
changeset | 13 import string | 
| 56 
04cc7c2e7b47
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
 yating-l parents: 
55diff
changeset | 14 import tempfile | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 15 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 16 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 17 class PopenError(Exception): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 18 def __init__(self, cmd, error, return_code): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 19 self.cmd = cmd | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 20 self.error = error | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 21 self.return_code = return_code | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 22 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 23 def __str__(self): | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 24 message = "The subprocess {0} has returned the error: {1}.".format( | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 25 self.cmd, self.return_code) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 26 message = ','.join( | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 27 (message, "Its error message is: {0}".format(self.error))) | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 28 return repr(message) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 29 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 30 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 31 def _handleExceptionAndCheckCall(array_call, **kwargs): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 32 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 33 This class handle exceptions and call the tool. | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 34 It maps the signature of subprocess.check_call: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 35 See https://docs.python.org/2/library/subprocess.html#subprocess.check_call | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 36 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 37 stdout = kwargs.get('stdout', subprocess.PIPE) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 38 stderr = kwargs.get('stderr', subprocess.PIPE) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 39 shell = kwargs.get('shell', False) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 40 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 41 cmd = array_call[0] | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 42 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 43 output = None | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 44 error = None | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 45 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 46 # TODO: Check the value of array_call and <=[0] | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 47 logging.debug("Calling {0}:".format(cmd)) | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 48 logging.debug("%s", array_call) | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 49 logging.debug("---------") | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 50 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 51 # TODO: Use universal_newlines option from Popen? | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 52 try: | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 53 p = subprocess.Popen(array_call, stdout=stdout, | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 54 stderr=stderr, shell=shell) | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 55 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 56 # TODO: Change this because of possible memory issues => https://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 57 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 58 output, error = p.communicate() | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 59 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 60 if stdout == subprocess.PIPE: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 61 logging.debug("\t{0}".format(output)) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 62 else: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 63 logging.debug("\tOutput in file {0}".format(stdout.name)) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 64 # If we detect an error from the subprocess, then we raise an exception | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 65 # TODO: Manage if we raise an exception for everything, or use CRITICAL etc... but not stop process | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 66 # TODO: The responsability of returning a sys.exit() should not be there, but up in the app. | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 67 if p.returncode: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 68 if stderr == subprocess.PIPE: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 69 raise PopenError(cmd, error, p.returncode) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 70 else: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 71 # TODO: To Handle properly with a design behind, if we received a option as a file for the error | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 72 raise Exception("Error when calling {0}. Error as been logged in your file {1}. Error code: {2}" | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 73 .format(cmd, stderr.name, p.returncode)) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 74 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 75 except OSError as e: | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 76 message = "The subprocess {0} has encountered an OSError: {1}".format( | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 77 cmd, e.strerror) | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 78 if e.filename: | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 79 message = '\n'.join( | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 80 (message, ", against this file: {0}".format(e.filename))) | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 81 logging.error(message) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 82 sys.exit(-1) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 83 except PopenError as p: | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 84 message = "The subprocess {0} has returned the error: {1}.".format( | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 85 p.cmd, p.return_code) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 86 message = '\n'.join( | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 87 (message, "Its error message is: {0}".format(p.error))) | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 88 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 89 logging.exception(message) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 90 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 91 sys.exit(p.return_code) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 92 except Exception as e: | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 93 message = "The subprocess {0} has encountered an unknown error: {1}".format( | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 94 cmd, e) | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 95 logging.exception(message) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 96 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 97 sys.exit(-1) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 98 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 99 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 100 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 101 def twoBitInfo(two_bit_file_name, two_bit_info_file): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 102 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 103 Call twoBitInfo and write the result into twoBit_info_file | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 104 :param two_bit_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 105 :param two_bit_info_file: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 106 :return the subprocess.check_call return object: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 107 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 108 array_call = ['twoBitInfo', two_bit_file_name, two_bit_info_file] | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 109 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 110 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 111 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 112 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 113 def faToTwoBit(fasta_file_name, twoBitFile): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 114 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 115 This function call faToTwoBit UCSC tool, and return the twoBitFile | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 116 :param fasta_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 117 :param mySpecieFolder: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 118 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 119 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 120 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 121 array_call = ['faToTwoBit', fasta_file_name, twoBitFile] | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 122 _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 123 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 124 return twoBitFile | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 125 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 126 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 127 def gtfToGenePred(input_gtf_file_name, gene_pred_file_name): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 128 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 129 Call gtfToGenePred and write the result into gene_pred_file_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 130 :param input_gtf_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 131 :param gene_pred_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 132 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 133 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 134 array_call = ['gtfToGenePred', input_gtf_file_name, gene_pred_file_name] | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 135 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 136 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 137 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 138 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 139 def gff3ToGenePred(input_gff3_file_name, gene_pred_file_name): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 140 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 141 Call gff3ToGenePred and write the result into gene_pred_file_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 142 :param input_gff3_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 143 :param gene_pred_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 144 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 145 """ | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 146 array_call = ['gff3ToGenePred', input_gff3_file_name, gene_pred_file_name] | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 147 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 148 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 149 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 150 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 151 def genePredToBigGenePred(gene_pred_file_name, unsorted_bigGenePred_file_name): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 152 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 153 Call genePredToBigGenePred and write the result into unsorted_bigGenePred_file_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 154 :param gene_pred_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 155 :param unsorted_bigGenePred_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 156 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 157 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 158 array_call = ['genePredToBigGenePred', | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 159 gene_pred_file_name, | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 160 unsorted_bigGenePred_file_name] | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 161 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 162 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 163 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 164 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 165 def genePredToBed(gene_pred_file_name, unsorted_bed_file_name): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 166 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 167 Call genePredToBed and write the result into unsorted_bed_file_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 168 :param gene_pred_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 169 :param unsorted_bed_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 170 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 171 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 172 array_call = ['genePredToBed', gene_pred_file_name, unsorted_bed_file_name] | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 173 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 174 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 175 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 176 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 177 def sort(unsorted_bed_file_name, sorted_bed_file_name): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 178 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 179 Call sort with -k1,1 -k2,2n on unsorted_bed_file_name and write the result into sorted_bed_file_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 180 :param unsorted_bed_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 181 :param sorted_bed_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 182 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 183 """ | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 184 array_call = ['sort', '-k', '1,1', '-k', '2,2n', | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 185 unsorted_bed_file_name, '-o', sorted_bed_file_name] | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 186 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 187 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 188 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 189 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 190 def sortChromSizes(two_bit_info_file_name, chrom_sizes_file_name): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 191 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 192 Call sort with -k2rn on two_bit_info_file_name and write the result into chrom_sizes_file_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 193 :param two_bit_info_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 194 :param chrom_sizes_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 195 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 196 """ | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 197 array_call = ['sort', '-k2rn', two_bit_info_file_name, | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 198 '-o', chrom_sizes_file_name] | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 199 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 200 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 201 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 202 | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 203 def bedToBigBed(sorted_bed_file_name, chrom_sizes_file_name, big_bed_file_name, options=None): | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 204 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 205 Call bedToBigBed on sorted_bed_file_name, using chrom_sizes_file_name and write the result into big_bed_file_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 206 :param sorted_bed_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 207 :param chrom_sizes_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 208 :param big_bed_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 209 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 210 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 211 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 212 array_call = ['bedToBigBed', sorted_bed_file_name, | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 213 chrom_sizes_file_name, big_bed_file_name] | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 214 if options: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 215 typeOption = options.get("typeOption") | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 216 autoSql = options.get("autoSql") | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 217 tab = options.get("tab") | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 218 extraIndex = options.get("extraIndex") | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 219 if typeOption: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 220 typeOption = ''.join(['-type=', typeOption]) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 221 array_call.append(typeOption) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 222 if autoSql: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 223 autoSql = ''.join(['-as=', autoSql]) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 224 array_call.append(autoSql) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 225 if tab: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 226 array_call.append('-tab') | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 227 if extraIndex: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 228 index = ''.join(['-extraIndex=', extraIndex]) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 229 array_call.append(index) | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 230 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 231 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 232 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 233 def sortBam(input_bam_file_name, output_sorted_bam_name): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 234 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 235 Call samtools on input_bam_file_name and output the result in output_sorted_bam_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 236 :param input_bam_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 237 :param output_sorted_bam_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 238 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 239 """ | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 240 array_call = ['samtools', 'sort', | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 241 input_bam_file_name, '-o', output_sorted_bam_name] | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 242 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 243 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 244 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 245 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 246 def createBamIndex(input_sorted_bam_file_name, output_name_index_name): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 247 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 248 Call `samtools index` on imput_sorted_bam_file_name and output the result in output_name_index_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 249 :param input_sorted_bam_file_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 250 :param output_name_index_name: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 251 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 252 """ | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 253 array_call = ['samtools', 'index', | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 254 input_sorted_bam_file_name, output_name_index_name] | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 255 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 256 return p | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 257 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 258 | 
| 0 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 259 def pslToBigPsl(input_psl_file_name, output_bed12_file_name): | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 260 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 261 Call `pslToBigPsl` on input_psl_file_name and output the result in output_bed12_file_name | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 262 :param input_psl_file_name: Name of the psl input file | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 263 :param output_bed12_file_name: Name of the output file where to store the result of the cmd | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 264 :return: | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 265 """ | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 266 # The command to send | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 267 array_call = ['pslToBigPsl', input_psl_file_name, output_bed12_file_name] | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 268 | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 269 p = _handleExceptionAndCheckCall(array_call) | 
| 
3e0c61b52a06
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
 yating-l parents: diff
changeset | 270 return p | 
| 51 
364b8db8de17
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
 yating-l parents: 
0diff
changeset | 271 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 272 # santitize trackName. Because track name must begin with a letter and | 
| 51 
364b8db8de17
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
 yating-l parents: 
0diff
changeset | 273 # contain only the following chars: [a-zA-Z0-9_]. | 
| 
364b8db8de17
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
 yating-l parents: 
0diff
changeset | 274 # See the "track" Common settings at: | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 275 # https://genome.ucsc.edu/goldenpath/help/trackDb/trackDbHub.html#bigPsl_-_Pairwise_Alignments | 
| 56 
04cc7c2e7b47
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
 yating-l parents: 
55diff
changeset | 276 | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 277 def validateFiles(input_file, chrom_sizes_file_name, file_type, options=None): | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 278 """ | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 279 Call validateFiles on input_file, using chrom_sizes_file_name and file_type | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 280 :param input_file: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 281 :param chrom_sizes_file_name: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 282 :param file_type: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 283 :return: | 
| 56 
04cc7c2e7b47
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
 yating-l parents: 
55diff
changeset | 284 """ | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 285 | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 286 array_call = ['validateFiles', '-chromInfo=' + chrom_sizes_file_name, '-type='+ file_type, input_file] | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 287 if options: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 288 tab = options.get("tab") | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 289 autoSql = options.get("autoSql") | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 290 logging.debug("tab: {0}".format(tab)) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 291 logging.debug("autoSql: {0}".format(autoSql)) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 292 if autoSql: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 293 autoSql = ''.join(['-as=', autoSql]) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 294 array_call.append(autoSql) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 295 if tab: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 296 array_call.append('-tab') | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 297 p = _handleExceptionAndCheckCall(array_call) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 298 return p | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 299 | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 300 def pslCheck(input_file, options=None): | 
| 56 
04cc7c2e7b47
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 93e2e2fb59f99677425104a80c17f665fa7b2b4a-dirty
 yating-l parents: 
55diff
changeset | 301 """ | 
| 66 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 302 Call pslCheck on input_file | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 303 :param input_file: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 304 :return: | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 305 """ | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 306 | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 307 array_call = ['pslCheck', input_file] | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 308 p = _handleExceptionAndCheckCall(array_call) | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 309 return p | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 310 | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 311 | 
| 
4ca7cbf2d9b8
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
 yating-l parents: 
57diff
changeset | 312 | 
