Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@datagrok/bio

Package Overview
Dependencies
Maintainers
5
Versions
281
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datagrok/bio - npm Package Compare versions

Comparing version 2.11.37 to 2.11.38

files/samples/FASTA_DNA.csv

5

.eslintrc.json

@@ -18,3 +18,3 @@ {

"rules": {
"indent": ["error", 2, {"SwitchCase": 1}],
"indent": ["error", 2, {"SwitchCase": 0}],
"max-len": ["error", 120],

@@ -29,4 +29,3 @@ "no-unused-vars": "off",

"error",
"multi-or-nest",
"consistent"
"multi-or-nest"
],

@@ -33,0 +32,0 @@ "brace-style": [

# Bio changelog
## 2.11.38 (2024-03-08)
### Bug fixes
* GROK-14910: PepSeA verbose output
* MSA ensures docker container for PepSeA
* Sample files harmonized
## 2.11.37 (2024-03-08)

@@ -4,0 +12,0 @@

4

package.json

@@ -8,3 +8,3 @@ {

},
"version": "2.11.37",
"version": "2.11.38",
"description": "Bioinformatics support (import/export of sequences, conversion, visualization, analysis). [See more](https://github.com/datagrok-ai/public/blob/master/packages/Bio/README.md) for details.",

@@ -38,3 +38,3 @@ "repository": {

"@biowasm/aioli": "^3.1.0",
"@datagrok-libraries/bio": "5.39.26",
"@datagrok-libraries/bio": "5.39.29",
"@datagrok-libraries/chem-meta": "^1.2.1",

@@ -41,0 +41,0 @@ "@datagrok-libraries/ml": "^6.4.10",

@@ -11,3 +11,3 @@ import * as grok from 'datagrok-api/grok';

const dataFn: string = 'data/sample_FASTA_PT_activity.csv';
const dataFn: string = 'samples/FASTA_PT_activity.csv';

@@ -14,0 +14,0 @@ export async function demoBio01UI() {

@@ -12,3 +12,3 @@ import * as grok from 'datagrok-api/grok';

const dataFn = 'data/sample_FASTA_PT_activity.csv';
const dataFn = 'samples/FASTA_PT_activity.csv';
const seqColName = 'sequence';

@@ -15,0 +15,0 @@

@@ -17,3 +17,3 @@ import * as grok from 'datagrok-api/grok';

const dataFn: string = 'data/sample_FASTA_PT_activity.csv';
const dataFn: string = 'samples/FASTA_PT_activity.csv';

@@ -20,0 +20,0 @@ export async function demoBio01bUI() {

@@ -915,3 +915,3 @@ /* Do not change these import lines to match external modules in webpack configuration */

const app = new WebLogoApp(urlParams, 'webLogoAggApp');
const df: DG.DataFrame = await _package.files.readCsv('data/sample_FASTA_PT_activity.csv');
const df: DG.DataFrame = await _package.files.readCsv('samples/FASTA_PT_activity.csv');
await grok.data.detectSemanticTypes(df);

@@ -941,3 +941,3 @@ await app.init(df);

const urlParams = new URLSearchParams(window.location.search);
const df = await _package.files.readCsv('data/sample_HELM_empty_vals.csv');
const df = await _package.files.readCsv('samples/HELM_empty_vals.csv');
const app = new GetRegionApp(urlParams, 'getRegionHelmApp');

@@ -944,0 +944,0 @@ await app.init({df: df, colName: 'HELM'});

@@ -75,3 +75,3 @@ import * as grok from 'datagrok-api/grok';

test('Helm', async () => {
const df = await _package.files.readCsv('data/sample_HELM_50.csv');
const df = await _package.files.readCsv('samples/HELM_50.csv');
const _view = grok.shell.addTableView(df);

@@ -78,0 +78,0 @@

@@ -158,4 +158,4 @@ import * as grok from 'datagrok-api/grok';

const samples: { [key: string]: string } = {
[Samples.fastaFasta]: 'System:AppData/Bio/data/sample_FASTA.fasta',
[Samples.fastaPtCsv]: 'System:AppData/Bio/data/sample_FASTA_PT.csv',
[Samples.fastaFasta]: 'System:AppData/Bio/samples/FASTA.fasta',
[Samples.fastaPtCsv]: 'System:AppData/Bio/samples/FASTA_PT.csv',
[Samples.msaComplex]: 'System:AppData/Bio/samples/MSA.csv',

@@ -162,0 +162,0 @@ [Samples.fastaCsv]: 'System:AppData/Bio/samples/FASTA.csv',

@@ -9,3 +9,3 @@ import * as grok from 'datagrok-api/grok';

import {multipleSequenceAlignmentUI} from '../utils/multiple-sequence-alignment-ui';
import {awaitContainerStart} from './utils';
import {awaitContainerStart} from '../utils/docker';

@@ -12,0 +12,0 @@ category('MSA', async () => {

import * as DG from 'datagrok-api/dg';
import {before, category, expect, test} from '@datagrok-libraries/utils/src/test';
import {before, category, expect, expectArray, test} from '@datagrok-libraries/utils/src/test';
import {runPepsea} from '../utils/pepsea';
import {awaitContainerStart} from './utils';
import {TestLogger} from './utils/test-logger';
import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
import {awaitContainerStart} from '../utils/docker';
category('PepSeA', () => {
const testCsv = `HELM,MSA
"PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"
"PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"
"PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"
"PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"
"PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"`;
"PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"
"PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"
"PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"
"PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"
"PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"
`;
const pepseaStderrCsv: string = `HELM,MSA
"PEPTIDE1{F.L.Mis.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.Mis.G.W.MeF.Y..S.N.N.C"
"PEPTIDE1{F.L.Mis.G.Y.[MeF].Y.W.N.C}$$$$","F.L.Mis.G.Y.MeF.Y...W.N.C"
"PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"
`;
const pepseaStderrWarningList: string = 'Mis not found in Monomer Map\nMeF not found in Monomer Map\n';
const pepseaErrorCsv: string = `HELM
"PEPTIDE1{[NH2].*.A.Q.T.T.Y.K.N.Y.R.R.N.L.L.*.[COOH]}$$$$"
"PEPTIDE1{[NH2].M.A.N.T.T.Y.K.N.Y.R.N.N.L.L.*.[COOH]}$$$$"
"PEPTIDE1{[NH2].*.A.N.T.T.Y.K.C.Y.R.R.N.L.L.*.[COOH]}$$$$"
"PEPTIDE1{[NH2].*.A.N.T.T.Y.K.F.Y.R.R.N.L.L.*.[COOH]}$$$$"
`;
const pepseaErrorError: string = 'PepSeA error: The pair (*,M) couldn\'t be found in the substitution matrix';
before(async () => {

@@ -20,9 +38,31 @@ await awaitContainerStart();

test('Basic alignment', async () => {
const table = DG.DataFrame.fromCsv(testCsv);
const alignedCol = await runPepsea(table.getCol('HELM'), 'msa(HELM)');
expect(alignedCol !== null, true, 'PepSeA container has not started');
const alignedTestCol = table.getCol('MSA');
for (let i = 0; i < alignedCol!.length; ++i)
expect(alignedCol!.get(i) == alignedTestCol.get(i), true);
const df = DG.DataFrame.fromCsv(testCsv);
const resMsaCol = await runPepsea(df.getCol('HELM'), 'msa(HELM)');
const tgtMsaCol = df.getCol('MSA');
for (let i = 0; i < resMsaCol!.length; ++i)
expect(resMsaCol!.get(i) == tgtMsaCol.get(i), true);
}, {timeout: 60000 /* docker */});
test('stderr', async () => {
const logger = new TestLogger();
const df = DG.DataFrame.fromCsv(pepseaStderrCsv);
const resMsaCol = await runPepsea(df.getCol('HELM'), 'msa(HELM)',
undefined, undefined, undefined, undefined, logger);
const tgtMsaCol = df.getCol('MSA');
expectArray(resMsaCol!.toList(), tgtMsaCol.toList());
expect(logger.warningList[0].message, pepseaStderrWarningList);
}, {timeout: 60000 /* docker */});
test('error', async () => {
const logger = new TestLogger();
try {
const df = DG.DataFrame.fromCsv(pepseaErrorCsv);
const _resMsaCol = await runPepsea(df.getCol('HELM'), 'msa(HELM)',
undefined, undefined, undefined, undefined, logger);
} catch (err: any) {
const [errMsg, errStack] = errInfo(err);
logger.error(errMsg, undefined, errStack);
}
expect(logger.errorList[0].message, pepseaErrorError);
});
});

@@ -74,3 +74,3 @@ import * as grok from 'datagrok-api/grok';

async function _rendererMacromoleculeSeparator() {
const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/data/sample_SEPARATOR_PT.csv');
const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/SEPARATOR_PT.csv');
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);

@@ -117,3 +117,3 @@

async function _testAfterMsa() {
const fastaTxt: string = await grok.dapi.files.readAsText('System:AppData/Bio/data/sample_FASTA.fasta');
const fastaTxt: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/FASTA.fasta');
const df: DG.DataFrame = importFasta(fastaTxt)[0];

@@ -158,3 +158,3 @@

async function _testAfterConvert() {
const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/data/sample_FASTA_PT.csv');
const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/FASTA_PT.csv');
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);

@@ -161,0 +161,0 @@

@@ -37,10 +37,2 @@ import * as DG from 'datagrok-api/dg';

/** Waits if container is not started
* @param {number} ms - time to wait in milliseconds */
export async function awaitContainerStart(ms: number = 30000): Promise<void> {
const dc = await grok.dapi.docker.dockerContainers.filter('bio').first();
const dcId = dc.id;
await startDockerContainer(dcId, ms);
}
export async function awaitGrid(grid: DG.Grid, timeout: number = 5000): Promise<void> {

@@ -47,0 +39,0 @@ await delay(0);

@@ -13,3 +13,3 @@ import * as DG from 'datagrok-api/dg';

test(v, async () => {
const df = await readDataframe('data/sample_FASTA_DNA.csv');
const df = await readDataframe('samples/FASTA_DNA.csv');
await testViewer(v, df, {detectSemanticTypes: true});

@@ -16,0 +16,0 @@ }, {

import * as grok from 'datagrok-api/grok';
import * as ui from 'datagrok-api/ui';
import * as DG from 'datagrok-api/dg';
import {delay} from '@datagrok-libraries/utils/src/test';
export async function startDockerContainer(dcId: string, timeout: number = 30000): Promise<void> {
// TODO: Use the new dockerContainers API
const res = await grok.dapi.docker.dockerContainers.run(dcId /*, true */);
import {Pepsea} from './pepsea';
/** Waits if container is not started
* @param {number} ms - time to wait in milliseconds */
export async function awaitContainerStart(ms: number = 60000): Promise<void> {
const dc = await Pepsea.getDockerContainer();
await startDockerContainer(dc, ms);
}
export async function startDockerContainer(argDc: DG.DockerContainer, timeout: number = 60000): Promise<void> {
// argDc contains current container status
let dc: DG.DockerContainer | null = argDc;
let end: boolean = false;
for (let i = 0; i < timeout / 200; ++i) {
const dc = await grok.dapi.docker.dockerContainers.find(dcId);
if (dc === null) dc = await grok.dapi.docker.dockerContainers.find(argDc.id);
if (isStarted(dc)) {
end = true;
break;
}
switch (dc.status) {
case 'stopped': {
await grok.dapi.docker.dockerContainers.run(dcId);
break;
}
case 'pending change':
case 'changing': {
// skip to wait
break;
}
case 'checking':
case 'started': {
end = true;
break;
}
case 'error': {
throw new Error('Docker container error state.');
}
case 'stopped': {
// TODO: Use the new dockerContainers API
await grok.dapi.docker.dockerContainers.run(dc.id);
break;
}
if (end) break;
case 'pending change':
case 'changing': {
// skip to wait
break;
}
case 'error': {
throw new Error('Docker container error state.');
}
}
dc = null;
await delay(200);
}
if (!end) throw new Error('Docker container run timeout.');
if (!end) throw new Error('Docker container start timeout.');
// this.dc = await grok.dapi.docker.dockerContainers.find(dcId);
}
export function isStarted(dc: DG.DockerContainer): boolean {
return dc.status === 'checking' || dc.status === 'started';
}

@@ -14,2 +14,3 @@ import * as grok from 'datagrok-api/grok';

import {kalignVersion, msaDefaultOptions} from './constants';
import {awaitContainerStart} from './docker';

@@ -72,3 +73,3 @@ import {_package} from '../package';

//TODO: remove when the new version of datagrok-api is available
//TODO: allow only macromolecule colums to be chosen
//TODO: allow only macromolecule columns to be chosen
const colInput = ui.columnInput('Sequence', table, seqCol, async () => {

@@ -171,4 +172,7 @@ performAlignment = await onColInputChange(

return async () => await runPepsea(col, unusedName, methodInput.value!,
gapOpenInput.value!, gapExtendInput.value!, clustersColInput.value);
return async () => {
await awaitContainerStart();
return runPepsea(col, unusedName, methodInput.value!,
gapOpenInput.value!, gapExtendInput.value!, clustersColInput.value);
};
} else if (checkInputColumnUI(col, col.name, [NOTATION.SEPARATOR], [ALPHABET.UN], false)) {

@@ -183,4 +187,7 @@ //if the column is separator with unknown alphabet, it might be helm. check if it can be converted to helm

return async () => await runPepsea(helmCol, unusedName, methodInput.value!,
gapOpenInput.value!, gapExtendInput.value!, clustersColInput.value);
return async () => {
await awaitContainerStart();
return runPepsea(helmCol, unusedName, methodInput.value!,
gapOpenInput.value!, gapExtendInput.value!, clustersColInput.value);
};
} else {

@@ -187,0 +194,0 @@ gapOpenInput.value = null;

@@ -9,2 +9,3 @@ /* Do not change these import lines to match external modules in webpack configuration */

import {NOTATION, TAGS as bioTAGS, ALIGNMENT, ALPHABET} from '@datagrok-libraries/bio/src/utils/macromolecule';
import {ILogger} from '@datagrok-libraries/bio/src/utils/logger';

@@ -42,14 +43,12 @@ import * as C from './constants';

* @param {DG.Column} clustersCol - The column containing the clusters of the sequences.
* @param logger {ILogger} Logger
*/
export async function runPepsea(srcCol: DG.Column<string>, unUsedName: string,
method: typeof pepseaMethods[number] = 'ginsi', gapOpen: number = 1.53, gapExtend: number = 0.0,
clustersCol: DG.Column<string | number> | null = null,
): Promise<DG.Column<string> | null> {
clustersCol: DG.Column<string | number> | null = null, logger?: ILogger
): Promise<DG.Column<string>> {
const pepseaContainer = await Pepsea.getDockerContainer();
if (pepseaContainer.status !== 'started' && pepseaContainer.status !== 'checking') {
grok.log.warning('PepSeA container has not started yet');
return null;
}
if (pepseaContainer.status !== 'started' && pepseaContainer.status !== 'checking')
throw new Error('PepSeA container has not started yet');
const peptideCount = srcCol.length;

@@ -77,3 +76,3 @@ clustersCol ??= DG.Column.int('Clusters', peptideCount).init(0);

for (const body of bodies) { // getting aligned sequences for each cluster
const alignedObject = await requestAlignedObjects(pepseaContainer.id, body, method, gapOpen, gapExtend);
const alignedObject = await requestAlignedObjects(pepseaContainer.id, body, method, gapOpen, gapExtend, logger);
const alignments = alignedObject.Alignment;

@@ -100,4 +99,5 @@

async function requestAlignedObjects(dockerfileId: string, body: PepseaBodyUnit[], method: string, gapOpen: number,
gapExtend: number): Promise<PepseaResponse> {
async function requestAlignedObjects(
dockerfileId: string, body: PepseaBodyUnit[], method: string, gapOpen: number, gapExtend: number, logger?: ILogger
): Promise<PepseaResponse> {
const params = {

@@ -109,4 +109,51 @@ method: 'POST',

const path = `/align?method=${method}&gap_open=${gapOpen}&gap_extend=${gapExtend}`;
const response = await grok.dapi.docker.dockerContainers.request(dockerfileId, path, params);
return JSON.parse(response ?? '{}');
let responseObj: any;
if ('fetchProxy' in grok.dapi.docker.dockerContainers) {
// new dockerContainers API
const t1: number = window.performance.now();
// @ts-ignore
const response: Response = await grok.dapi.docker.dockerContainers.fetchProxy(dockerfileId, path, params);
const t2: number = window.performance.now();
_package.logger.debug(`Bio: requestAlignedObjects() dockerContainers.fetchProxy(), ET: ${(t2 - t1)} ms`);
const responseContentType = response.headers.get('content-type');
const isJson: boolean = responseContentType === 'application/json';
if (!response.ok && isJson) {
const responseJson = await response.json();
const pepseaErrorMsg = responseJson['pepsea-error'];
if (!!pepseaErrorMsg)
throw new Error(`PepSeA error: ${pepseaErrorMsg}`);
const datagrokErrorMsg = responseJson['datagrok-error'];
if (!!datagrokErrorMsg)
throw new Error(`Datagrok error: ${datagrokErrorMsg}`);
throw new Error(response.statusText);
} else if (!response.ok && !isJson) {
const responseStr = await response.text();
throw new Error(`Error: ${responseStr}`);
} else if (!isJson) {
const responseStr = await response.text();
throw new Error(`Error: PepSeA expected JSON response, got '${responseStr}'.`);
}
responseObj = await response.json();
} else {
const responseStr = await grok.dapi.docker.dockerContainers.request(dockerfileId, path, params)!;
if (!responseStr)
throw new Error('Empty response');
responseObj = JSON.parse(responseStr);
const pepseaErrorMsg = responseObj['pepsea-error'];
if (!!pepseaErrorMsg)
throw new Error(`PepSeA error: ${pepseaErrorMsg}`);
const datagrokErrorMsg = responseObj['datagrok-error'];
if (!!datagrokErrorMsg)
throw new Error(`Datagrok error: ${datagrokErrorMsg}`);
}
// Check for pepsea stderr output
if ('pepsea-stderr' in responseObj) {
const pepseaStdErr: string = responseObj['pepsea-stderr'] as string;
logger?.warning(pepseaStdErr);
}
return responseObj as PepseaResponse;
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc