Read and write UCSC track and assembly hub files in Node or the browser.
npm install @gmod/ucsc-hubSee the UCSC track hub documentation for the hub.txt, genomes.txt, and trackDb.txt file formats.
import {
HubFile,
GenomesFile,
TrackDbFile,
SingleFileHub,
} from '@gmod/ucsc-hub'
const hub = new HubFile(hubText)
console.log(hub.data.shortLabel)
const genomes = new GenomesFile(genomesText)
console.log(genomes.data['hg38'].data.trackDb)
const trackDb = new TrackDbFile(trackDbText)
console.log(trackDb.settings('myTrack'))
const singleHub = new SingleFileHub(hubText)
console.log(singleHub.hubData, singleHub.genome, singleHub.tracks)Extends RaFile
Class representing a genomes.txt file.
- Throws Error Throws if the first line of the genomes.txt file doesn't start with "genome <genome_name>" or if it has invalid entries
Extends RaStanza
Class representing a hub.txt file.
- Throws Error Throws if the first line of the hub.txt file doesn't start with "hub <hub_name>", if it has invalid entries, or is missing required entries
Class representing an ra file. Each file is composed of multiple stanzas, and
each stanza is separated by one or more blank lines. Each stanza is stored in a
Map with the key being the value of the first key-value pair in the stanza. The
usual Map methods can be used on the file. An additional method add() is
available to take a raw line of text and break it up into a key and value and
add them to the class. This should be favored over set() when possible, as it
performs more validity checks than using set().
raFile(string | Array<string>) An ra file, either as a single string or an array of strings with one stanza per entry. Supports both LF and CRLF line terminators. (optional, default[])optionsobjectoptions.checkIndentboolean [true] - Check if a the stanzas within the file are indented consistently and keep track of the indentation
nameKey(undefined | string) The key of the first line of all the stanzas (undefinedif the stanza has no lines yet).
- Throws Error Throws if an empty stanza is added, if the key in the first key-value pair of each stanza isn't the same, or if two stanzas have the same value for the key-value pair in their first lines.
Class representing an ra file stanza. Each stanza line is split into its key and value and stored as a Map, so the usual Map methods can be used on the stanza.
stanza(string | Array<string>) (optional, default[])options{checkIndent: boolean?, skipValidation: boolean?}?
Class representing a "single-file" hub.txt file that contains all the sections of a hub in a single file.
hubTextstring
Extends RaFile
Class representing a trackDb.txt file.
trackDbFile(string | Array<string>) A trackDb.txt file as a string (optional, default[])optionsany?
- Throws Error Throws if "track" is not the first key in each track or if a track is missing required keys
Gets all track entries including those of parent tracks, with closer entries overriding more distant ones
trackNamestring The name of a track
- Throws Error Throws if track name does not exist in the trackDb
MIT © Generic Model Organism Database Project
Trusted publishing via GitHub Actions.
npm version patch # or minor/major