Skip to content
depha edited this page Oct 17, 2013 · 1 revision

Core Classes

Data model

  • Gentle: master class, handles sequences, settings, user management
  • Sequence: handles history, triggers change events
  • Annotation
  • User

Storage adapters

Views

Gentle class

Implements a basic event pub/sub mechanism (should be much faster than resorting to jQuery's). Follows jQuery naming convention. Events are namespaces so that triggering 'currentSequence:update:deleted' also triggers 'currentSequence:update' and 'currentSequence'. (This is different from jQuery event namespaces. Most non-DOM-related events are expected to go through the Gentle object.

Lives in window so is accessible to every object (but most methods are private)

Public Methods

  • on ( name, callback )
  • off ( name[, callback] )
  • trigger ( name[, payload] )

Public Properties

  • CurrentSequence: reference to the currently opened sequence
  • sequences: collection of sequences keyed by ID
  • settings: object

Sequence class

Other objects access the content of the sequences through getters/setters to allow us to handle it as we want in its entirety (buffer arrays, strings, etc).

Should the getters/setters return promises? It sounds like over-engineering but if we have a situation where we stream sequences from a source and another module requests a range of bases which isn't loaded yet, this could help.

For revision purposes, the setters will record the history of what's happening (and only the diffs will be sent to the server for saving)

Events

Events are triggered on Gentle object, if the sequence is the current sequence.

  • currentSequence:load
  • currentSequence:change: new sequence selected
  • currentSequence:update: sends information about which bases have changed

Public Methods

  • get ( [rangeStart[, rangeEnd]] )
  • delete ( [rangeStart[, rangeEnd]] )
  • insert ( content, rangeStart[, rangeEnd] )
  • move ( rangeStart, rangeEnd, targetStart )
  • getAnnotations ( [rangeStart[, rangeEnd]] )

Revisioning

Ideas for how to store the diffs in a database: (Sequence object can probably work with object description of this)

  • additions: +@START_POS_IN_ORIGINAL_FILE@SEQUENCE, e.g. +@1456@ATCGEZRH
  • deletions: -@START_POS_IN_ORIGINAL_FILE,END_POS_IN_ORIGINAL_FILE@
  • movement: -@START_POS_IN_ORIGINAL_FILE,END_POS_IN_ORIGINAL_FILE@+@START_POS_AFTER_DELETION@ or =@START_POS_IN_ORIGINAL_FILE,END_POS_IN_ORIGINAL_FILE, NEW_START_POS_IN_ORIGINAL_FILE@

Canvas classes

Canvas classes are bound to sequence events (currentSequence:change, currentSequence:update) and window scrolling events. They interface with the sequences through Gentle.currentSequence

They register with the UI Layout manager (and are added to the DOM at the same time), handle their own redraw. UI manager notifies object if it is not hidden anymore, which triggers an unbinding of the Canvas object's event listeners

Canvas classes should be extended from CommonCanvas objects which will allow us to work with WebGl or normal canvas methods seamlessly.

UI classes

UI

Dependencies

  • jQuery
  • underscore (or lo-dash?)
  • ..?

Syntax conventions

  • ObjectNames
  • paramNames
  • this_ rather than that or self for context scoping (completely arbitrary choice, but let's pick one)