Skip to content

Commit

Permalink
Merge pull request #13 from mimrock/master
Browse files Browse the repository at this point in the history
Fix nested references
  • Loading branch information
dopefishh committed Apr 22, 2019
2 parents ae19ec1 + 2da89f7 commit 79c747c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pympi/Elan.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,11 +952,25 @@ def get_ref_annotation_data_for_tier(self, id_tier):
"""
bucket = []
for aid, (ref, value, prev, _) in self.tiers[id_tier][1].items():
refann = self.tiers[self.annotations[ref]][0][ref]
refann = self.get_parent_aligned_annotation(ref)
bucket.append((self.timeslots[refann[0]],
self.timeslots[refann[1]], value, refann[2]))
return bucket

def get_parent_aligned_annotation(self, ref_id):
"""" Give the aligment annotation that a reference annotation belongs to directly, or indirectly through other
reference annotations.
:param str ref_id: Id of a reference annotation.
:raises KeyError: If no annotation exists with the id or if it belongs to an alignment annotation.
:returns: The alignment annotation at the end of the reference chain.
"""
parentTier = self.tiers[self.annotations[ref_id]]
while "PARENT_REF" in parentTier[2] and len(parentTier[2]) > 0:
ref_id = parentTier[1][ref_id][0]
parentTier = self.tiers[self.annotations[ref_id]]

return parentTier[0][ref_id]

def get_secondary_linked_files(self):
"""Give all linked files."""
return self.linked_file_descriptors
Expand Down

0 comments on commit 79c747c

Please sign in to comment.