Mercurial > repos > yating-l > jbrowsearchivecreator
annotate util/subtools.py @ 38:d17f629f5486 draft
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
| author | yating-l | 
|---|---|
| date | Fri, 06 Apr 2018 13:44:56 -0400 | 
| parents | 68466f5064ce | 
| children | 4a69515eed63 | 
| rev | line source | 
|---|---|
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 1 #!/usr/bin/env python | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 2 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 3 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 4 This file include common used functions for converting file format to gff3 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 5 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 6 from collections import OrderedDict | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 7 import json | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 8 import subprocess | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 9 import os | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 10 import sys | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 11 import tempfile | 
| 38 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 12 import shutil | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 13 import logging | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 14 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 15 class PopenError(Exception): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 16 def __init__(self, cmd, error, return_code): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 17 self.cmd = cmd | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 18 self.error = error | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 19 self.return_code = return_code | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 20 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 21 def __str__(self): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 22 message = "The subprocess {0} has returned the error: {1}.".format( | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 23 self.cmd, self.return_code) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 24 message = ','.join( | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 25 (message, "Its error message is: {0}".format(self.error))) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 26 return repr(message) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 27 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 28 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 29 def _handleExceptionAndCheckCall(array_call, **kwargs): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 30 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 31 This class handle exceptions and call the tool. | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 32 It maps the signature of subprocess.check_call: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 33 See https://docs.python.org/2/library/subprocess.html#subprocess.check_call | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 34 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 35 stdout = kwargs.get('stdout', subprocess.PIPE) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 36 stderr = kwargs.get('stderr', subprocess.PIPE) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 37 shell = kwargs.get('shell', False) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 38 stdin = kwargs.get('stdin', None) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 39 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 40 cmd = array_call[0] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 41 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 42 output = None | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 43 error = None | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 44 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 45 # TODO: Check the value of array_call and <=[0] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 46 logging.debug("Calling {0}:".format(cmd)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 47 logging.debug("%s", array_call) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 48 logging.debug("---------") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 49 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 50 # TODO: Use universal_newlines option from Popen? | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 51 try: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 52 p = subprocess.Popen(array_call, stdout=stdout, | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 53 stderr=stderr, shell=shell, stdin=stdin) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 54 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 55 # TODO: Change this because of possible memory issues => https://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 56 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 57 output, error = p.communicate() | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 58 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 59 if stdout == subprocess.PIPE: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 60 logging.debug("\t{0}".format(output)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 61 else: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 62 logging.debug("\tOutput in file {0}".format(stdout.name)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 63 # If we detect an error from the subprocess, then we raise an exception | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 64 # TODO: Manage if we raise an exception for everything, or use CRITICAL etc... but not stop process | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 65 # TODO: The responsability of returning a sys.exit() should not be there, but up in the app. | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 66 if p.returncode: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 67 if stderr == subprocess.PIPE: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 68 raise PopenError(cmd, error, p.returncode) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 69 else: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 70 # TODO: To Handle properly with a design behind, if we received a option as a file for the error | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 71 raise Exception("Error when calling {0}. Error as been logged in your file {1}. Error code: {2}" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 72 .format(cmd, stderr.name, p.returncode)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 73 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 74 except OSError as e: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 75 message = "The subprocess {0} has encountered an OSError: {1}".format( | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 76 cmd, e.strerror) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 77 if e.filename: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 78 message = '\n'.join( | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 79 (message, ", against this file: {0}".format(e.filename))) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 80 logging.error(message) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 81 sys.exit(-1) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 82 except PopenError as p: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 83 message = "The subprocess {0} has returned the error: {1}.".format( | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 84 p.cmd, p.return_code) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 85 message = '\n'.join( | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 86 (message, "Its error message is: {0}".format(p.error))) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 87 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 88 logging.exception(message) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 89 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 90 sys.exit(p.return_code) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 91 except Exception as e: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 92 message = "The subprocess {0} has encountered an unknown error: {1}".format( | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 93 cmd, e) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 94 logging.exception(message) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 95 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 96 sys.exit(-1) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 97 return p | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 98 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 99 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 100 def write_features(field, attribute, gff3): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 101 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 102 The function write the features to gff3 format (defined in https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 103 field, attribute are ordered dictionary | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 104 gff3 is the file handler | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 105 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 106 attr = [] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 107 for v in field.values(): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 108 gff3.write(str(v) + '\t') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 109 for k, v in attribute.items(): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 110 s = str(k) + '=' + str(v) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 111 attr.append(s) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 112 gff3.write(';'.join(attr)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 113 gff3.write('\n') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 114 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 115 def twoBitInfo(two_bit_file_name, two_bit_info_file): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 116 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 117 Call twoBitInfo and write the result into twoBit_info_file | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 118 :param two_bit_file_name: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 119 :param two_bit_info_file: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 120 :return the subprocess.check_call return object: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 121 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 122 array_call = ['twoBitInfo', two_bit_file_name, two_bit_info_file] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 123 p = _handleExceptionAndCheckCall(array_call) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 124 return p | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 125 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 126 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 127 def faToTwoBit(fasta_file_name, twoBitFile): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 128 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 129 This function call faToTwoBit UCSC tool, and return the twoBitFile | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 130 :param fasta_file_name: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 131 :param mySpecieFolder: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 132 :return: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 133 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 134 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 135 array_call = ['faToTwoBit', fasta_file_name, twoBitFile] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 136 _handleExceptionAndCheckCall(array_call) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 137 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 138 return twoBitFile | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 139 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 140 def sortChromSizes(two_bit_info_file_name, chrom_sizes_file_name): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 141 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 142 Call sort with -k2rn on two_bit_info_file_name and write the result into chrom_sizes_file_name | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 143 :param two_bit_info_file_name: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 144 :param chrom_sizes_file_name: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 145 :return: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 146 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 147 array_call = ['sort', '-k2rn', two_bit_info_file_name, | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 148 '-o', chrom_sizes_file_name] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 149 p = _handleExceptionAndCheckCall(array_call) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 150 return p | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 151 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 152 def getChromSizes(reference, tool_dir): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 153 #TODO: find a better way instead of shipping the two exec files with the tool | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 154 faToTwoBit = os.path.join(tool_dir, 'faToTwoBit') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 155 twoBitInfo = os.path.join(tool_dir, 'twoBitInfo') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 156 try: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 157 twoBitFile = tempfile.NamedTemporaryFile(bufsize=0) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 158 chrom_sizes = tempfile.NamedTemporaryFile(bufsize=0, suffix='.chrom.sizes', delete=False) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 159 except IOError as err: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 160 print "Cannot create tempfile err({0}): {1}".format(err.errno, err.strerror) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 161 try: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 162 subprocess.call(['faToTwoBit', reference, twoBitFile.name]) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 163 except OSError as err: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 164 print "Cannot generate twoBitFile from faToTwoBit err({0}): {1}".format(err.errno, err.strerror) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 165 try: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 166 subprocess.call(['twoBitInfo', twoBitFile.name, chrom_sizes.name]) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 167 except OSError as err: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 168 print "Cannot generate chrom_sizes from twoBitInfo err({0}): {1}".format(err.errno, err.strerror) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 169 return chrom_sizes | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 170 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 171 def sequence_region(chrom_sizes): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 172 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 173 This function read from a chromatin size file generated by twoBitInfo and write the information to dict | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 174 return a dict | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 175 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 176 f = open(chrom_sizes, 'r') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 177 sizes = f.readlines() | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 178 sizes_dict = {} | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 179 for line in sizes: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 180 chrom_info = line.rstrip().split('\t') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 181 sizes_dict[chrom_info[0]] = chrom_info[1] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 182 return sizes_dict | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 183 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 184 def child_blocks(parent_field, parent_attr, gff3, child_type): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 185 num = 0 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 186 blockcount = int(parent_attr['blockcount']) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 187 chromstart = parent_attr['chromstarts'].split(',') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 188 blocksize = parent_attr['blocksizes'].split(',') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 189 parent_start = parent_field['start'] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 190 while num < blockcount: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 191 child_attr = OrderedDict() | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 192 child_field = parent_field | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 193 child_field['type'] = child_type | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 194 child_field['start'] = int(chromstart[num]) + int(parent_start) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 195 child_field['end'] = int(child_field['start']) + int(blocksize[num]) - 1 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 196 child_attr['ID'] = parent_attr['ID'] + '_part_' + str(num+1) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 197 child_attr['Parent'] = parent_attr['ID'] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 198 write_features(child_field, child_attr, gff3) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 199 num = num + 1 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 200 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 201 def add_tracks_to_json(trackList_json, new_tracks, modify_type): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 202 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 203 Add to track configuration (trackList.json) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 204 # modify_type = 'add_tracks': add a new track like bam or bigwig, new_track = dict() | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 205 # modify_type = 'add_attr': add configuration to the existing track, new_track = dict(track_name: dict()) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 206 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 207 with open(trackList_json, 'r+') as f: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 208 data = json.load(f) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 209 if modify_type == 'add_tracks': | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 210 data['tracks'].append(new_tracks) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 211 elif modify_type == 'add_attr': | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 212 for k in new_tracks: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 213 for track in data['tracks']: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 214 if k.lower() in track['urlTemplate'].lower(): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 215 attr = new_tracks[k] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 216 for k, v in attr.items(): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 217 track[k] = v | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 218 f.seek(0, 0) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 219 f.write(json.dumps(data, separators=(',' , ':'), indent=4)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 220 f.truncate() | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 221 f.close() | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 222 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 223 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 224 def createBamIndex(bamfile): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 225 subprocess.call(['samtools', 'index', bamfile]) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 226 filename = bamfile + '.bai' | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 227 if os.path.exists(filename): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 228 return filename | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 229 else: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 230 raise ValueError('Did not find bai file') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 231 | 
| 38 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 232 def createFastaIndex(fastaFile): | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 233 subprocess.call(['samtools', 'faidx', fastaFile]) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 234 filename = fastaFile + '.fai' | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 235 if os.path.exists(filename): | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 236 return filename | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 237 else: | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 238 raise ValueError('Did not find fai file') | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 239 | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 240 def gff3sort(inputFile, outputFile, precise=False): | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 241 array_call = ['gff3sort.pl', inputFile, '>', outputFile] | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 242 if precise: | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 243 array_call.append('--precise') | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 244 p = _handleExceptionAndCheckCall(array_call) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 245 return p | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 246 | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 247 def bedSort(inputFile, outputFile): | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 248 array_call = ['sort', '-k1,1', '-k2,2n', '-k6,6', inputFile, '>', outputFile] | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 249 p = _handleExceptionAndCheckCall(array_call) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 250 return p | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 251 | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 252 def bgzip(inputFile): | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 253 subprocess.call(['bgzip', inputFile]) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 254 filename = inputFile + '.gz' | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 255 if os.path.exists(filename): | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 256 return filename | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 257 else: | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 258 raise ValueError('Did not find gz file') | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 259 | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 260 def createTabix(inputFile, dataType): | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 261 subprocess.call(['tabix', '-p', dataType, inputFile]) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 262 filename = inputFile + '.tbi' | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 263 if os.path.exists(filename): | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 264 return filename | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 265 else: | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 266 raise ValueError('Did not find tbi file') | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 267 | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 268 def generate_tabix_indexed_track(inputFile, dataType, outputFolder): | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 269 if "bed" in dataType: | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 270 fileType = 'bed' | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 271 sortedFile = tempfile.NamedTemporaryFile(bufsize=0) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 272 bedSort(inputFile, sortedFile.name) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 273 elif "gff" in dataType: | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 274 fileType = 'gff' | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 275 sortedFile = tempfile.NamedTemporaryFile(bufsize=0) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 276 gff3sort(inputFile, sortedFile.name) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 277 compressedFile = bgzip(sortedFile) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 278 tabixFile = createTabix(compressedFile, fileType) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 279 trackPath = os.path.join(outputFolder, inputFile) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 280 trackIndexPath = os.path.join(outputFolder, inputFile+'.tbi') | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 281 shutil.copy(compressedFile, trackPath) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 282 shutil.copy(tabixFile, trackIndexPath) | 
| 
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
 yating-l parents: 
35diff
changeset | 283 | 
| 35 
68466f5064ce
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit a500f7ab2119cc5faaf80393bd87428389d06880
 yating-l parents: 
32diff
changeset | 284 def flatfile_to_json(inputFile, dataType, trackType, trackLabel, outputFolder, options=None, compress=True): | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 285 if "bed" in dataType: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 286 fileType = "--bed" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 287 elif "gff" in dataType: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 288 fileType = "--gff" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 289 else: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 290 raise ValueError("%s is not a valid filetype for flatfile_to_json" % dataType) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 291 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 292 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 293 array_call = ['flatfile-to-json.pl', | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 294 fileType, inputFile, | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 295 '--trackType', trackType, | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 296 '--trackLabel', trackLabel, | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 297 '--out', outputFolder] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 298 if compress: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 299 array_call.append('--compress') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 300 if options: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 301 config = options.get("config") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 302 clientConfig = options.get("clientConfig") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 303 renderClassName = options.get('renderClassName') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 304 subfeatureClasses = options.get('subfeatureClasses') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 305 load_type = options.get("type") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 306 if clientConfig: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 307 array_call.append('--clientConfig') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 308 array_call.append(clientConfig) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 309 if config: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 310 array_call.append('--config') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 311 array_call.append(config) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 312 if load_type: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 313 array_call.append('--type') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 314 array_call.append(load_type) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 315 if renderClassName: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 316 array_call.append('--renderClassName') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 317 array_call.append(renderClassName) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 318 if subfeatureClasses: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 319 array_call.append('--subfeatureClasses') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 320 array_call.append(json.dumps(subfeatureClasses)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 321 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 322 p = _handleExceptionAndCheckCall(array_call) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 323 return p | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 324 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 325 def bam_to_json(inputFile, trackLabel, outputFolder, options=None, compress=False): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 326 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 327 array_call = ['bam-to-json.pl', | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 328 '--bam', inputFile, | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 329 '--trackLabel', trackLabel, | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 330 '--out', outputFolder] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 331 if compress: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 332 array_call.append('--compress') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 333 if options: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 334 config = options.get('config') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 335 clientConfig = options.get('clientConfig') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 336 if clientConfig: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 337 array_call.append('--clientConfig') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 338 array_call.append(clientConfig) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 339 if config: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 340 array_call.append('--config') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 341 array_call.append(config) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 342 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 343 p = _handleExceptionAndCheckCall(array_call) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 344 return p | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 345 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 346 def add_track_json(trackList, track_json): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 347 track_json = json.dumps(track_json) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 348 new_track = subprocess.Popen(['echo', track_json], stdout=subprocess.PIPE) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 349 p = subprocess.call(['add-track-json.pl', trackList], stdin=new_track.stdout) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 350 return p | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 351 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 352 def prepare_refseqs(fasta_file_name, outputFolder): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 353 array_call = ['prepare-refseqs.pl', '--fasta', fasta_file_name, '--out', outputFolder] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 354 p = _handleExceptionAndCheckCall(array_call) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 355 return p | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 356 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 357 def generate_names(outputFolder): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 358 array_call = ['generate-names.pl', '-v', '--out', outputFolder] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 359 p = _handleExceptionAndCheckCall(array_call) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 360 return p | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 361 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 362 def validateFiles(input_file, chrom_sizes_file_name, file_type, options=None): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 363 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 364 Call validateFiles on input_file, using chrom_sizes_file_name and file_type | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 365 :param input_file: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 366 :param chrom_sizes_file_name: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 367 :param file_type: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 368 :return: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 369 """ | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 370 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 371 array_call = ['validateFiles', '-chromInfo=' + chrom_sizes_file_name, '-type='+ file_type, input_file] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 372 if options: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 373 tab = options.get("tab") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 374 autoSql = options.get("autoSql") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 375 logging.debug("tab: {0}".format(tab)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 376 logging.debug("autoSql: {0}".format(autoSql)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 377 if autoSql: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 378 autoSql = ''.join(['-as=', autoSql]) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 379 array_call.append(autoSql) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 380 if tab: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 381 array_call.append('-tab') | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 382 p = _handleExceptionAndCheckCall(array_call) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 383 return p | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 384 | 
