@teselagen/ove 0.6.1-beta.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,13 +7,13 @@ import {
7
7
  import AddOrEditAnnotationDialog from "../AddOrEditAnnotationDialog";
8
8
  import { ReactSelectField } from "@teselagen/ui";
9
9
 
10
- const renderTypes = ({ readOnly }) => (
10
+ const RenderTypes = ({ readOnly, type }) => (
11
11
  <ReactSelectField
12
12
  inlineLabel
13
13
  tooltipError
14
14
  disabled={readOnly}
15
- defaultValue="misc_feature"
16
- options={getFeatureTypes().map(type => {
15
+ defaultValue={type ?? "misc_feature"}
16
+ options={getFeatureTypes().map(featureType => {
17
17
  return {
18
18
  label: (
19
19
  <div
@@ -25,16 +25,18 @@ const renderTypes = ({ readOnly }) => (
25
25
  >
26
26
  <div
27
27
  style={{
28
- background: getFeatureToColorMap({ includeHidden: true })[type],
28
+ background: getFeatureToColorMap({ includeHidden: true })[
29
+ featureType
30
+ ],
29
31
  height: 15,
30
32
  width: 15,
31
33
  marginRight: 5
32
34
  }}
33
35
  />
34
- {type}
36
+ {featureType}
35
37
  </div>
36
38
  ),
37
- value: type
39
+ value: featureType
38
40
  };
39
41
  })}
40
42
  name="type"
@@ -52,7 +54,7 @@ export default AddOrEditAnnotationDialog({
52
54
  upsertAnnotation: props.upsertFeature,
53
55
  // renderLocations: true, //tnw enable this eventually for proteins
54
56
  renderLocations: !props.sequenceData.isProtein,
55
- renderTypes: renderTypes({ readOnly: props.readOnly }),
57
+ RenderTypes,
56
58
  annotationTypePlural: "features"
57
59
  })
58
60
  });
@@ -9,12 +9,12 @@ import {
9
9
  import { getFeatureTypes } from "@teselagen/sequence-utils";
10
10
  import { get } from "lodash-es";
11
11
 
12
- const renderTypes = ({ readOnly }) => (
12
+ const RenderTypes = ({ readOnly, type }) => (
13
13
  <ReactSelectField
14
14
  inlineLabel
15
15
  tooltipError
16
16
  disabled={readOnly}
17
- defaultValue="misc_feature"
17
+ defaultValue={type ?? "misc_feature"}
18
18
  options={getFeatureTypes().map(type => {
19
19
  return {
20
20
  label: type,
@@ -88,7 +88,7 @@ export default AddOrEditAnnotationDialog({
88
88
  advancedOptions: props.allowPartsToOverlapSelf
89
89
  ? renderAdvancedOptions({ readOnly: props.readOnly })
90
90
  : undefined,
91
- renderTypes: renderTypes({ readOnly: props.readOnly }),
91
+ RenderTypes,
92
92
  renderTags:
93
93
  props.allPartTags &&
94
94
  getRenderTags({
@@ -33,9 +33,9 @@ const CustomContentEditable = generateField(function CustomContentEditable({
33
33
  start,
34
34
  end,
35
35
  primerBindsOn,
36
- bases,
37
36
  forward
38
37
  }) {
38
+ const bases = input.value;
39
39
  const [hasTempError, setTempError] = useState(false);
40
40
  const inputRef = useRef(null);
41
41
  const [caretPosition, setCaretPosition] = useState({ start: 0, end: 0 });
@@ -194,7 +194,7 @@ const RenderBases = props => {
194
194
  label="Linked Oligo?"
195
195
  tooltipInfo={`Check this box to link this primer to an oligo in your Oligo Library. If the primer bases match exactly the bases of an existing oligo, it will be linked to that existing oligo. If the bases don't match, a new oligo will be created in the library.`}
196
196
  noMarginBottom
197
- defaultValue={true}
197
+ defaultValue={useLinkedOligo ?? true}
198
198
  disabled={readOnly}
199
199
  ></CheckboxField>
200
200
  {useLinkedOligo && (
@@ -221,11 +221,7 @@ const RenderBases = props => {
221
221
  sequenceLength={sequenceLength}
222
222
  disabled={readOnly}
223
223
  {...props}
224
- {...(defaultValue
225
- ? {
226
- defaultValue
227
- }
228
- : {})}
224
+ defaultValue={bases ?? defaultValue}
229
225
  name="bases"
230
226
  label={
231
227
  <div className="tg-bases-label">
@@ -44,15 +44,58 @@ const genericAnnotationProperties = ({
44
44
  constructor(props) {
45
45
  super(props);
46
46
  this.commands = commands(this);
47
+ }
48
+ onRowSelect = ([record]) => {
49
+ if (!record) return;
50
+ const { dispatch, editorName } = this.props;
51
+ dispatch({
52
+ type: "SELECTION_LAYER_UPDATE",
53
+ payload: record,
54
+ meta: {
55
+ editorName
56
+ }
57
+ });
58
+ };
59
+ render() {
60
+ const {
61
+ readOnly,
62
+ annotations = {},
63
+ annotationVisibility,
64
+ sequenceLength,
65
+ selectionLayer,
66
+ sequence,
67
+ isProtein,
68
+ allPartTags,
69
+ annotationPropertiesSelectedEntities:
70
+ _annotationPropertiesSelectedEntities,
71
+ selectedAnnotationId
72
+ } = this.props;
73
+ const annotationPropertiesSelectedEntities =
74
+ _annotationPropertiesSelectedEntities.filter(a => annotations[a.id]);
75
+
76
+ const deleteAnnotation = this.props[`delete${annotationTypeUpper}`];
77
+
78
+ const annotationsToUse = map(annotations, annotation => {
79
+ return {
80
+ ...annotation,
81
+ ...(annotation.strand === undefined && {
82
+ strand: annotation.forward ? 1 : -1
83
+ }),
84
+ size: getRangeLength(annotation, sequenceLength)
85
+ };
86
+ });
87
+
88
+ const keyedPartTags = getKeyedTagsAndTagOptions(allPartTags) ?? {};
89
+
47
90
  this.schema = {
48
91
  fields: [
49
92
  {
50
93
  path: "name",
51
94
  type: "string",
52
95
 
53
- render: (name, ann, row, props) => {
96
+ render: (name, ann) => {
54
97
  const checked =
55
- !props.annotationVisibility[
98
+ !this.props.annotationVisibility[
56
99
  `${annotationType}IndividualToHide`
57
100
  ][ann.id];
58
101
 
@@ -64,9 +107,9 @@ const genericAnnotationProperties = ({
64
107
  e.stopPropagation();
65
108
  const upperType = startCase(annotationType);
66
109
  if (checked) {
67
- props[`hide${upperType}Individual`]([ann.id]);
110
+ this.props[`hide${upperType}Individual`]([ann.id]);
68
111
  } else {
69
- props[`show${upperType}Individual`]([ann.id]);
112
+ this.props[`show${upperType}Individual`]([ann.id]);
70
113
  }
71
114
  }}
72
115
  style={{
@@ -89,10 +132,10 @@ const genericAnnotationProperties = ({
89
132
  {
90
133
  path: "bases",
91
134
  type: "string",
92
- render: (bases, primer, row, props) => {
135
+ render: (bases, primer) => {
93
136
  let bps = bases;
94
137
  if (!bases) {
95
- bps = getSequenceWithinRange(primer, props.sequence);
138
+ bps = getSequenceWithinRange(primer, this.props.sequence);
96
139
  if (!primer.forward) {
97
140
  bps = getReverseComplementSequenceString(bps);
98
141
  }
@@ -121,13 +164,13 @@ const genericAnnotationProperties = ({
121
164
  }
122
165
  }
123
166
  ]),
124
- sizeSchema,
167
+ sizeSchema(this.props.isProtein),
125
168
  ...(withTags && this.props.allPartTags
126
169
  ? [
127
170
  {
128
171
  path: "tags",
129
172
  type: "string",
130
- getValueToFilterOn: (o, { keyedPartTags }) => {
173
+ getValueToFilterOn: o => {
131
174
  const toRet = (o.tags || [])
132
175
  .map(tagId => {
133
176
  const tag = keyedPartTags[tagId];
@@ -137,7 +180,7 @@ const genericAnnotationProperties = ({
137
180
  .join(" ");
138
181
  return toRet;
139
182
  },
140
- render: (tags, b, c, { keyedPartTags = {} }) => {
183
+ render: tags => {
141
184
  return (
142
185
  <div style={{ display: "flex" }}>
143
186
  {(tags || []).map((tagId, i) => {
@@ -154,46 +197,6 @@ const genericAnnotationProperties = ({
154
197
  { path: "strand", type: "number" }
155
198
  ]
156
199
  };
157
- }
158
- onRowSelect = ([record]) => {
159
- if (!record) return;
160
- const { dispatch, editorName } = this.props;
161
- dispatch({
162
- type: "SELECTION_LAYER_UPDATE",
163
- payload: record,
164
- meta: {
165
- editorName
166
- }
167
- });
168
- };
169
- render() {
170
- const {
171
- readOnly,
172
- annotations = {},
173
- annotationVisibility,
174
- sequenceLength,
175
- selectionLayer,
176
- sequence,
177
- isProtein,
178
- allPartTags,
179
- annotationPropertiesSelectedEntities:
180
- _annotationPropertiesSelectedEntities,
181
- selectedAnnotationId
182
- } = this.props;
183
- const annotationPropertiesSelectedEntities =
184
- _annotationPropertiesSelectedEntities.filter(a => annotations[a.id]);
185
-
186
- const deleteAnnotation = this.props[`delete${annotationTypeUpper}`];
187
-
188
- const annotationsToUse = map(annotations, annotation => {
189
- return {
190
- ...annotation,
191
- ...(annotation.strand === undefined && {
192
- strand: annotation.forward ? 1 : -1
193
- }),
194
- size: getRangeLength(annotation, sequenceLength)
195
- };
196
- });
197
200
 
198
201
  return (
199
202
  <DataTable
@@ -337,7 +340,6 @@ const genericAnnotationProperties = ({
337
340
  formName="annotationProperties"
338
341
  noRouter
339
342
  isProtein={isProtein}
340
- keyedPartTags={getKeyedTagsAndTagOptions(allPartTags)}
341
343
  compact
342
344
  isInfinite
343
345
  schema={this.schema}
@@ -80,7 +80,7 @@ class OrfProperties extends React.Component {
80
80
  displayName: "Size (aa)",
81
81
  type: "number"
82
82
  },
83
- sizeSchema,
83
+ sizeSchema(this.props.isProtein),
84
84
  { path: "frame", type: "number" },
85
85
  { path: "strand", type: "number" }
86
86
  ]
@@ -2,11 +2,11 @@ import React from "react";
2
2
  import { convertDnaCaretPositionOrRangeToAA } from "@teselagen/sequence-utils";
3
3
  import { convertRangeTo1Based } from "@teselagen/range-utils";
4
4
 
5
- export const sizeSchema = {
5
+ export const sizeSchema = isProtein => ({
6
6
  path: "size",
7
7
  type: "number",
8
- render: (val, _record, i, props) => {
9
- const record = props.isProtein
8
+ render: (val, _record) => {
9
+ const record = isProtein
10
10
  ? convertDnaCaretPositionOrRangeToAA(_record)
11
11
  : _record;
12
12
  const base1Range = convertRangeTo1Based(record);
@@ -14,7 +14,7 @@ export const sizeSchema = {
14
14
 
15
15
  return (
16
16
  <span>
17
- {props.isProtein ? Math.floor(val / 3) : val}{" "}
17
+ {isProtein ? Math.floor(val / 3) : val}{" "}
18
18
  <span style={{ fontSize: 10 }}>
19
19
  {hasJoinedLocations ? (
20
20
  record.locations.map((loc, i) => {
@@ -34,4 +34,4 @@ export const sizeSchema = {
34
34
  </span>
35
35
  );
36
36
  }
37
- };
37
+ });
@@ -17,30 +17,6 @@ import { forEach, camelCase, startCase } from "lodash-es";
17
17
  import { sizeSchema } from "../PropertiesDialog/utils";
18
18
  import { getRangeLength } from "@teselagen/range-utils";
19
19
 
20
- const schema = {
21
- fields: [
22
- // ...(noColor
23
- // ? []
24
- // : [
25
- // {
26
- // path: "color",
27
- // type: "string",
28
- // render: color => {
29
- // return (
30
- // <ColorPickerPopover>
31
- // <div style={{ height: 20, width: 20, background: color }} />
32
- // </ColorPickerPopover>
33
- // );
34
- // }
35
- // }
36
- // ]),
37
- { path: "name", type: "string" },
38
- // ...(noType ? [] : [{ path: "type", type: "string" }]),
39
- sizeSchema,
40
- { path: "strand", type: "string" }
41
- ]
42
- };
43
-
44
20
  class RemoveDuplicatesDialog extends React.Component {
45
21
  state = {
46
22
  dups: []
@@ -89,6 +65,30 @@ class RemoveDuplicatesDialog extends React.Component {
89
65
  const { duplicatesToRemoveSelectedEntities, hideModal, type } = this.props;
90
66
 
91
67
  const selectedIds = this.state.dups.map(d => d.id);
68
+
69
+ const schema = {
70
+ fields: [
71
+ // ...(noColor
72
+ // ? []
73
+ // : [
74
+ // {
75
+ // path: "color",
76
+ // type: "string",
77
+ // render: color => {
78
+ // return (
79
+ // <ColorPickerPopover>
80
+ // <div style={{ height: 20, width: 20, background: color }} />
81
+ // </ColorPickerPopover>
82
+ // );
83
+ // }
84
+ // }
85
+ // ]),
86
+ { path: "name", type: "string" },
87
+ // ...(noType ? [] : [{ path: "type", type: "string" }]),
88
+ sizeSchema(this.props.isProtein),
89
+ { path: "strand", type: "string" }
90
+ ]
91
+ };
92
92
  // const sequenceLength = sequenceData.sequence.length;
93
93
  // const isCirc = (this.state || {}).circular;
94
94
  return (