@datagrok/bio 2.25.4 → 2.25.6
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.
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +3 -3
- package/dist/package.js.map +1 -1
- package/package.json +1 -1
- package/scripts/mol-to-helm.py +306 -31
- package/src/package-api.ts +14 -0
- package/src/package.g.ts +17 -1
- package/src/package.ts +58 -18
- package/test-console-output-1.log +341 -330
- package/test-record-1.mp4 +0 -0
package/src/package.ts
CHANGED
|
@@ -74,7 +74,7 @@ import {matchMoleculesWithMonomers, MonomerManager, standardizeMonomerLibrary} f
|
|
|
74
74
|
import {calculateScoresWithEmptyValues} from './utils/calculate-scores';
|
|
75
75
|
import {SeqHelper} from './utils/seq-helper/seq-helper';
|
|
76
76
|
import {_toAtomicLevel} from '@datagrok-libraries/bio/src/monomer-works/to-atomic-level';
|
|
77
|
-
import {molecular3DStructureWidget, toAtomicLevelWidget} from './widgets/to-atomic-level-widget';
|
|
77
|
+
import {molecular3DStructureWidget, toAtomicLevelWidget, toAtomicLevelSingle} from './widgets/to-atomic-level-widget';
|
|
78
78
|
import {handleSequenceHeaderRendering} from './widgets/sequence-scrolling-widget';
|
|
79
79
|
import {PolymerType} from '@datagrok-libraries/js-draw-lite/src/types/org';
|
|
80
80
|
import {BilnNotationProvider} from './utils/biln';
|
|
@@ -642,6 +642,20 @@ export class PackageFunctions {
|
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
+
@grok.decorators.func({name: 'Molecule to HELM Single', description: 'Converts a single molecule to HELM notation without requiring a table or column'})
|
|
646
|
+
static async moleculeToHelmSingle(
|
|
647
|
+
@grok.decorators.param({name: 'molecule', options: {semType: 'Molecule', description: 'Input molecule'}})molecule: string,
|
|
648
|
+
): Promise<string> {
|
|
649
|
+
// create temporary dataframe
|
|
650
|
+
const tempCol = DG.Column.fromStrings('molecule', [molecule]);
|
|
651
|
+
tempCol.semType = DG.SEMTYPE.MOLECULE;
|
|
652
|
+
const tempDF = DG.DataFrame.fromColumns([tempCol]);
|
|
653
|
+
// call converter
|
|
654
|
+
await PackageFunctions.moleculesToHelmTopMenu(tempDF, tempCol);
|
|
655
|
+
// get result
|
|
656
|
+
const result = tempDF.columns.toList().find((c) => c.name.toLowerCase().includes('regenerated sequence'))?.get(0);
|
|
657
|
+
return result ?? '';
|
|
658
|
+
}
|
|
645
659
|
|
|
646
660
|
@grok.decorators.func({
|
|
647
661
|
name: 'To Atomic Level',
|
|
@@ -651,7 +665,7 @@ export class PackageFunctions {
|
|
|
651
665
|
static async toAtomicLevel(
|
|
652
666
|
@grok.decorators.param({options: {description: 'Input data table'}})table: DG.DataFrame,
|
|
653
667
|
@grok.decorators.param({options: {semType: 'Macromolecule', caption: 'Sequence'}})seqCol: DG.Column,
|
|
654
|
-
@grok.decorators.param({options: {initialValue: '
|
|
668
|
+
@grok.decorators.param({options: {initialValue: 'true', caption: 'Non-linear', description: 'Slower mode for cycling/branching HELM structures'}}) nonlinear: boolean = true,
|
|
655
669
|
@grok.decorators.param({options: {initialValue: 'false', caption: 'Highlight monomers', description: 'Highlight monomers\' substructures of the molecule'}}) highlight: boolean = false
|
|
656
670
|
): Promise<void> {
|
|
657
671
|
const pi = DG.TaskBarProgressIndicator.create('Converting to atomic level ...');
|
|
@@ -690,6 +704,47 @@ export class PackageFunctions {
|
|
|
690
704
|
return toAtomicLevelWidget(sequence);
|
|
691
705
|
}
|
|
692
706
|
|
|
707
|
+
@grok.decorators.func({
|
|
708
|
+
name: 'To Atomic Level Single sequence',
|
|
709
|
+
description: 'Converts a single sequence to molblock'
|
|
710
|
+
})
|
|
711
|
+
static async toAtomicLevelSingleSeq(
|
|
712
|
+
@grok.decorators.param({name: 'sequence', type: 'string', options: {semType: 'Macromolecule'}}) sequence: string,
|
|
713
|
+
) : Promise<string> {
|
|
714
|
+
// create temporary column and table
|
|
715
|
+
const isHelm = sequence.includes('$$');
|
|
716
|
+
const isSeparator = sequence.split('').filter((c) => c == '/').length > 2;
|
|
717
|
+
const isBiln = sequence.split('').filter((c) => c == '-').length > 2; // biln is super separator basically :D
|
|
718
|
+
// const isFasta = !isHelm && !isSeparator && !isBiln;
|
|
719
|
+
const tempCol = DG.Column.fromStrings('sequence', [sequence]);
|
|
720
|
+
tempCol.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
721
|
+
tempCol.meta.units = isHelm ? NOTATION.HELM : isSeparator ? NOTATION.SEPARATOR : isBiln ? NOTATION.BILN : NOTATION.FASTA;
|
|
722
|
+
tempCol.setTag(bioTAGS.aligned, 'SEQ');
|
|
723
|
+
if (isSeparator)
|
|
724
|
+
tempCol.setTag(bioTAGS.separator, '/');
|
|
725
|
+
if (isBiln)
|
|
726
|
+
tempCol.setTag(bioTAGS.separator, '-');
|
|
727
|
+
// detect alphabet
|
|
728
|
+
const dnaAlphabet = 'AGCT';
|
|
729
|
+
const RNAAlphabet = 'AGCU';
|
|
730
|
+
const isDNA = sequence.split('').every((c) => dnaAlphabet.includes(c) || c === '/' || c === '-');
|
|
731
|
+
const isRNA = !isDNA && sequence.split('').every((c) => RNAAlphabet.includes(c) || c === '/' || c === '-');
|
|
732
|
+
|
|
733
|
+
tempCol.setTag(bioTAGS.alphabet, isDNA ? ALPHABET.DNA : isRNA ? ALPHABET.RNA : 'UN');
|
|
734
|
+
tempCol.setTag(bioTAGS.alphabetIsMultichar, 'true');
|
|
735
|
+
|
|
736
|
+
const tempDF = DG.DataFrame.fromColumns([tempCol]);
|
|
737
|
+
|
|
738
|
+
// get the sell as semantic value
|
|
739
|
+
const cell = tempDF.cell(0, 'sequence');
|
|
740
|
+
const semValue = DG.SemanticValue.fromTableCell(cell);
|
|
741
|
+
|
|
742
|
+
const res = await toAtomicLevelSingle(semValue);
|
|
743
|
+
if (res.errorText || !res.mol)
|
|
744
|
+
throw new Error(res.errorText);
|
|
745
|
+
return res.mol;
|
|
746
|
+
}
|
|
747
|
+
|
|
693
748
|
@grok.decorators.panel({
|
|
694
749
|
name: 'Molecular 3D Structure',
|
|
695
750
|
tags: ['bio', 'widgets']
|
|
@@ -1277,22 +1332,7 @@ export class PackageFunctions {
|
|
|
1277
1332
|
nonlinear: boolean
|
|
1278
1333
|
): Promise<string | undefined> {
|
|
1279
1334
|
if (!(seq.trim())) return '';
|
|
1280
|
-
|
|
1281
|
-
const seqCol = DG.Column.fromList(DG.COLUMN_TYPE.STRING, `helm`, [seq]);
|
|
1282
|
-
const df = DG.DataFrame.fromColumns([seqCol]);
|
|
1283
|
-
const semType = await grok.functions.call('Bio:detectMacromolecule', {col: seqCol});
|
|
1284
|
-
if (semType) seqCol.semType = semType;
|
|
1285
|
-
|
|
1286
|
-
const monomerLib = (await PackageFunctions.getMonomerLibHelper()).getMonomerLib();
|
|
1287
|
-
const seqHelper = _package.seqHelper;
|
|
1288
|
-
const rdKitModule = await getRdKitModule();
|
|
1289
|
-
const res = (await sequenceToMolfile(df, seqCol, nonlinear, false, monomerLib, seqHelper, rdKitModule))?.molCol?.get(0);
|
|
1290
|
-
return res ?? undefined;
|
|
1291
|
-
} catch (err: any) {
|
|
1292
|
-
const [errMsg, errStack] = errInfo(err);
|
|
1293
|
-
_package.logger.error(errMsg, undefined, errStack);
|
|
1294
|
-
throw err;
|
|
1295
|
-
}
|
|
1335
|
+
return PackageFunctions.toAtomicLevelSingleSeq(seq);
|
|
1296
1336
|
}
|
|
1297
1337
|
|
|
1298
1338
|
// //description: Gets similarity to a reference sequence
|