Skip to content

Commit

Permalink
Add datamodel docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Feb 26, 2024
1 parent 9c9d8a1 commit 6cc9795
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 133 deletions.
87 changes: 87 additions & 0 deletions lib/apidocs/DataModel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
id: datamodel
title: DataModel
---

Note: this document is automatically generated from mobx-state-tree objects in
our source code.

### Source file

[src/DataModel.ts](https://github.com/GMOD/react-msaview/blob/main/lib/src/DataModel.ts)

the data stored for the model. this is sometimes temporary in the case that
e.g. msaFilehandle is available on the parent model, because then the msa
data will not be persisted in saved session snapshots, it will be fetched
from msaFilehandle at startup

### DataModel - Properties
#### property: msa



```js
// type signature
IMaybe<ISimpleType<string>>
// code
msa: types.maybe(types.string)
```

#### property: tree



```js
// type signature
IMaybe<ISimpleType<string>>
// code
tree: types.maybe(types.string)
```

#### property: treeMetadata



```js
// type signature
IMaybe<ISimpleType<string>>
// code
treeMetadata: types.maybe(types.string)
```








### DataModel - Actions
#### action: setMSA



```js
// type signature
setMSA: (msa?: string) => void
```

#### action: setTree



```js
// type signature
setTree: (tree?: string) => void
```

#### action: setTreeMetadata



```js
// type signature
setTreeMetadata: (treeMetadata?: string) => void
```


118 changes: 41 additions & 77 deletions lib/apidocs/MsaView.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@ extends
- DialogQueueSessionMixin

### MsaView - Properties
#### property: annotatedRegions

current "annotated regions"

```js
// type signature
IArrayType<IModelType<{ start: ISimpleType<number>; end: ISimpleType<number>; attributes: IType<Record<string, string[]>, Record<string, string[]>, Record<string, string[]>>; }, {}, _NotCustomized, _NotCustomized>>
// code
annotatedRegions: types.array(
types.model({
start: types.number,
end: types.number,
attributes: types.frozen<Record<string, string[]>>(),
}),
)
```

#### property: bgColor

draw MSA tiles with a background color
Expand Down Expand Up @@ -108,26 +91,7 @@ autorun
// type signature
IOptionalIType<IModelType<{ tree: IMaybe<ISimpleType<string>>; msa: IMaybe<ISimpleType<string>>; treeMetadata: IMaybe<ISimpleType<string>>; }, { ...; }, _NotCustomized, _NotCustomized>, [...]>
// code
data: types.optional(
types
.model({
tree: types.maybe(types.string),
msa: types.maybe(types.string),
treeMetadata: types.maybe(types.string),
})
.actions(self => ({
setTree(tree?: string) {
self.tree = tree
},
setMSA(msa?: string) {
self.msa = msa
},
setTreeMetadata(treeMetadata?: string) {
self.treeMetadata = treeMetadata
},
})),
{ tree: '', msa: '' },
)
data: types.optional(DataModelF(), { tree: '', msa: '' })
```

#### property: drawNodeBubbles
Expand Down Expand Up @@ -279,7 +243,7 @@ showBranchLen: true
#### property: showOnly
array of tree nodes to show (invert of collapsed)
focus on particular subtree
```js
// type signature
Expand Down Expand Up @@ -383,15 +347,6 @@ BasicTrack[]
any
```
#### getter: annotationTrackModels
```js
// type
BasicTrack[]
```
#### getter: blanks
Expand All @@ -407,7 +362,7 @@ any[]
```js
// type
number[][]
any[]
```
#### getter: blocksX
Expand All @@ -416,7 +371,7 @@ number[][]
```js
// type
number[]
any[]
```
#### getter: blocksY
Expand All @@ -425,7 +380,7 @@ number[]
```js
// type
number[]
any[]
```
#### getter: boxTrackModels
Expand Down Expand Up @@ -549,6 +504,15 @@ boolean
```js
// type
number
```
#### getter: maxScrollX
```js
// type
number
Expand Down Expand Up @@ -675,6 +639,15 @@ number
total height of track area (px)
```js
// type
number
```
#### getter: totalWidth
```js
// type
number
Expand All @@ -689,6 +662,15 @@ number
BasicTrack[]
```
#### getter: treeAreaWidthMinusMargin
```js
// type
number
```
#### getter: treeMetadata
Expand Down Expand Up @@ -792,15 +774,6 @@ rowSpecificBpToPx: (rowName: string, position: number) => number
### MsaView - Actions
#### action: addAnnotation
add a new annotated region, in 'global' coordinates
```js
// type signature
addAnnotation: (start: number, end: number, attributes: Record<string, string[]>) => void
```
#### action: addStructureToSelection
add to the selected structures
Expand All @@ -819,15 +792,6 @@ addStructureToSelection: (elt: ModelCreationType<ExtractCFromProps<{ id: ISimple
addUniprotTrack: (node: { name: string; accession: string; }) => void
```
#### action: clearAnnotationClickBoundaries
internal, used for annotation click-and-drag state
```js
// type signature
clearAnnotationClickBoundaries: () => void
```
#### action: clearHidden
Expand Down Expand Up @@ -864,6 +828,15 @@ doScrollX: (deltaX: number) => void
doScrollY: (deltaY: number) => void
```
#### action: exportSVG
```js
// type signature
exportSVG: (opts: { theme: Theme; includeMinimap?: boolean; exportType: string; }) => Promise<void>
```
#### action: hideNode
Expand Down Expand Up @@ -891,15 +864,6 @@ remove from the selected structures
removeStructureFromSelection: (elt: ModelCreationType<ExtractCFromProps<{ id: ISimpleType<string>; structure: IModelType<{ pdb: ISimpleType<string>; startPos: ISimpleType<number>; endPos: ISimpleType<number>; }, {}, _NotCustomized, _NotCustomized>; range: IMaybe<...>; }>>) => void
```
#### action: setAnnotationClickBoundaries
internal, used for annotation click-and-drag state
```js
// type signature
setAnnotationClickBoundaries: (left: number, right: number) => void
```
#### action: setBgColor
Expand Down
46 changes: 46 additions & 0 deletions lib/src/DataModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { types } from 'mobx-state-tree'

/**
* #stateModel DataModel
* the data stored for the model. this is sometimes temporary in the case that
* e.g. msaFilehandle is available on the parent model, because then the msa
* data will not be persisted in saved session snapshots, it will be fetched
* from msaFilehandle at startup
*/
export function DataModelF() {
return types
.model({
/**
* #property
*/
tree: types.maybe(types.string),
/**
* #property
*/
msa: types.maybe(types.string),
/**
* #property
*/
treeMetadata: types.maybe(types.string),
})
.actions(self => ({
/**
* #action
*/
setTree(tree?: string) {
self.tree = tree
},
/**
* #action
*/
setMSA(msa?: string) {
self.msa = msa
},
/**
* #action
*/
setTreeMetadata(treeMetadata?: string) {
self.treeMetadata = treeMetadata
},
}))
}
25 changes: 4 additions & 21 deletions lib/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { hierarchy, cluster, HierarchyNode } from 'd3-hierarchy'
import { ascending } from 'd3-array'
import Stockholm from 'stockholm-js'
import { saveAs } from 'file-saver'
import { Theme } from '@mui/material'

// jbrowse
import { FileLocation, ElementId } from '@jbrowse/core/util/types/mst'
import { FileLocation as FileLocationType } from '@jbrowse/core/util/types'
Expand Down Expand Up @@ -35,9 +37,9 @@ import { UniprotTrack } from './UniprotTrack'
import { StructureModel } from './StructureModel'
import { DialogQueueSessionMixin } from './DialogQueue'
import { renderToSvg } from './renderToSvg'
import { Theme } from '@mui/material'
import { blocksX, blocksY } from './calculateBlocks'
import measureTextCanvas from './measureTextCanvas'
import { DataModelF } from './DataModel'

export interface RowDetails {
[key: string]: unknown
Expand Down Expand Up @@ -274,26 +276,7 @@ const model = types
* data from the loaded tree/msa/treeMetadata, generally loaded by
* autorun
*/
data: types.optional(
types
.model({
tree: types.maybe(types.string),
msa: types.maybe(types.string),
treeMetadata: types.maybe(types.string),
})
.actions(self => ({
setTree(tree?: string) {
self.tree = tree
},
setMSA(msa?: string) {
self.msa = msa
},
setTreeMetadata(treeMetadata?: string) {
self.treeMetadata = treeMetadata
},
})),
{ tree: '', msa: '' },
),
data: types.optional(DataModelF(), { tree: '', msa: '' }),
}),
)
.volatile(() => ({
Expand Down
Loading

0 comments on commit 6cc9795

Please sign in to comment.