Skip to content

Commit 6c9294e

Browse files
authored
Merge pull request #332 from mpsonntag/rdfsubclasses
RDF converter: subclassing file fix
2 parents 2d9a95d + 0339329 commit 6c9294e

File tree

6 files changed

+36
-8
lines changed

6 files changed

+36
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ until the next release.
55

66
# Latest changes in master
77

8+
## Minor changes, updates and fixes
9+
- The `section_subclasses.yaml` file is moved from the `doc` folder to the new `odml/resources` folder. This allows usage of the file with all install options. See issue #212 for details.
10+
811
# Version 1.4.3
912

1013
## Introduction of odML templates support and update in odML terminology handling

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
include LICENSE
22
include README.rst
33
include odml/info.json
4-
include doc/section_subclasses.yaml
4+
include odml/resources/section_subclasses.yaml

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ its identifier RRID:SCR_001376 and/or the reference:
135135

136136
### Referenced By
137137

138-
- Dragly et al (2018) [doi:10.3389/fninf.2018.000169](https://doi.org/10.3389/fninf.2018.000169)
138+
- Sprenger et al (2019) [doi:10.3389/fninf.2019.00062](https://doi.org/10.3389/fninf.2019.00062)
139+
- Dragly et al (2018) [doi:10.3389/fninf.2018.00016](https://doi.org/10.3389/fninf.2018.00016)
139140
- Brochier et al (2018) [doi:10.1038/sdata.2018.55](https://doi.org/10.1038/sdata.2018.55)
140141
- Moucek et al (2017) [doi:10.1038/sdata.2016.121](https://doi.org/10.1038/sdata.2016.121)
141142
- Papez et al (2017) [doi:10.3389/fninf.2017.00024](https://doi.org/10.3389/fninf.2017.00024)

doc/section_subclasses.yaml renamed to odml/resources/section_subclasses.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,27 @@ analysis: Analysis
22
analysis/psth: PSTH
33
analysis/power_spectrum: PowerSpectrum
44
cell: Cell
5+
datacite/alternate_identifier: AlternateIdentifier
6+
datacite/contributor: Contributer
7+
datacite/contributor/affiliation: Affiliation
8+
datacite/contributor/named_identifier: NamedIdentifier
9+
datacite/creator: Creator
10+
datacite/creator/affiliation: Affiliation
11+
datacite/creator/named_identifier: NamedIdentifier
12+
datacite/date: Date
13+
datacite/description: Description
14+
datacite/format: Format
15+
datacite/funding_reference: FundingReference
16+
datacite/geo_location: GeoLocation
17+
datacite/identifier: Identifier
18+
datacite/related_identifier: RelatedIdentifier
19+
datacite/resource_type: ResourceType
20+
datacite/rights: Rights
21+
datacite/size: Size
22+
datacite/subject: Subject
23+
datacite/title: Title
524
dataset: Dataset
25+
data_reference: DataReference
626
blackrock: Blackrock
727
electrode: Electrode
828
event: Event
@@ -51,4 +71,4 @@ stimulus/sine_wave: Sinewave
5171
stimulus/square_wave: Squarewave
5272
stimulus/white_noise: Whitenoise
5373
subject: Subject
54-
carmen_mini: CarmenMini
74+
carmen_mini: CarmenMini

odml/tools/rdf_converter.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def __init__(self, odml_documents):
4343

4444
self.section_subclasses = {}
4545

46-
subclass_path = os.path.join(dirname(dirname(dirname(abspath(__file__)))),
47-
'doc', 'section_subclasses.yaml')
46+
subclass_path = os.path.join(odml.__path__[0], 'resources',
47+
'section_subclasses.yaml')
4848

4949
if os.path.isfile(subclass_path):
5050
with open(subclass_path, "r") as f:
@@ -53,6 +53,8 @@ def __init__(self, odml_documents):
5353
except yaml.parser.ParserError as err:
5454
print(err)
5555
return
56+
else:
57+
print("[Warning] Could not find subclass file '%s'" % subclass_path)
5658

5759
def convert_to_rdf(self):
5860
self.hub_root = URIRef(odmlns.Hub)
@@ -125,8 +127,10 @@ def save_element(self, e, node=None):
125127
self.g.add((curr_node, fmt.rdf_map(k), node))
126128
self.save_element(p, node)
127129
elif isinstance(fmt, Property.__class__) and \
128-
k == 'value' and len(getattr(e, k)) > 0:
129-
values = getattr(e, k)
130+
k == 'value' and len(getattr(e, fmt.map(k))) > 0:
131+
# "value" needs to be mapped to its appropriate
132+
# Property library attribute.
133+
values = getattr(e, fmt.map(k))
130134
seq = URIRef(odmlns + unicode(uuid.uuid4()))
131135
self.g.add((seq, RDF.type, RDF.Seq))
132136
self.g.add((curr_node, fmt.rdf_map(k), seq))

test/test_rdf_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_adding_values(self):
132132
object=Literal("val")))), 3)
133133

134134
def test_section_subclass(self):
135-
p = os.path.join(dirname(dirname(abspath(__file__))), 'doc', 'section_subclasses.yaml')
135+
p = os.path.join(odml.__path__[0], 'resources', 'section_subclasses.yaml')
136136
with open(p, "r") as f:
137137
subclass = yaml.load(f)
138138

0 commit comments

Comments
 (0)