Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
Rename process_type and protocol_type (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsotirho-ucsc authored and hannes-ucsc committed May 2, 2019
1 parent 6c2f166 commit e366e9e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/humancellatlas/data/metadata/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,14 +643,20 @@ def from_json(cls, json: JSON) -> Iterable['Link']:
# vx
process_id = UUID4(json['process'])
for source_id in json['inputs']:
yield cls(source_id=UUID4(source_id), source_type=json['input_type'],
destination_id=process_id, destination_type='process')
yield cls(source_id=UUID4(source_id),
source_type=json['input_type'],
destination_id=process_id,
destination_type='process')
for destination_id in json['outputs']:
yield cls(source_id=process_id, source_type='process',
destination_id=UUID4(destination_id), destination_type=json['output_type'])
yield cls(source_id=process_id,
source_type='process',
destination_id=UUID4(destination_id),
destination_type=json['output_type'])
for protocol in json['protocols']:
yield cls(source_id=process_id, source_type='process',
destination_id=UUID4(protocol['protocol_id']), destination_type=protocol['protocol_type'])
yield cls(source_id=process_id,
source_type='process',
destination_id=UUID4(protocol['protocol_id']),
destination_type=lookup(protocol, 'type', 'protocol_type'))


@dataclass(init=False)
Expand Down
22 changes: 22 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ def assert_bundle():
self._rename_keys(contributor, name='contact_name')

assert_bundle()

def test_file_format(self):
uuid = '6b498499-c5b4-452f-9ff9-2318dbb86000'
version = '2019-01-03T163633.780215Z'
Expand All @@ -588,6 +589,27 @@ def assert_bundle():

assert_bundle()

def test_link_destination_type(self):
uuid = '6b498499-c5b4-452f-9ff9-2318dbb86000'
version = '2019-01-03T163633.780215Z'
replica = 'aws'
deployment = 'prod'
manifest, metadata_files = self._load_bundle(uuid, version, replica, deployment)

def assert_bundle():
bundle = Bundle(uuid, version, manifest, metadata_files)
destination_types = {link.destination_type for link in bundle.links}
expected_types = {'library_preparation_protocol', 'sequencing_protocol', 'dissociation_protocol',
'differentiation_protocol', 'ipsc_induction_protocol', 'biomaterial', 'process', 'file'}
self.assertEqual(destination_types, expected_types)

assert_bundle()

for link in metadata_files['links.json']['links']:
for protocol in link['protocols']:
self._rename_keys(protocol, type='protocol_type')

assert_bundle()

# noinspection PyUnusedLocal
def load_tests(loader, tests, ignore):
Expand Down

0 comments on commit e366e9e

Please sign in to comment.