Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[draft] refactor(core): move /track-def under /src #1110

Open
wants to merge 2 commits into
base: higlassless
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions demo/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import { compile } from '../src/compiler/compile';
import { getTheme } from '../src/core/utils/theme';

import './App.css';
import { createTrackDefs, renderTrackDefs, showTrackInfoPositions } from './track-def/main';
import type { TrackInfo } from 'src/compiler/bounding-box';
import type { GoslingSpec } from 'gosling.js';
import { getLinkedEncodings } from './linking/linkedEncoding';
import { GoslingComponent } from './GoslingComponent';

function App() {
Expand Down
2 changes: 1 addition & 1 deletion demo/GoslingComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import { PixiManager } from '@pixi-manager';
import { compile, type UrlToFetchOptions } from '../src/compiler/compile';
import { getTheme } from '../src/core/utils/theme';
import { createTrackDefs } from './track-def/main';
import { createTrackDefs } from '../src/track-def';
import { renderTrackDefs } from './renderer/main';
import type { TrackInfo } from 'src/compiler/bounding-box';
import type { GoslingSpec } from 'gosling.js';
Expand Down
12 changes: 9 additions & 3 deletions demo/linking/linkedEncoding.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { IsDummyTrack, IsMultipleViews, IsSingleView, type Assembly, type SingleView } from '@gosling-lang/gosling-schema';
import {
IsDummyTrack,
IsMultipleViews,
IsSingleView,
type Assembly,
type SingleView
} from '@gosling-lang/gosling-schema';
import { GenomicPositionHelper, computeChromSizes } from '../../src/core/utils/assembly';
import { signal, type Signal } from '@preact/signals-core';
import type { GoslingSpec } from 'gosling.js';
import { TrackType } from '../track-def/main';
import { isHeatmapTrack } from '../track-def/heatmap';
import { TrackType } from '../../src/track-def';
import { isHeatmapTrack } from '../../src/track-def/heatmap';

/**
* This is the information needed to link tracks together
Expand Down
2 changes: 1 addition & 1 deletion demo/renderer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Signal } from '@preact/signals-core';
import { TextTrack } from '@gosling-lang/text-track';

import { panZoom, panZoomHeatmap } from '@gosling-lang/interactors';
import { type TrackDefs, TrackType } from '../track-def/main';
import { type TrackDefs, TrackType } from '../../src/track-def';
import { getDataFetcher } from './dataFetcher';
import type { LinkedEncoding } from '../linking/linkedEncoding';
import { BrushCircularTrack } from '@gosling-lang/brush-circular';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 11 additions & 2 deletions editor/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ body {
/* Common font styles */
body,
button {
font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
'Cantarell', 'Droid Sans', sans-serif;
font-family:
'Helvetica Neue',
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
'Roboto',
'Oxygen',
'Ubuntu',
'Cantarell',
'Droid Sans',
sans-serif;
font-size: 14px;
text-align: left;
line-height: 1.42857143;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/bounding-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { resolveSuperposedTracks } from '../core/utils/overlay';
import { traverseTracksAndViews, traverseViewArrangements } from './spec-preprocess';
import type { CompleteThemeDeep } from '../core/utils/theme';
import type { ProcessedCircularTrack, ProcessedTrack } from '../../demo/track-def/types';
import type { ProcessedCircularTrack, ProcessedTrack } from '../track-def/types';
export interface Size {
width: number;
height: number;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { convertToFlatTracks } from './spec-preprocess';
import type { SingleView } from '@gosling-lang/gosling-schema';
import { spreadTracksByData } from '../core/utils/overlay';
import { getDataFetcher } from '../../demo/renderer/dataFetcher';
import type { ProcessedTrack } from 'demo/track-def/types';
import type { ProcessedTrack } from '../track-def/types';

// TODO: Move this to dataFetcher.test.ts after we move the /demo/renderer under /src
describe('Compiler with UrlToFetchOptions', () => {
Expand Down
18 changes: 9 additions & 9 deletions src/compiler/views-and-tracks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
import type { CompleteThemeDeep } from '../core/utils/theme';
import { getViewApiData } from '../api/api-data';
import { IsDummyTrack } from '@gosling-lang/gosling-schema';
import type { ProcessedCircularTrack } from 'demo/track-def/types';
import type { ProcessedCircularTrack } from '../track-def/types';

export function collectViewsAndTracks(spec: GoslingSpec, trackInfos: TrackInfo[], theme: Required<CompleteThemeDeep>) {
if (trackInfos.length === 0) {
Expand All @@ -32,14 +32,14 @@ export function collectViewsAndTracks(spec: GoslingSpec, trackInfos: TrackInfo[]
shape: isLinear
? d.boundingBox
: {
...d.boundingBox,
cx: d.boundingBox.x + d.boundingBox.width / 2.0,
cy: d.boundingBox.y + d.boundingBox.height / 2.0,
innerRadius: (d.track as ProcessedCircularTrack).innerRadius!,
outerRadius: (d.track as ProcessedCircularTrack).outerRadius!,
startAngle: (d.track as ProcessedCircularTrack).startAngle!,
endAngle: (d.track as ProcessedCircularTrack).endAngle!
}
...d.boundingBox,
cx: d.boundingBox.x + d.boundingBox.width / 2.0,
cy: d.boundingBox.y + d.boundingBox.height / 2.0,
innerRadius: (d.track as ProcessedCircularTrack).innerRadius!,
outerRadius: (d.track as ProcessedCircularTrack).outerRadius!,
startAngle: (d.track as ProcessedCircularTrack).startAngle!,
endAngle: (d.track as ProcessedCircularTrack).endAngle!
}
};
});

Expand Down
6 changes: 5 additions & 1 deletion src/core/utils/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ export function parseGenomicPosition(position: string): { chromosome: string; st
* A class that consistently manage and convert genomics positions.
*/
export class GenomicPositionHelper {
constructor(public chromosome: string, public start?: number, public end?: number) {}
constructor(
public chromosome: string,
public start?: number,
public end?: number
) {}
static fromString(str: string) {
const result = parseGenomicPosition(str);
return new GenomicPositionHelper(result.chromosome, result.start, result.end);
Expand Down
4 changes: 2 additions & 2 deletions src/core/utils/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ export function spreadTracksByData(tracks: Track[]): Track[] {
IsSingleTrack(track) && IsChannelDeep(track.y) && !track.y.axis && overlayOnPreviousTrack
? ({ ...track.y, axis: i === 1 ? 'right' : 'none' } as ChannelDeep)
: IsSingleTrack(track)
? track.y
: undefined;
? track.y
: undefined;

if (track.title && i !== arr.length - 1 && arr.length !== 1) {
delete track.title; // remove `title` except the last one
Expand Down
4 changes: 2 additions & 2 deletions src/data-fetchers/bam/bam-data-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const DEBOUNCE_TIME = 200;
type InferTileType<Config extends BamData> = Config['extractJunction'] extends true
? Junction
: Config['loadMates'] extends true
? SegmentWithMate
: Segment;
? SegmentWithMate
: Segment;

class BamDataFetcher<Config extends BamData> implements TabularDataFetcher<InferTileType<Config>> {
static config = { type: 'bam' };
Expand Down
5 changes: 4 additions & 1 deletion src/data-fetchers/bed/bed-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ class BedFile {
#customFields?: string[];
#uid: string;

constructor(public tbi: TabixIndexedFile, uid: string) {
constructor(
public tbi: TabixIndexedFile,
uid: string
) {
this.#uid = uid;
}
/**
Expand Down
6 changes: 5 additions & 1 deletion src/data-fetchers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export class DataSource<File, Options> {
chromInfo: ExtendedChromInfo;
tilesetInfo: ReturnType<typeof tilesetInfoFromChromInfo>;

constructor(public file: File, chromSizes: ChromSizes, public options: Options) {
constructor(
public file: File,
chromSizes: ChromSizes,
public options: Options
) {
this.chromInfo = sizesToChromInfo(chromSizes);
this.tilesetInfo = tilesetInfoFromChromInfo(this.chromInfo);
}
Expand Down
5 changes: 4 additions & 1 deletion src/data-fetchers/vcf/vcf-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ type VcfFileOptions = {
class VcfFile {
#parser?: VCF;
#uid: string;
constructor(public tbi: TabixIndexedFile, uid: string) {
constructor(
public tbi: TabixIndexedFile,
uid: string
) {
this.#uid = uid;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion src/gosling-schema/gosling.schema.guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
} from 'd3-scale-chromatic';
import { resolveSuperposedTracks } from '../core/utils/overlay';
import type { TabularDataFetcher } from '@data-fetchers';
import type { ProcessedDummyTrack, ProcessedTrack } from 'demo/track-def/types';
import type { ProcessedDummyTrack, ProcessedTrack } from '../track-def/types';

export const PREDEFINED_COLOR_STR_MAP: { [k: string]: (t: number) => string } = {
viridis: interpolateViridis,
Expand Down
4 changes: 3 additions & 1 deletion src/gosling-schema/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { SingleTrack, ChannelDeep, ChannelTypes, OverlaidTrack, Track } fro
import { IsChannelDeep } from './gosling.schema.guards';
import { resolveSuperposedTracks } from '../core/utils/overlay';
import GoslingSchema from './gosling.schema.json';
import type { ProcessedTrack } from 'src/track-def/types';

export interface Validity {
message: string;
Expand Down Expand Up @@ -37,10 +38,11 @@ export function validateSpec(schema: any, spec: any, silence = false): Validity
return { state: valid ? 'success' : 'warn', message, details };
}

export function validateTrack(track: Track) {
export function validateProcessedTrack(track: ProcessedTrack) {
let valid = true;
const errorMessages: string[] = [];

// @ts-expect-error This function should be re-written
const resolvedTrack = resolveSuperposedTracks(track);

resolvedTrack.forEach(spec => {
Expand Down
Loading
Loading