示例#1
0
def test_check__can_pickle():
    def _do_test_can_pickle(obj):
        pickle.dumps(obj)

    yield _do_test_can_pickle, versions.EQ(1, 2, 3)
    yield _do_test_can_pickle, versions.GE(1, 2, 3)
    yield _do_test_can_pickle, versions.LT(1, 2, 3)
    yield _do_test_can_pickle, versions.Any()
    yield _do_test_can_pickle, versions.And(versions.EQ(1, 2, 3))
    yield _do_test_can_pickle, versions.Or(versions.GE(1, 2, 3))
示例#2
0
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
import os

from paleomix.node import CommandNode
from paleomix.atomiccmd.command import AtomicCmd
from paleomix.atomiccmd.sets import SequentialCmds

from paleomix.common.fileutils import reroot_path, swap_ext
import paleomix.common.versions as versions

_VERSION_REGEX = r"Version: (\d+)\.(\d+)(?:\.(\d+))?"

# v0.2.0 was the pre-release version of v1.0, and lacks required features
_COMMON_CHECK = versions.Or(versions.EQ(0, 1, 19), versions.GE(1, 0, 0))

SAMTOOLS_VERSION = versions.Requirement(call=("samtools", ),
                                        search=_VERSION_REGEX,
                                        checks=_COMMON_CHECK)

SAMTOOLS_VERSION_1x = versions.Requirement(call=("samtools", ),
                                           search=_VERSION_REGEX,
                                           checks=versions.GE(1, 0, 0))

SAMTOOLS_VERSION_0119 = versions.Requirement(call=("samtools", ),
                                             search=_VERSION_REGEX,
                                             checks=versions.EQ(0, 1, 19))

BCFTOOLS_VERSION_0119 \
    = versions.Requirement(call=("bcftools",),
示例#3
0
文件: bwa.py 项目: jelber2/paleomix
    use_customizable_cli_parameters, \
    create_customizable_cli_parameters

from paleomix.atomiccmd.sets import ParallelCmds
from paleomix.nodes.samtools import SAMTOOLS_VERSION
from paleomix.common.fileutils import \
    describe_paired_files, \
    missing_files

import paleomix.common.versions as versions
import paleomix.tools.factory as factory


BWA_VERSION = versions.Requirement(call=("bwa",),
                                   search=r"Version: (\d+)\.(\d+)\.(\d+)",
                                   checks=versions.Or(versions.EQ(0, 5, 9),
                                                      versions.EQ(0, 5, 10),
                                                      versions.EQ(0, 6, 2),
                                                      versions.GE(0, 7, 9)))

BWA_VERSION_07x = versions.Requirement(call=("bwa",),
                                       search=r"Version: (\d+)\.(\d+)\.(\d+)",
                                       checks=versions.GE(0, 7, 9))


class BWAIndexNode(CommandNode):
    def __init__(self, input_file, prefix=None, dependencies=()):
        prefix = prefix if prefix else input_file
        builder = _get_bwa_template(("bwa", "index"), prefix, iotype="OUT",
                                    IN_FILE=input_file,
                                    TEMP_OUT_PREFIX=os.path.basename(prefix),
示例#4
0
def test_eq__check_values__not_equal():
    obj = versions.EQ(2, 3)
    assert not obj((1, 3))
    assert not obj((2, 2))
    assert not obj((1, 4))
示例#5
0
def test_eq__check_values__equal():
    obj = versions.EQ(2, 3)
    assert obj((2, 3))
示例#6
0
def test_eq__str__two_values():
    obj = versions.EQ(2, 1)
    assert str(obj) == "v2.1.x"
示例#7
0
def test_eq__str__one_value():
    obj = versions.EQ(1)
    assert str(obj) == "v1.x"
示例#8
0
def test_eq__check_values__not_equal_too_few_values():
    obj = versions.EQ(2, 3)
    with pytest.raises(ValueError):
        obj((1, ))
示例#9
0
def test_eq__check_values__equal_truncated():
    obj = versions.EQ(2, 3)
    assert obj((2, 3, 1))
示例#10
0
        checks=versions.GE(1, 1),
        name="test#1",
    )
    try:
        obj()
        assert False  # pragma: no coverage
    except versions.VersionRequirementError as error:
        assert str(error) == expected


###############################################################################
###############################################################################
# Pickling of checks

_CAN_PICKLE_VALUES = (
    versions.EQ(1, 2, 3),
    versions.GE(1, 2, 3),
    versions.LT(1, 2, 3),
    versions.Any(),
    versions.And(versions.EQ(1, 2, 3)),
    versions.Or(versions.GE(1, 2, 3)),
)


@pytest.mark.parametrize("obj", _CAN_PICKLE_VALUES)
def test_check__can_pickle(obj):
    pickle.dumps(obj)


###############################################################################
###############################################################################
示例#11
0
def test_eq__str__two_values():
    obj = versions.EQ(2, 1)
    assert_equal(str(obj), "v2.1.x")
示例#12
0
def test_eq__str__one_value():
    obj = versions.EQ(1)
    assert_equal(str(obj), "v1.x")
示例#13
0
def test_eq__check_values__not_equal_too_few_values():
    obj = versions.EQ(2, 3)
    assert_raises(ValueError, obj, (1, ))