بنقرة واحدة
add-curve-format
Add support for a new curve data format in the Curves package converter system
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Add support for a new curve data format in the Curves package converter system
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use whenever you need the Datagrok browser to actually execute JavaScript — adding viewers, filtering, modifying the view, or returning a result widget to the chat. Open this skill before calling the datagrok_exec tool.
Filter rows of a Datagrok DataFrame inside a datagrok-exec block through the Filters panel — by range, equals/contains/in-set, multi-value, boolean, free-text row expressions, or substructure (SMILES / SMARTS / molblock). Also covers clearing, inverting, the show-only-filtered vs destructive-drop split, and the filter event lifecycle (onRowsFiltering / onFilterChanged / onRowsFiltered). Use whenever the user says "filter", "show only", "hide rows where", "narrow to subset", "find rows that", "contains", "substructure search", "categorical filter", "range filter", "invert", "clear the filter", "clear filters", "drop rows", or asks for the filtered subset as a new table. Does NOT cover selection (separate skill) or generic DataFrame cloning (datagrok-df-and-columns).
Add a calculated, formula-based column to a dataframe inside a datagrok-exec block. Use whenever the user asks to compute, derive, add, or create a new column from existing columns — LipE, ratios, log/round, heavy atom count, any expression in the Datagrok formula DSL. Replaces hand-written addNewFloat/addNewInt + for-loop with a single formula-attached column that recomputes when source columns change.
Find, describe, add, remove, rename, clone, or set metadata on columns of a Datagrok DataFrame inside a datagrok-exec block. Use whenever the user asks to locate "the X column", summarize a column, add a typed/empty/values-filled/virtual column, set semantic type / units / format / friendly name, apply linear or categorical or conditional color coding, drop or rename columns, or copy a DataFrame. Covers everything in DataFrame.columns and Column.meta — but not row filtering/selection (datagrok-filtering, datagrok-selection) and not formula-only columns (datagrok-calc-column).
Sort, hide, show, reorder, resize, pin, format, and color-code columns in a Datagrok TableView grid from a datagrok-exec block. Use whenever the user asks to sort by a column (any direction), multi-sort, hide / show / reorder / pin / resize columns, freeze the first N columns, change number-format display, color-code cells (defaults and grid-only tint here; full per-type reference in datagrok-df-and-columns), set row height, or reset the grid back to defaults. Distinct from datagrok-df-and-columns (which owns column-level data metadata like semType, units, friendlyName, and is also where canonical color-coding lives) and from datagrok-viewers (which owns scatter plot / histogram / etc.). Does NOT cover filtering (`datagrok-filtering`), selection (`datagrok-selection`), custom cell renderer authoring (`create-cell-renderer`), saving / restoring layouts, or grid event handlers.
Add a viewer, configure a viewer, change viewer options, find viewer, close viewer, view a scatter plot, bar chart, histogram, line chart, box plot, pie chart, heat map, correlation plot, 3D scatter, trellis, density plot, statistics, on a Datagrok TableView inside a datagrok-exec block. Use whenever the user asks to plot, chart, visualize, show a graph, draw a distribution, color by a column, swap a viewer's axis, toggle a legend / regression line / log scale, replace one viewer with another, close every chart, reset the view to just the grid, or find an existing viewer by type. Plugin viewers like "Chem space", "sequence space", "activity cliffs" are NOT viewer types — they're registered functions — route those to `grok.functions.call`. Does NOT cover filtering (separate skill `datagrok-filtering`), selection (`datagrok-selection`), grid cell rendering (`datagrok-grid-customization`), layout save/restore, or custom-viewer authoring.
| name | add-curve-format |
| description | Add support for a new curve data format in the Curves package converter system |
| when-to-use | When user asks to add a new curve format, integrate curve data, or extend the Curves converter |
| effort | medium |
Help the user add support for a new curve data format to Datagrok. The Curves package (packages/Curves) uses a converter architecture where any package can provide support for a new curve notation. When the Curves package initializes, it discovers all converter functions tagged with meta.role: curveConverter and meta.curveFormat: '<name>' across all loaded packages and registers them automatically.
/add-curve-format [format-name]
The native format is IFitChartData JSON (defined in @datagrok-libraries/statistics/src/fit/fit-curve.ts):
interface IFitChartData {
chartOptions?: IFitChartOptions; // axes bounds, log scale, title, axis names
seriesOptions?: IFitSeriesOptions; // default series options
series?: IFitSeries[]; // array of data series with points
}
Each IFitSeries has points: IFitPoint[] where each point has x, y, and optional outlier, plus fit configuration like fitFunction, parameters, showFitLine, etc.
detectors.js) identifies a column's format and sets:
col.semType = 'fit'col.setTag('.%curve-format', '<format-name>') — a friendly format name (e.g. 'my-format')meta.role: curveConverter and meta.curveFormat: '<format-name>') returns a sync converter function: () => (value: string) => stringDG.Func.find({meta: {role: 'curveConverter'}}) at init time, reads each function's meta.curveFormat value, and registers the converter under that format nameformatName||cellValueparseCellValue() which handles conversion transparentlyYour package only needs @datagrok-libraries/statistics (for types like IFitChartData and FitConstants) and datagrok-api. The Curves package discovers your converter automatically at runtime.
Create a converter file in your package, e.g. src/<format-name>-converter.ts:
import {
IFitChartData,
IFitPoint,
IFitSeries,
} from '@datagrok-libraries/statistics/src/fit/fit-curve';
/** Converts <format-name> format to native IFitChartData JSON string. */
export function convert<FormatName>ToJson(value: string): string {
// 1. Parse the input format (JSON.parse, DOMParser, etc.)
// 2. Extract points, series options, chart options
// 3. Build IFitChartData object
// 4. Return JSON.stringify(chartData)
const parsed = JSON.parse(value); // or XML parse, etc.
const points: IFitPoint[] = []; // Map input data to {x, y, outlier?}
// ... populate points from parsed data
const series: IFitSeries = {
points: points,
fitFunction: 'sigmoid', // or '4pl-dose-response', 'linear', etc.
showFitLine: true,
showPoints: 'points',
clickToToggle: true,
};
// If the format includes pre-fit parameters, set them:
// series.parameters = [max, slope, IC50, min];
const chartData: IFitChartData = {
chartOptions: {
xAxisName: 'Concentration',
yAxisName: 'Response',
logX: true, // typical for dose-response
},
series: [series],
};
return JSON.stringify(chartData);
}
Key requirements for the converter function:
(value: string) => string — takes raw cell value, returns native JSON stringIn your package's src/package.ts, expose a DG function tagged with meta.role: curveConverter and meta.curveFormat: '<format-name>'. This function returns the sync converter function (it does not perform the conversion itself):
import {convert<FormatName>ToJson} from './<format-name>-converter';
export class PackageFunctions {
@grok.decorators.func({
description: 'Returns <format-name> curve converter function',
meta: {role: 'curveConverter', curveFormat: '<format-name>'}
})
static convert<FormatName>ToJsonFunc(): (value: string) => string {
return convert<FormatName>ToJson;
}
}
The meta.curveFormat value must match exactly the format name set in the detector tag.
Add a semantic type detector in your package's detectors.js:
const FIT_SEM_TYPE = 'fit';
const TAG_CURVE_FORMAT = '.%curve-format';
class <YourPackage>PackageDetectors extends DG.Package {
//meta.role: semTypeDetector
//input: column col
//output: string semType
detect<FormatName>(col) {
if (DG.Detector.sampleCategories(col, (s) => {
// Return true if the string looks like this format
// Use fast checks: string includes, startsWith, etc.
// For JSON: try { const o = JSON.parse(s); return hasExpectedFields; } catch { return false; }
return false;
}, 1)) {
col.setTag(TAG_CURVE_FORMAT, '<format-name>');
col.semType = FIT_SEM_TYPE;
return col.semType;
}
return null;
}
}
Detection tips:
DG.Detector.sampleCategories(col, predicate, minCount) to check sample valuessetTag must match meta.curveFormat on the converter function exactlyAdd tests to your package's test files:
import {convert<FormatName>ToJson} from '../<format-name>-converter';
import {IFitChartData} from '@datagrok-libraries/statistics/src/fit/fit-curve';
import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
// Sample data in the new format
const SAMPLE_DATA = '...';
category('curve converter', () => {
test('basicConversion', async () => {
const result = convert<FormatName>ToJson(SAMPLE_DATA);
const chartData: IFitChartData = JSON.parse(result);
expect(chartData.series !== undefined && chartData.series.length > 0, true);
expect(chartData.series![0].points.length > 0, true);
// Verify specific point values, chart options, etc.
});
test('detection', async () => {
const df = DG.DataFrame.fromColumns([DG.Column.fromStrings('col', [SAMPLE_DATA])]);
const col = df.columns.byName('col');
await grok.data.detectSemanticTypes(df);
expect(col.semType, FitConstants.FIT_SEM_TYPE);
expect(col.getTag(FitConstants.TAG_CURVE_FORMAT), '<format-name>');
});
});
cd <YourPackage>
npm run build
grok test --host <host alias in config>
Once both your package and the Curves package are published to the same server, the Curves package will automatically discover and use your converter.
For working examples, see these files in packages/Curves/:
| Format | Format Name | Converter | Detector |
|---|---|---|---|
XML 3DX (<chart>...</chart>) | 3dx | src/fit/converters/xml-converter.ts | detectXMLCurveChart |
Compact dose-response JSON ({p, poi, mxr, ...}) | compact-dr | src/fit/converters/compact-dr-converter.ts | detectCompactDoseResponse |
| PZFX (GraphPad Prism XY) | pzfx | src/fit/converters/pzfx-converter.ts | detectPzfxCurveChart |
Note: the Curves package registers its own converters directly (hardcoded) to avoid circular dependencies. External packages rely on auto-discovery via meta.curveFormat.
From @datagrok-libraries/statistics/src/fit/fit-curve.ts:
interface IFitPoint {
x: number;
y: number;
outlier?: boolean;
color?: string;
marker?: FitMarkerType;
size?: number;
stdev?: number;
}
interface IFitSeries {
points: IFitPoint[];
name?: string;
fitFunction?: string; // 'sigmoid', '4pl-dose-response', 'linear', etc.
parameters?: number[]; // [max, slope, IC50, min] for sigmoid/4PL
showFitLine?: boolean;
showPoints?: string; // 'points' to show
clickToToggle?: boolean; // allow outlier toggling
pointColor?: string;
fitLineColor?: string;
droplines?: string[]; // e.g. ['IC50']
// ... more options available
}
interface IFitChartOptions {
minX?: number; minY?: number;
maxX?: number; maxY?: number;
xAxisName?: string;
yAxisName?: string;
logX?: boolean;
logY?: boolean;
title?: string;
// ... more options available
}
From @datagrok-libraries/statistics/src/fit/const.ts:
FitConstants.TAG_CURVE_FORMAT = '.%curve-format' — the column tag to setFitConstants.FIT_SEM_TYPE = 'fit' — the semantic type to assignAvailable fit functions: 'sigmoid', '4pl-dose-response', '4pl-regression', 'linear', 'log-linear', 'exponential', or custom via IFitFunctionDescription.