Skip to content

Commit

Permalink
Alignment track and fixes on track class
Browse files Browse the repository at this point in the history
Signed-off-by: eternal-flame-AD <[email protected]>
  • Loading branch information
eternal-flame-AD committed Aug 12, 2024
1 parent a7b0699 commit 3629e90
Showing 1 changed file with 72 additions and 4 deletions.
76 changes: 72 additions & 4 deletions js/igv.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ declare class Opaque<N extends string> {
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<K extends string, F extends string> {
type?: K;
format?: F;
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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<any>;
loadTrack(track: TrackLoad): Promise<any>;
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;
Expand Down

0 comments on commit 3629e90

Please sign in to comment.