class Bio::GFFbrowser::Helpers::LinkedRecs

Helper class for storing linked records based on a shared ID

Public Instance Methods

add(id, rec) click to toggle source
# File lib/bio/db/gff/gffvalidate.rb, line 37
def add id, rec
  info "Adding #{rec.feature_type} (validate)",id
  raise "ID should not be empty" if id == nil or id == ""
  self[id] = [] if self[id] == nil
  self[id] << rec
end
validate_nonoverlapping() click to toggle source

walk all (CDS) lists for every container/component and validate they do not overlap

# File lib/bio/db/gff/gffvalidate.rb, line 77
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() click to toggle source

Validate all lists belong to the same container/component

# File lib/bio/db/gff/gffvalidate.rb, line 45
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() click to toggle source

Validate all lists share the same parent (if available). First checks for Parent attribute, next for mRNA attribute

# File lib/bio/db/gff/gffvalidate.rb, line 56
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