Example #1
0
def test_create_wf_include(test_data_dir, tmpdir, helpers):
    wf_path = test_data_dir / 'test_galaxy_wf.ga'
    extra_file1 = test_data_dir / 'test_file_galaxy.txt'
    extra_file2 = test_data_dir / 'test_file_galaxy2.txt'
    files_list = [extra_file1, extra_file2]
    wf_crate = roc_api.make_workflow_rocrate(wf_path,
                                             wf_type='Galaxy',
                                             include_files=files_list)
    assert isinstance(wf_crate, ROCrate)
    out_path = tmpdir / 'ro_crate_out'
    out_path.mkdir()
    wf_crate.write_crate(out_path)
    json_entities = helpers.read_json_entities(out_path)
    helpers.check_wf_crate(json_entities, wf_path.name)

    wf_out_path = out_path / wf_path.name
    file1 = out_path / extra_file1.name
    file2 = out_path / extra_file2.name
    assert wf_out_path.exists()
    with open(wf_path) as f1, open(wf_out_path) as f2:
        assert f1.read() == f2.read()
    assert file1.exists()
    with open(extra_file1) as f1, open(file1) as f2:
        assert f1.read() == f2.read()
    assert file2.exists()
    with open(extra_file2) as f1, open(file2) as f2:
        assert f1.read() == f2.read()
Example #2
0
def test_galaxy_wf_crate(test_data_dir, tmpdir, helpers):
    wf_id = 'test_galaxy_wf.ga'
    wf_path = test_data_dir / wf_id
    wf_crate = roc_api.make_workflow_rocrate(wf_path, wf_type='Galaxy')
    assert isinstance(wf_crate, ROCrate)

    wf = wf_crate.dereference(wf_id)
    assert wf._default_type == "ComputationalWorkflow"
    assert wf_crate.mainEntity is wf
    lang = wf_crate.dereference("#galaxy")
    assert hasattr(lang, "name")
    assert lang.version == GALAXY_DEFAULT_VERSION
    assert wf["programmingLanguage"] is lang
    assert wf["subjectOf"] is not None
    assert helpers.WORKFLOW_TYPES.issubset(wf["subjectOf"].type)

    out_path = tmpdir / 'ro_crate_out'
    out_path.mkdir()
    wf_crate.write_crate(out_path)
    json_entities = helpers.read_json_entities(out_path)
    helpers.check_wf_crate(json_entities, wf_id)
    wf_entity = json_entities[wf_id]
    assert "subjectOf" in wf_entity
    abstract_wf_id = wf_entity["subjectOf"]["@id"]
    abstract_wf_entity = json_entities[abstract_wf_id]
    assert helpers.WORKFLOW_TYPES.issubset(abstract_wf_entity["@type"])

    wf_out_path = out_path / wf_id
    assert wf_out_path.exists()
    with open(wf_path) as f1, open(wf_out_path) as f2:
        assert f1.read() == f2.read()

    abstract_wf_out_path = out_path / abstract_wf_id
    assert abstract_wf_out_path.exists()
Example #3
0
 def test_create_wf_include(self):
     wf_path = self.test_data_dir / 'test_galaxy_wf.ga'
     extra_file1 = self.test_data_dir / 'test_file_galaxy.txt'
     extra_file2 = self.test_data_dir / 'test_file_galaxy2.txt'
     files_list = [extra_file1, extra_file2]
     wc_crate = roc_api.make_workflow_rocrate(wf_path,
                                              wf_type='Galaxy',
                                              include_files=files_list)
     self.assertIsInstance(wc_crate, ROCrate)
Example #4
0
def test_cwl_wf_crate(test_data_dir, tmpdir, helpers):
    wf_path = test_data_dir / 'sample_cwl_wf.cwl'
    wf_crate = roc_api.make_workflow_rocrate(wf_path, wf_type='CWL')
    assert isinstance(wf_crate, ROCrate)
    out_path = tmpdir / 'ro_crate_out'
    out_path.mkdir()
    wf_crate.write_crate(out_path)
    json_entities = helpers.read_json_entities(out_path)
    helpers.check_wf_crate(json_entities, wf_path.name)

    wf_out_path = out_path / wf_path.name
    assert wf_out_path.exists()
    with open(wf_path) as f1, open(wf_out_path) as f2:
        assert f1.read() == f2.read()
Example #5
0
def test_create_wf_include(test_data_dir, tmpdir, helpers):
    wf_id = 'test_galaxy_wf.ga'
    wf_path = test_data_dir / wf_id
    extra_file1 = test_data_dir / 'test_file_galaxy.txt'
    extra_file2 = test_data_dir / 'test_file_galaxy2.txt'
    files_list = [extra_file1, extra_file2]
    wf_crate = roc_api.make_workflow_rocrate(wf_path,
                                             wf_type='Galaxy',
                                             include_files=files_list)
    assert isinstance(wf_crate, ROCrate)

    wf = wf_crate.dereference(wf_id)
    assert wf_crate.mainEntity is wf
    lang = wf_crate.dereference("#galaxy")
    assert hasattr(lang, "name")
    assert lang.version == GALAXY_DEFAULT_VERSION
    assert wf["programmingLanguage"] is lang
    assert wf["subjectOf"] is not None
    assert helpers.WORKFLOW_TYPES.issubset(wf["subjectOf"].type)
    assert wf_crate.dereference(extra_file1.name) is not None
    assert wf_crate.dereference(extra_file2.name) is not None

    out_path = tmpdir / 'ro_crate_out'
    out_path.mkdir()
    wf_crate.write_crate(out_path)
    json_entities = helpers.read_json_entities(out_path)
    helpers.check_wf_crate(json_entities, wf_id)

    wf_out_path = out_path / wf_id
    file1 = out_path / extra_file1.name
    file2 = out_path / extra_file2.name
    assert wf_out_path.exists()
    with open(wf_path) as f1, open(wf_out_path) as f2:
        assert f1.read() == f2.read()
    assert file1.exists()
    with open(extra_file1) as f1, open(file1) as f2:
        assert f1.read() == f2.read()
    assert file2.exists()
    with open(extra_file2) as f1, open(file2) as f2:
        assert f1.read() == f2.read()
Example #6
0
def test_galaxy_wf_crate(test_data_dir, tmpdir, helpers):
    wf_path = test_data_dir / 'test_galaxy_wf.ga'
    wf_crate = roc_api.make_workflow_rocrate(wf_path, wf_type='Galaxy')
    assert isinstance(wf_crate, ROCrate)
    out_path = tmpdir / 'ro_crate_out'
    out_path.mkdir()
    wf_crate.write_crate(out_path)
    json_entities = helpers.read_json_entities(out_path)
    helpers.check_wf_crate(json_entities, wf_path.name)
    wf_entity = json_entities[wf_path.name]
    assert "subjectOf" in wf_entity
    abstract_wf_id = wf_entity["subjectOf"]["@id"]
    abstract_wf_entity = json_entities[abstract_wf_id]
    assert helpers.WORKFLOW_TYPES.issubset(abstract_wf_entity["@type"])

    wf_out_path = out_path / wf_path.name
    assert wf_out_path.exists()
    with open(wf_path) as f1, open(wf_out_path) as f2:
        assert f1.read() == f2.read()

    abstract_wf_out_path = out_path / abstract_wf_id
    assert abstract_wf_out_path.exists()
Example #7
0
def test_cwl_wf_crate(test_data_dir, tmpdir, helpers):
    wf_id = 'sample_cwl_wf.cwl'
    wf_path = test_data_dir / wf_id
    wf_crate = roc_api.make_workflow_rocrate(wf_path, wf_type='CWL')
    assert isinstance(wf_crate, ROCrate)

    wf = wf_crate.dereference(wf_id)
    assert wf_crate.mainEntity is wf
    lang = wf_crate.dereference("#cwl")
    assert hasattr(lang, "name")
    assert lang.version == CWL_DEFAULT_VERSION
    assert wf["programmingLanguage"] is lang
    assert wf["subjectOf"] is None

    out_path = tmpdir / 'ro_crate_out'
    out_path.mkdir()
    wf_crate.write_crate(out_path)
    json_entities = helpers.read_json_entities(out_path)
    helpers.check_wf_crate(json_entities, wf_id)

    wf_out_path = out_path / wf_id
    assert wf_out_path.exists()
    with open(wf_path) as f1, open(wf_out_path) as f2:
        assert f1.read() == f2.read()
Example #8
0
from rocrate.model.workflow import Workflow
from rocrate.model.file import File
from rocrate.model import entity
from rocrate.model import contextentity
import rocrate.rocrate as roc

with open('/data/docker/RO-crates/arguments.json') as f:
    data = json.load(f)

wf_path = data['location']
files_list = []

Workflow.TYPES = ["File", "SoftwareSourceCode"]

wf_crate = rocrate_api.make_workflow_rocrate(workflow_path=wf_path,
                                             wf_type="CWL",
                                             include_files=files_list)

wf_crate.isBasedOn = data['software_url']
wf_crate.name = data['software_name']
wf_crate.description = data['software_description']
wf_crate.creator = data['creator']
print(data['image'])
wf_crate.image = data['image']

main_entity = entity.Entity(
    wf_crate,
    data['software_url'],
    properties={
        "@id":
        data['software_url'],
Example #9
0
 def test_galaxy_wf_crate(self):
     wf_path = self.test_data_dir / 'test_galaxy_wf.ga'
     wc_crate = roc_api.make_workflow_rocrate(wf_path, wf_type='Galaxy')
     self.assertIsInstance(wc_crate, ROCrate)
Example #10
0
 def test_cwl_wf_crate(self):
     wf_path = self.test_data_dir / 'sample_cwl_wf.cwl'
     wc_crate = roc_api.make_workflow_rocrate(wf_path, wf_type='CWL')
     self.assertIsInstance(wc_crate, ROCrate)