Esempio n. 1
0
def _is_qsub_accessible():
    cluster_exe = which(CLUSTER_CMD)
    if cluster_exe is None:
        m = "Unable to find '{c}'. Cluster tests will be skipped.".format(c=CLUSTER_CMD)
        _log.warn(m)
        print m
    else:
        m = "Found cluster exe '{e}'. Cluster tests will run. (This is setup for pacbio SGE 'production' queue).".format(e=cluster_exe)
        print m
        _log.warn(m)
    return cluster_exe is not None
Esempio n. 2
0
def _dot_to_image(image_type, dot_file, image_file):
    assert image_type.lower() in _SUPPORTED_IMAGE_TYPES

    if not os.path.exists(dot_file):
        raise IOError("Unable to find {f}".format(f=dot_file))

    if which(DOT_EXE) is None:
        raise RequiredExeNotFoundError("Unable to find required external exe '{x}'".format(x=DOT_EXE))

    cmd_str = "{e} -T{t} {i} -o {o}"
    d = dict(e=DOT_EXE, t=image_type, i=dot_file, o=image_file)
    cmd = cmd_str.format(**d)
    rcode, stdout, stderr, run_time = backticks(cmd)

    state = True if rcode == 0 else False
    return state
Esempio n. 3
0
def _dot_to_image(image_type, dot_file, image_file):
    assert image_type.lower() in _SUPPORTED_IMAGE_TYPES

    if not os.path.exists(dot_file):
        raise IOError("Unable to find {f}".format(f=dot_file))

    if which(DOT_EXE) is None:
        raise RequiredExeNotFoundError(
            "Unable to find required external exe '{x}'".format(x=DOT_EXE))

    cmd_str = "{e} -T{t} {i} -o {o}"
    d = dict(e=DOT_EXE, t=image_type, i=dot_file, o=image_file)
    cmd = cmd_str.format(**d)
    rcode, stdout, stderr, run_time = backticks(cmd)

    state = True if rcode == 0 else False
    return state
Esempio n. 4
0
from pbcore.io import FastaReader, FastqReader, openDataSet
from pbcommand.testkit import PbTestApp
from pbcommand.utils import which

log = logging.getLogger(__name__)

DATA = op.join(op.dirname(__file__), "data")


class Constants(object):
    BAX2BAM = "bax2bam"
    BAM2FASTA = "bam2fasta"


# XXX hacks to make sure tools are actually available
HAVE_BAX2BAM = which(Constants.BAX2BAM) is not None
HAVE_BAM2FASTX = which(Constants.BAM2FASTA) is not None
DATA_DIR = "/mnt/secondary-siv/testdata"
HAVE_DATA_DIR = op.isdir(DATA_DIR)


@unittest.skipUnless(HAVE_BAX2BAM and HAVE_DATA_DIR, "Missing bax2bam")
class TestBax2Bam(PbTestApp):
    TASK_ID = "pbsmrtpipe.tasks.h5_subreads_to_subread"
    DRIVER_EMIT = 'python -m pbsmrtpipe.pb_tasks.pacbio emit-tool-contract {i} '.format(
        i=TASK_ID)
    DRIVER_RESOLVE = 'python -m pbsmrtpipe.pb_tasks.pacbio run-rtc '

    # User Provided values
    # Abspath'ed temp files will be automatically generated
    INPUT_FILES = [
Esempio n. 5
0
import subprocess

from pbcommand.testkit import PbTestApp
from pbcommand.utils import which

log = logging.getLogger(__name__)

DATA = op.join(op.dirname(__file__), "data")


class Constants(object):
    BAX2BAM = "bax2bam"
    BAM2FASTA = "bam2fasta"

# XXX hacks to make sure tools are actually available
HAVE_BAX2BAM = which(Constants.BAX2BAM) is not None
HAVE_BAM2FASTX = which(Constants.BAM2FASTA) is not None
DATA_DIR = "/mnt/secondary-siv/testdata"
HAVE_DATA_DIR = op.isdir(DATA_DIR)

@unittest.skipUnless(HAVE_BAX2BAM and HAVE_DATA_DIR, "Missing bax2bam")
class TestBax2Bam(PbTestApp):
    TASK_ID = "pbsmrtpipe.tasks.h5_subreads_to_subread"
    DRIVER_EMIT = 'python -m pbsmrtpipe.pb_tasks.pacbio emit-tool-contract {i} '.format(i=TASK_ID)
    DRIVER_RESOLVE = 'python -m pbsmrtpipe.pb_tasks.pacbio run-rtc '

    # User Provided values
    # Abspath'ed temp files will be automatically generated
    INPUT_FILES = [
        DATA_DIR + "/SA3-RS/lambda/2372215/0007_tiny/m150404_101626_42267_c100807920800000001823174110291514_s1_p0.hdfsubread.xml",
    ]
Esempio n. 6
0
def _resolve_exe(exe):
    """
    Try to resolve the abspath to the exe, default to the exe if not found
    in path"""
    x = which(exe)
    return exe if x is None else os.path.abspath(x)
Esempio n. 7
0
from pbcommand.utils import which
from pbcore.io import openDataSet

log = logging.getLogger(__name__)

# FIXME. Remove this.
PATHS = ('/mnt/usmp-data3/scratch/Labs/Kristofor/python/plotly',
         '/mnt/usmp-data3/scratch/Labs/Kristofor/python/selenium/py')


def raise_if_not_exist(p):
    if not os.path.exists(p):
        raise IOError("Unable to find {p}".format(p=p))
    return p

PH_EXE = which("phantomjs")

if PH_EXE is None:
    PHANTOM_EXE = '/home/knyquist/local/phantomjs-2.1.1-linux-x86_64/bin/phantomjs'
else:
    PHANTOM_EXE = os.path.abspath(PH_EXE)

try:
    import plotly
    import selenium
except ImportError as e:
    warnings.warn("Error {e}\n Trying to import from {p}".format(e=e, p=PATHS))
    for path in PATHS:
        sys.path.append(raise_if_not_exist(path))
    import plotly
    import selenium
class Constants(object):
    BAX2BAM = "bax2bam"
    BAM2FASTA = "bam2fasta"
    BAM2BAM = "bam2bam"
    FASTA2REF = "fasta-to-reference"
    FASTA2GMAP = "fasta-to-gmap-reference"


SIV_DATA_DIR = "/pbi/dept/secondary/siv/testdata"


def _to_skip_msg(exe):
    return "Missing {e} or {d}".format(d=SIV_DATA_DIR, e=exe)

# XXX hacks to make sure tools are actually available
HAVE_BAX2BAM = which(Constants.BAX2BAM) is not None
HAVE_BAM2BAM = which(Constants.BAM2BAM) is not None
HAVE_BAM2FASTX = which(Constants.BAM2FASTA) is not None
HAVE_FASTA2REF = which(Constants.FASTA2REF) is not None
HAVE_FASTA2GMAP = which(Constants.FASTA2GMAP) is not None
HAVE_DATA_DIR = op.isdir(SIV_DATA_DIR)
HAVE_DATA_AND_BAX2BAM = HAVE_BAX2BAM and HAVE_DATA_DIR
HAVE_DATA_AND_BAM2BAM = HAVE_BAM2BAM and HAVE_DATA_DIR

SKIP_MSG_BAX2BAM = _to_skip_msg(Constants.BAX2BAM)
SKIP_MSG_BAM2FX = _to_skip_msg(Constants.BAM2FASTA)
SKIP_MSG_BAM2BAM = _to_skip_msg(Constants.BAM2BAM)
SKIP_MSG_FASTA2REF = _to_skip_msg(Constants.FASTA2REF)
SKIP_MSG_FASTA2GMAP = _to_skip_msg(Constants.FASTA2GMAP)

skip_unless_bax2bam = unittest.skipUnless(HAVE_DATA_AND_BAX2BAM, SKIP_MSG_BAX2BAM)
Esempio n. 9
0
 def test_bad_which(self):
     exe = 'pythonz'
     path = which(exe)
     self.assertIsNone(path)
Esempio n. 10
0
def _resolve_exe(exe):
    """
    Try to resolve the abspath to the exe, default to the exe if not found
    in path"""
    x = which(exe)
    return exe if x is None else os.path.abspath(x)