@datagrok/bio 2.4.11 → 2.4.13

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.
@@ -21,6 +21,7 @@ import './tests/similarity-diversity-tests';
21
21
  import './tests/substructure-filters-tests';
22
22
  import './tests/pepsea-tests';
23
23
  import './tests/viewers';
24
+ import './tests/units-handler-tests';
24
25
 
25
26
  // Tests hanging github CI
26
27
  import './tests/activity-cliffs-tests';
package/src/package.ts CHANGED
@@ -655,30 +655,34 @@ export function bioSubstructureFilter(): BioSubstructureFilter {
655
655
  //name: demoBioSimilarityDiversity
656
656
  //meta.demoPath: Bioinformatics | Similarity, Diversity
657
657
  //description:
658
+ //meta.path: /apps/Tutorials/Demo/Bioinformatics/Similarity,%20Diversity
658
659
  export async function demoBioSimilarityDiversity(): Promise<void> {
659
- await demoBio01UI('func/Bio.demoBio01');
660
+ await demoBio01UI();
660
661
  }
661
662
 
662
663
  // demoBio01a
663
664
  //name:demoBioSequenceSpace
664
665
  //meta.demoPath: Bioinformatics | Sequence Space
665
666
  //description:
667
+ //meta.path: /apps/Tutorials/Demo/Bioinformatics/Sequence%20Space
666
668
  export async function demoBioSequenceSpace(): Promise<void> {
667
- await demoBio01aUI('func/Bio.demoBio01a');
669
+ await demoBio01aUI();
668
670
  }
669
671
 
670
672
  // demoBio01b
671
673
  //name: demoBioActivityCliffs
672
674
  //meta.demoPath: Bioinformatics | Activity Cliffs
673
675
  //description:
676
+ //meta.path: /apps/Tutorials/Demo/Bioinformatics/Activity%20Cliffs
674
677
  export async function demoBioActivityCliffs(): Promise<void> {
675
- await demoBio01bUI('func/Bio.demoBio01b');
678
+ await demoBio01bUI();
676
679
  }
677
680
 
678
681
  // demoBio05
679
682
  //name: demoBioHelmMsaSequenceSpace
680
683
  //meta.demoPath: Bioinformatics | Helm, MSA, Sequence Space
681
684
  //description:
685
+ //meta.path: /apps/Tutorials/Demo/Bioinformatics/Helm,%20MSA,%20Sequence%20Space
682
686
  export async function demoBioHelmMsaSequenceSpace(): Promise<void> {
683
- await demoBio05UI('func/demoBio05');
687
+ await demoBio05UI();
684
688
  }
@@ -0,0 +1,97 @@
1
+ import * as grok from 'datagrok-api/grok';
2
+ import * as ui from 'datagrok-api/ui';
3
+ import * as DG from 'datagrok-api/dg';
4
+
5
+ import {after, before, category, test, expect, expectObject} from '@datagrok-libraries/utils/src/test';
6
+ import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
7
+ import {ALPHABET, NOTATION, TAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
8
+
9
+ const seqDna = `seq
10
+ ACGTC
11
+ CAGTGT
12
+ TTCAAC
13
+ `;
14
+
15
+ const seqDnaMsa = `seq
16
+ AC-GT-CT
17
+ CAC-T-GT
18
+ ACCGTACT
19
+ `;
20
+
21
+ const seqUn = `seq
22
+ abc-dfgg-abc1-cfr3-rty-wert
23
+ rut12-her2-rty-wert-abc-abc1-dfgg
24
+ rut12-rty-her2-abc-cfr3-wert-rut12
25
+ `;
26
+
27
+ const seqHelm = `seq
28
+ PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$$
29
+ PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$
30
+ PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$
31
+ PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$
32
+ `;
33
+
34
+ category('UnitsHandler', () =>{
35
+ test('Seq-Fasta', async () =>{
36
+ const [df, uh] = await loadCsvWithDetection(seqDna);
37
+ expect(uh.notation, NOTATION.FASTA);
38
+ expect(uh.isMsa(), false);
39
+ });
40
+
41
+ test('Seq-Fasta-MSA', async () =>{
42
+ const [df, uh] = await loadCsvWithDetection(seqDnaMsa);
43
+ expect(uh.notation, NOTATION.FASTA);
44
+ expect(uh.isMsa(), true);
45
+ });
46
+
47
+ test('Seq-Fasta-units', async () =>{
48
+ const [df, uh] = await loadCsvWithTag(seqDna, DG.TAGS.UNITS, NOTATION.FASTA);
49
+ expect(uh.notation, NOTATION.FASTA);
50
+ expect(uh.isMsa(), false);
51
+ });
52
+
53
+ test('Seq-Fasta-MSA-units', async () =>{
54
+ const [df, uh] = await loadCsvWithTag(seqDnaMsa, DG.TAGS.UNITS, NOTATION.FASTA);
55
+ expect(uh.notation, NOTATION.FASTA);
56
+ expect(uh.isMsa(), true);
57
+ });
58
+
59
+ test('Seq-Helm', async () =>{
60
+ const [df, uh] = await loadCsvWithTag(seqHelm, DG.TAGS.UNITS, NOTATION.HELM);
61
+ expect(uh.notation, NOTATION.HELM);
62
+ expect(uh.isHelm(), true);
63
+ });
64
+
65
+ test('Seq-UN', async () =>{
66
+ const [df, uh] = await loadCsvWithTag(seqUn, DG.TAGS.UNITS, NOTATION.SEPARATOR);
67
+ expect(uh.notation, NOTATION.SEPARATOR);
68
+ expect(uh.separator, '-');
69
+ expect(uh.alphabet, ALPHABET.UN);
70
+ });
71
+
72
+ test('Seq-UN-auto', async () =>{
73
+ const [df, uh] = await loadCsvWithDetection(seqUn);
74
+ expect(uh.notation, NOTATION.SEPARATOR);
75
+ expect(uh.separator, '-');
76
+ expect(uh.alphabet, ALPHABET.UN);
77
+ });
78
+
79
+ async function loadCsvWithDetection(csv: string): Promise<[df: DG.DataFrame, uh: UnitsHandler]> {
80
+ const df = DG.DataFrame.fromCsv(csv);
81
+ await grok.data.detectSemanticTypes(df);
82
+ const uh = new UnitsHandler(df.getCol('seq'));
83
+ return [df, uh];
84
+ }
85
+
86
+ async function loadCsvWithTag(csv: string, tag: string, value: string):
87
+ Promise<[df: DG.DataFrame, uh: UnitsHandler]> {
88
+ const df = DG.DataFrame.fromCsv(csv);
89
+ const col = df.getCol('seq');
90
+ col.setTag(tag, value);
91
+ col.semType = DG.SEMTYPE.MACROMOLECULE;
92
+ if (value === NOTATION.SEPARATOR)
93
+ col.setTag(TAGS.separator, '-');
94
+ const uh = new UnitsHandler(df.getCol('seq'));
95
+ return [df, uh];
96
+ }
97
+ });