Skip to content

Commit

Permalink
Changes finalized and tested
Browse files Browse the repository at this point in the history
  • Loading branch information
ptth222 committed Mar 20, 2024
1 parent a5ca2f1 commit e78f621
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
14 changes: 11 additions & 3 deletions isatools/isatab/dump/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,13 @@ def write_assay_table_files(inv_obj, output_dir, write_factor_values=False):

if not isinstance(inv_obj, Investigation):
raise NotImplementedError
protocol_types_dict = load_protocol_types_info()
yaml_dict = load_protocol_types_info()
protocol_types_dict = {}
for protocol, attributes in yaml_dict.items():
protocol_types_dict[protocol] = attributes
for synonym in attributes[SYNONYMS]:
protocol_types_dict[synonym] = attributes

for study_obj in inv_obj.studies:
for assay_obj in study_obj.assays:
a_graph = assay_obj.graph
Expand Down Expand Up @@ -300,7 +306,8 @@ def flatten(current_list):
else:
protocol_type = node.executes_protocol.protocol_type.lower()

if protocol_type in protocol_types_dict:
if protocol_type in protocol_types_dict and\
protocol_types_dict[protocol_type][HEADER]:
oname_label = protocol_types_dict[protocol_type][HEADER]
else:
oname_label = None
Expand Down Expand Up @@ -360,7 +367,8 @@ def pbar(x):
else:
protocol_type = node.executes_protocol.protocol_type.lower()

if protocol_type in protocol_types_dict:
if protocol_type in protocol_types_dict and\
protocol_types_dict[protocol_type][HEADER]:
oname_label = protocol_types_dict[protocol_type][HEADER]
else:
oname_label = None
Expand Down
24 changes: 12 additions & 12 deletions isatools/model/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,18 @@ def from_assay_dict(self, process, technology_type):
self.name = process.get('name', '')
self.executes_protocol = indexes.get_protocol(process['executesProtocol']['@id'])
self.load_comments(process.get('comments', []))
allowed_protocol_type_terms = [
"nucleic acid sequencing",
"nmr spectroscopy",
"mass spectrometry",
"nucleic acid hybridization",
"data transformation",
"data normalization"
]
if self.executes_protocol.protocol_type.term in allowed_protocol_type_terms or (
self.executes_protocol.protocol_type.term == 'data collection'
and technology_type.term == 'DNA microarray'):
self.name = process['name']
# allowed_protocol_type_terms = [
# "nucleic acid sequencing",
# "nmr spectroscopy",
# "mass spectrometry",
# "nucleic acid hybridization",
# "data transformation",
# "data normalization"
# ]
# if self.executes_protocol.protocol_type.term in allowed_protocol_type_terms or (
# self.executes_protocol.protocol_type.term == 'data collection'
# and technology_type.term == 'DNA microarray'):
# self.name = process['name']

# Inputs / Outputs
for io_data_target in ['inputs', 'outputs']:
Expand Down
11 changes: 2 additions & 9 deletions isatools/model/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,7 @@ def load_protocol_types_info() -> dict:
"""
filepath = os.path.join(os.path.dirname(__file__), '..', 'resources', 'config', 'yaml', 'protocol-types.yml')
with open(filepath) as yaml_file:
yaml_dict = load(yaml_file, Loader=FullLoader)

protocol_types_dict = {}
for protocol, attributes in yaml_dict.items():
protocol_types_dict[protocol] = attributes
for synonym in attributes[SYNONYMS]:
protocol_types_dict[synonym] = attributes

return protocol_types_dict
return load(yaml_file, Loader=FullLoader)



6 changes: 3 additions & 3 deletions isatools/resources/config/yaml/protocol-types.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
sample collection:
header: Sample Name
header:
iri: http://purl.obolibrary.org/obo/OBI_0000659
synonyms:
- sample collection
- sampling
- aliquoting
extraction:
header: Extract Name
header:
iri: http://purl.obolibrary.org/obo/OBI_0302884
synonyms:
- extraction
- metabolite extraction
- intracellular metabolite extraction
- extracelluar metabolite extraction
labeling:
header: Labeled Extract Name
header:
iri: http://purl.obolibrary.org/obo/OBI_0600038
synonyms:
- labeling
Expand Down
2 changes: 1 addition & 1 deletion tests/model/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,4 @@ class TestFunctions(TestCase):
def test_load_protocol_types_info(self):
yaml_config = load_protocol_types_info()
self.assertTrue(isinstance(yaml_config, dict))
self.assertTrue(len(yaml_config.keys()) == 15)
self.assertEqual(len(yaml_config.keys()), 16)

0 comments on commit e78f621

Please sign in to comment.