@teselagen/ove 0.5.31-beta.3 → 0.5.32-beta.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, type }) => (
10
+ const renderTypes = ({ readOnly }) => (
11
11
  <ReactSelectField
12
12
  inlineLabel
13
13
  tooltipError
14
14
  disabled={readOnly}
15
- defaultValue={type ?? "misc_feature"}
16
- options={getFeatureTypes().map(featureType => {
15
+ defaultValue="misc_feature"
16
+ options={getFeatureTypes().map(type => {
17
17
  return {
18
18
  label: (
19
19
  <div
@@ -25,18 +25,16 @@ const RenderTypes = ({ readOnly, type }) => (
25
25
  >
26
26
  <div
27
27
  style={{
28
- background: getFeatureToColorMap({ includeHidden: true })[
29
- featureType
30
- ],
28
+ background: getFeatureToColorMap({ includeHidden: true })[type],
31
29
  height: 15,
32
30
  width: 15,
33
31
  marginRight: 5
34
32
  }}
35
33
  />
36
- {featureType}
34
+ {type}
37
35
  </div>
38
36
  ),
39
- value: featureType
37
+ value: type
40
38
  };
41
39
  })}
42
40
  name="type"
@@ -54,7 +52,7 @@ export default AddOrEditAnnotationDialog({
54
52
  upsertAnnotation: props.upsertFeature,
55
53
  // renderLocations: true, //tnw enable this eventually for proteins
56
54
  renderLocations: !props.sequenceData.isProtein,
57
- RenderTypes,
55
+ renderTypes: renderTypes({ readOnly: props.readOnly }),
58
56
  annotationTypePlural: "features"
59
57
  })
60
58
  });
@@ -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, type }) => (
12
+ const renderTypes = ({ readOnly }) => (
13
13
  <ReactSelectField
14
14
  inlineLabel
15
15
  tooltipError
16
16
  disabled={readOnly}
17
- defaultValue={type ?? "misc_feature"}
17
+ defaultValue="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,
91
+ renderTypes: renderTypes({ readOnly: props.readOnly }),
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,
36
37
  forward
37
38
  }) {
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={useLinkedOligo ?? true}
197
+ defaultValue={true}
198
198
  disabled={readOnly}
199
199
  ></CheckboxField>
200
200
  {useLinkedOligo && (
@@ -221,7 +221,11 @@ const RenderBases = props => {
221
221
  sequenceLength={sequenceLength}
222
222
  disabled={readOnly}
223
223
  {...props}
224
- defaultValue={bases ?? defaultValue}
224
+ {...(defaultValue
225
+ ? {
226
+ defaultValue
227
+ }
228
+ : {})}
225
229
  name="bases"
226
230
  label={
227
231
  <div className="tg-bases-label">
@@ -44,58 +44,15 @@ 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
-
90
47
  this.schema = {
91
48
  fields: [
92
49
  {
93
50
  path: "name",
94
51
  type: "string",
95
52
 
96
- render: (name, ann) => {
53
+ render: (name, ann, row, props) => {
97
54
  const checked =
98
- !this.props.annotationVisibility[
55
+ !props.annotationVisibility[
99
56
  `${annotationType}IndividualToHide`
100
57
  ][ann.id];
101
58
 
@@ -107,9 +64,9 @@ const genericAnnotationProperties = ({
107
64
  e.stopPropagation();
108
65
  const upperType = startCase(annotationType);
109
66
  if (checked) {
110
- this.props[`hide${upperType}Individual`]([ann.id]);
67
+ props[`hide${upperType}Individual`]([ann.id]);
111
68
  } else {
112
- this.props[`show${upperType}Individual`]([ann.id]);
69
+ props[`show${upperType}Individual`]([ann.id]);
113
70
  }
114
71
  }}
115
72
  style={{
@@ -132,10 +89,10 @@ const genericAnnotationProperties = ({
132
89
  {
133
90
  path: "bases",
134
91
  type: "string",
135
- render: (bases, primer) => {
92
+ render: (bases, primer, row, props) => {
136
93
  let bps = bases;
137
94
  if (!bases) {
138
- bps = getSequenceWithinRange(primer, this.props.sequence);
95
+ bps = getSequenceWithinRange(primer, props.sequence);
139
96
  if (!primer.forward) {
140
97
  bps = getReverseComplementSequenceString(bps);
141
98
  }
@@ -164,13 +121,13 @@ const genericAnnotationProperties = ({
164
121
  }
165
122
  }
166
123
  ]),
167
- sizeSchema(this.props.isProtein),
124
+ sizeSchema,
168
125
  ...(withTags && this.props.allPartTags
169
126
  ? [
170
127
  {
171
128
  path: "tags",
172
129
  type: "string",
173
- getValueToFilterOn: o => {
130
+ getValueToFilterOn: (o, { keyedPartTags }) => {
174
131
  const toRet = (o.tags || [])
175
132
  .map(tagId => {
176
133
  const tag = keyedPartTags[tagId];
@@ -180,7 +137,7 @@ const genericAnnotationProperties = ({
180
137
  .join(" ");
181
138
  return toRet;
182
139
  },
183
- render: tags => {
140
+ render: (tags, b, c, { keyedPartTags = {} }) => {
184
141
  return (
185
142
  <div style={{ display: "flex" }}>
186
143
  {(tags || []).map((tagId, i) => {
@@ -197,6 +154,46 @@ const genericAnnotationProperties = ({
197
154
  { path: "strand", type: "number" }
198
155
  ]
199
156
  };
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
+ });
200
197
 
201
198
  return (
202
199
  <DataTable
@@ -340,6 +337,7 @@ const genericAnnotationProperties = ({
340
337
  formName="annotationProperties"
341
338
  noRouter
342
339
  isProtein={isProtein}
340
+ keyedPartTags={getKeyedTagsAndTagOptions(allPartTags)}
343
341
  compact
344
342
  isInfinite
345
343
  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(this.props.isProtein),
83
+ sizeSchema,
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 = isProtein => ({
5
+ export const sizeSchema = {
6
6
  path: "size",
7
7
  type: "number",
8
- render: (val, _record) => {
9
- const record = isProtein
8
+ render: (val, _record, i, props) => {
9
+ const record = props.isProtein
10
10
  ? convertDnaCaretPositionOrRangeToAA(_record)
11
11
  : _record;
12
12
  const base1Range = convertRangeTo1Based(record);
@@ -14,7 +14,7 @@ export const sizeSchema = isProtein => ({
14
14
 
15
15
  return (
16
16
  <span>
17
- {isProtein ? Math.floor(val / 3) : val}{" "}
17
+ {props.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 = isProtein => ({
34
34
  </span>
35
35
  );
36
36
  }
37
- });
37
+ };
@@ -17,6 +17,30 @@ 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
+
20
44
  class RemoveDuplicatesDialog extends React.Component {
21
45
  state = {
22
46
  dups: []
@@ -65,30 +89,6 @@ class RemoveDuplicatesDialog extends React.Component {
65
89
  const { duplicatesToRemoveSelectedEntities, hideModal, type } = this.props;
66
90
 
67
91
  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 (