diff --git a/js/igv.d.ts b/js/igv.d.ts index 421ba120d..0683219ae 100644 --- a/js/igv.d.ts +++ b/js/igv.d.ts @@ -6,15 +6,18 @@ declare class Opaque { private readonly __opaque_brand: N; } -export type Track = Tracks.TrackCommonOptions & +export type TrackLoad = Tracks.TrackCommonOptions & ((Tracks.AnnotationTrackOptions & Tracks.TypeFormatPair<'annotation', Tracks.AnnotationFormat>) | (Tracks.WigTrackOptions & Tracks.TypeFormatPair<'wig', Tracks.WigFormat>) | (Tracks.WigMergedTrackOptions & { type: 'merged' }) | + (Tracks.AlignmentTrackOptions & Tracks.TypeFormatPair<'alignment', Tracks.AlignmentFormat>) | (Tracks.VariantTrackOptions & Tracks.TypeFormatPair<'variant', Tracks.VariantFormat>) | (Tracks.SegTrackOptions & Tracks.TypeFormatPair<'seg', Tracks.SegTrackFormat>) | (Tracks.CnvPyTorTrackOptions & Tracks.TypeFormatPair<'cnvpytor', Tracks.CnvPyTorFormat>)); export namespace Tracks { + export declare class Track { }; \ + export interface TypeFormatPair { type?: K; format?: F; @@ -283,6 +286,71 @@ export namespace Tracks { colors?: string[]; } + export type AlignmentFormat = "bam" | "cram"; + + type AlignmentBy = (string & {}) // tag:tagName and base:position + + export type AlignmentSortOptions = { + chr: string; + position: number; + direction?: "ASC" | "DESC"; + } & ({ + option: "BASE" | "STRAND" | "INSERT_SIZE" | "MATR_CHR" | "MQ"; + } | { + option: "TAG"; + tag: string; + }); + + export type AlignmentTrackOptions = { + showCoverage?: boolean; + showAlignments?: boolean; + viewAsPairs?: boolean; + pairsSupported?: boolean; + coverageColor?: string; + color?: string; + deletionColor?: string; + displayMode?: "FULL" | "EXPANDED" | "SQUISHED"; + groupBy?: + "strand" | "firstOfPairStrand" | "pairOrientation" | "mateChr" | "chimeric" | "supplementary" | "readOrder" | AlignmentBy; + samplingWindowSize?: number; + samplingDepth?: number; + alignmentRowHeight?: number; + readGroup?: string; + sort: AlignmentSortOptions; + filter: { + vendorFailed?: boolean; + duplicates?: boolean; + secondary?: boolean; + supplementary?: boolean; + mq?: number; + readGroups?: string[]; + }; + showSoftClips?: boolean; + showMismatches?: boolean; + showAllBases?: boolean; + showInsertionText?: boolean; + insertionTextColor?: string; + alignmentRowHeight?: number; + squishedRowHeight?: number; + } & ( + { + colorBy: "strand" | "firstOfPairStrand"; + insertionColor?: string; + negStrandColor?: string; + } | + { + colorBy: "pairOrientation" | "tlen" + | "unexpectedPair" + | "basemod" | "basemod2" + | AlignmentBy; + } + ) + + + export declare class AlignmentTrack extends Track { + setHighlightedReads(readNames: string[], color: string): void; + sort(options: AlignmentSortOptions): void; + }; } type Nucleotide = 'A' | 'C' | 'G' | 'T' | 'N'; @@ -431,7 +499,7 @@ interface CreateOptExtras { * Array of configuration objects defining tracks initially displayed when app launches. * */ - tracks: Track[]; + tracks: TrackLoad[]; } export type CreateOpt = GenomeOpt & CreateOptExtras; @@ -458,11 +526,11 @@ declare class _Browser { loadSessionObject(session: Opaque<'igv.js session JSON'>): void; loadSession(session: string): void; // TODO: check the return type - loadTrack(track: Track): Promise; + loadTrack(track: TrackLoad): Promise; loadSampleInfo({ url: string }): void; findTracks(func: (track: Track) => boolean): Track[]; findTracks(property: string, value: any): Track[]; - removeTRack(track: Track): void; + removeTrack(track: Track): void; removeTrackByName(trackName: string): void; loadROI(roi: DefineROI | DefineROI[]): void; clearROIs(): void;