Exemplo n.º 1
0
def test_permutate_job_108():
    handler = JobHandler()

    counter = 0

    def callback(job: Job, parameters: dict, profiles: dict):
        nonlocal counter
        counter = counter + 1
        pass

    test_job = Job(samples=['a', 'b', 'c'],
                   method='abc',
                   profiles={
                       'regression': ['a', 'b'],
                       'similarity': ['d', 'e', 'f']
                   },
                   parameters={
                       'first': [1, 2],
                       'second': [3, 4, 5],
                       'third': [6, 7, 8]
                   })

    handler.permutate_job(test_job, callback=callback)

    assert counter == 108
Exemplo n.º 2
0
def test_job_with_profile_activation_in_tree_format():
    LCB_TUNING_CONFIG['schedule']['limit']['sample_count'].set(0)
    handler = JobHandler()

    job = handler.read_job(f"{ROOT_DIR}/job.example.qtof.yml")

    assert len(job.samples) == 11
    assert job.method == "soqtof[M+H][M+NH4] | 6530a | c18 | positive"
    #    assert len(job.parameters) == 7
    assert len(job.profiles) == 3
    assert len(job.default_profiles) == 4
    assert len(job.default_parameters) == 1

    counter = 0
    counter_linear = 0
    counter_polynomial = 0
    counter_offset = 0

    def callback(job: Job, parameters: list, profiles: list):
        nonlocal counter
        nonlocal counter_offset
        nonlocal counter_linear
        nonlocal counter_polynomial

        assert isinstance(parameters, list)
        assert isinstance(profiles, list)

        counter = counter + 1

        if "carrot.lcms.correction.regression.offset" in profiles:
            keys = list(map(lambda x: x.split("=")[0], parameters))
            assert 'wcmc.workflow.lcms.process.correction.regression.offset.n' in keys
            assert 'wcmc.workflow.lcms.process.correction.regression.offset.linearSamplesEnd' in keys
            counter_offset = counter_offset + 1

        elif "carrot.lcms.correction.regression.linear" in profiles:
            keys = list(map(lambda x: x.split("=")[0], parameters))
            assert 'wcmc.workflow.lcms.process.correction.regression.offset.n' not in keys
            assert 'wcmc.workflow.lcms.process.correction.regression.offset.linearSamplesEnd' not in keys
            counter_linear = counter_linear + 1

        elif "carrot.lcms.correction.regression.polynomial" in profiles:
            keys = list(map(lambda x: x.split("=")[0], parameters))
            assert 'wcmc.workflow.lcms.process.correction.regression.polynomial.n' in keys
            assert 'wcmc.workflow.lcms.process.correction.regression.offset.linearSamplesEnd' not in keys
            counter_polynomial = counter_polynomial + 1
        else:
            raise Exception("invalid combination, should never happen")
        pass

    handler.permutate_job(job, callback=callback)
    assert counter > 0
    assert counter_linear > 0
    assert counter_offset > 0
    assert counter_polynomial == 0
Exemplo n.º 3
0
def test_read_job():
    handler = JobHandler()

    job = handler.read_job(f"{ROOT_DIR}/job.example.yml")

    assert len(job.samples) == 12
    assert job.method == "soqe[M+H][M+NH4] | QExactive | test | positive"
    assert len(job.parameters) == 7
    assert len(job.profiles) == 3
    assert len(job.default_profiles) == 5
    assert len(job.default_parameters) == 1
Exemplo n.º 4
0
def test_job_with_profile_activation():
    handler = JobHandler()

    job = handler.read_job(f"{ROOT_DIR}/job.example.yml")

    assert len(job.samples) == 12
    assert job.method == "soqe[M+H][M+NH4] | QExactive | test | positive"
    assert len(job.parameters) == 7
    assert len(job.profiles) == 3
    assert len(job.default_profiles) == 5
    assert len(job.default_parameters) == 1

    counter = 0
    counter_linear = 0
    counter_polynomial = 0
    counter_offset = 0

    def callback(job: Job, parameters: dict, profiles: dict):
        nonlocal counter
        nonlocal counter_offset
        nonlocal counter_linear
        nonlocal counter_polynomial

        counter = counter + 1

        if "carrot.lcms.correction.regression.offset" in profiles:
            keys = list(map(lambda x: x.split("=")[0], parameters))
            assert 'wcmc.workflow.lcms.process.correction.polynomialOrder' in keys
            assert 'wcmc.workflow.lcms.process.correction.linearSamplesEnd' in keys
            counter_offset = counter_offset + 1

        elif "carrot.lcms.correction.regression.linear" in profiles:
            keys = list(map(lambda x: x.split("=")[0], parameters))
            assert 'wcmc.workflow.lcms.process.correction.polynomialOrder' not in keys
            assert 'wcmc.workflow.lcms.process.correction.linearSamplesEnd' not in keys
            counter_linear = counter_linear + 1

        elif "carrot.lcms.correction.regression.polynomial" in profiles:
            keys = list(map(lambda x: x.split("=")[0], parameters))
            assert 'wcmc.workflow.lcms.process.correction.polynomialOrder' in keys
            assert 'wcmc.workflow.lcms.process.correction.linearSamplesEnd' not in keys
            counter_polynomial = counter_polynomial + 1
        else:
            raise Exception("invalid combination, should never happen")
        pass

    handler.permutate_job(job, callback=callback)
    assert counter > 0
    assert counter_linear > 0
    assert counter_offset > 0
    assert counter_polynomial > 0
Exemplo n.º 5
0
def test_permutate_job_8():
    handler = JobHandler()

    counter = 0

    def callback(job: Job, parameters: dict, profiles: dict):
        nonlocal counter
        counter = counter + 1
        pass

    test_job = Job(samples=['sample_1', 'sample_2', 'sample_3'],
                   method='abc',
                   profiles={'profile': ['a', 'b']},
                   parameters={
                       'number_1_2': [1, 2],
                       'number_3_4': [3, 4]
                   })

    handler.permutate_job(test_job, callback=callback)

    assert counter == 8
Exemplo n.º 6
0
def test_complex_job():
    handler = JobHandler()

    test_job = Job(
        samples=[
            "PNACIC_UnkLip_BTLE_P2_QE_A_POS_13Oct20_Lola-WCSH315112.mzml"
        ],
        method="soqe[M+H][M+NH4] | QExactive | test | positive",
        parameters={
            'wcmc.workflow.lcms.process.correction.polynomialOrder': [3, 5],
            'wcmc.workflow.lcms.process.correction.linearOffsetEnd':
            [3, 5, 8, 13],
            'wcmc.workflow.lcms.process.correction.linearOffsetBegin':
            [3, 5, 8, 13],
        },
        profiles={
            "correction": ["carrot.correction.sliding"],
            "test": ["1", "2", "3"]
        },
        default_profiles=[
            "carrot.similarity.entropy.weighted",
            "carrot.targets.yaml.correction",
            "carrot.targets.yaml.annotation",
            "carrot.resource.loader.bucket",
            "carrot.resource.store.local",
        ],
        default_parameters=[
            "wcmc.workflow.resource.store.multibucket.rawDataBucket=data-carrot"
        ])

    counter = 0

    def callback(job: Job, parameters: dict, profiles: dict):
        nonlocal counter
        counter = counter + 1
        pass

    handler.permutate_job(test_job, callback=callback)

    assert counter == 96