@gmod/ucsc-hub

中文文档
2.0.13发布于 2026/08/11MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 3.2万

Read and write UCSC track and assembly hub files in node or the browser

原始使用文档
文档目录11 节
  1. Install
  2. Usage
  3. API
  4. GenomesFile
  5. HubFile
  6. RaFile
  7. RaStanza
  8. SingleFileHub
  9. TrackDbFile
  10. License
  11. Publishing

ucsc-hub-js

Read and write UCSC track and assembly hub files in Node or the browser.

NPM version Build Status

Install

npm install @gmod/ucsc-hub

Usage

See 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)

API

Table of Contents

GenomesFile

Extends RaFile

Class representing a genomes.txt file.

Parameters

  • genomesFile (string | Array<string>) A genomes.txt file as a string (optional, default [])
  • 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

HubFile

Extends RaStanza

Class representing a hub.txt file.

Parameters

  • 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

RaFile

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().

Parameters

  • 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 [])
  • options object
    • options.checkIndent boolean [true] - Check if a the stanzas within the file are indented consistently and keep track of the indentation

Properties

  • nameKey (undefined | string) The key of the first line of all the stanzas (undefined if 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.

RaStanza

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.

Parameters

SingleFileHub

Class representing a "single-file" hub.txt file that contains all the sections of a hub in a single file.

Parameters

TrackDbFile

Extends RaFile

Class representing a trackDb.txt file.

Parameters

  • trackDbFile (string | Array<string>) A trackDb.txt file as a string (optional, default [])
  • options any?
  • Throws Error Throws if "track" is not the first key in each track or if a track is missing required keys

settings

Gets all track entries including those of parent tracks, with closer entries overriding more distant ones

Parameters
  • trackName string The name of a track
  • Throws Error Throws if track name does not exist in the trackDb

License

MIT © Generic Model Organism Database Project

Publishing

Trusted publishing via GitHub Actions.

pnpm version patch  # or minor/major

版本与发布记录

@gmod/ucsc-hub 共发布 25 个版本,首次发布于 2018/12/29;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.0.13latest2026/08/113 个月前
2.0.122026/07/253 个月前
2.0.112026/06/204 个月前
2.0.102026/06/204 个月前
2.0.92026/05/195 个月前
2.0.72026/05/195 个月前

关于 @gmod/ucsc-hub 的常见问题

@gmod/ucsc-hub 是什么?

Read and write UCSC track and assembly hub files in node or the browser

如何安装 @gmod/ucsc-hub?

在项目目录运行 npm install @gmod/ucsc-hub,或使用 pnpm add / yarn add / bun add。

@gmod/ucsc-hub 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gmod/ucsc-hub 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gmod/ucsc-hub 可以商用吗?

@gmod/ucsc-hub 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gmod/ucsc-hub 的下载量有多少?

根据 npm 官方下载统计,@gmod/ucsc-hub 在 2026/10/17 – 2026/11/15 这 30 天内被下载 32,496 次,日均约 1,083 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gmod/ucsc-hub 还在维护吗?

最新版本 2.0.13 发布于 2026/08/11(3 个月前);至今共发布 25 个版本,其中过去 12 个月发布了 9 个;首次发布于 2018/12/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。