Class: Bio::GFFbrowser::Helpers::LinkedRecs
- Inherits:
-
Hash
- Object
- Hash
- Bio::GFFbrowser::Helpers::LinkedRecs
- Includes:
- Error
- Defined in:
- lib/bio/db/gff/gffassemble.rb
Overview
Helper class for storing linked records based on a shared ID
Instance Method Summary collapse
- #add(id, rec) ⇒ Object
-
#validate_nonoverlapping ⇒ Object
walk all (CDS) lists for every container/component and validate they do not overlap.
-
#validate_seqname ⇒ Object
Validate all lists belong to the same container/component.
-
#validate_shared_parent ⇒ Object
Validate all lists share the same parent (if available).
Methods included from Error
Instance Method Details
#add(id, rec) ⇒ Object
36 37 38 39 40 |
# File 'lib/bio/db/gff/gffassemble.rb', line 36 def add id, rec info "Adding #{rec.feature_type} <#{id}>" self[id] = [] if self[id] == nil self[id] << rec end |
#validate_nonoverlapping ⇒ Object
walk all (CDS) lists for every container/component and validate they do not overlap
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bio/db/gff/gffassemble.rb', line 75 def validate_nonoverlapping each do | id, rec | sections = Sections::sort(rec) sections.each_with_index do | check, i | neighbour = sections[i+1] if neighbour and check.intersection(neighbour) warn "Overlapping sections for ",id end end end end |
#validate_seqname ⇒ Object
Validate all lists belong to the same container/component
43 44 45 46 47 48 49 50 |
# File 'lib/bio/db/gff/gffassemble.rb', line 43 def validate_seqname each do | id, rec | seqname = rec.first.seqname rec.each do | section | raise "Non-matching seqname #{section.seqname} in #{seqname}" if section.seqname != seqname end end end |
#validate_shared_parent ⇒ Object
Validate all lists share the same parent (if available). First checks for Parent attribute, next for mRNA attribute
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bio/db/gff/gffassemble.rb', line 54 def validate_shared_parent each do | id, rec | parent = rec.first.get_attribute('Parent') if parent rec.each do | section | _parent = section.get_attribute('Parent') raise "Non-matching parent #{_parent} and #{parent} in #{id}" if _parent != parent end end parent = rec.first.get_attribute('mRNA') if parent rec.each do | section | _parent = section.get_attribute('mRNA') raise "Non-matching parent #{_parent} and #{parent} in #{id}" if _parent != parent end end end end |