UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

29 lines (28 loc) 1.05 kB
import { SimpleFeature, fetchAndMaybeUnzipText } from "../../util/index.js"; import { openLocation } from "../../util/io/index.js"; import { BaseAdapter } from "../BaseAdapter/index.js"; export default class CytobandAdapter extends BaseAdapter { async getData(opts) { const conf = this.getConf('cytobandLocation'); if (conf.uri === '' || conf.uri === '/path/to/cytoband.txt.gz') { return []; } const text = await fetchAndMaybeUnzipText(openLocation(conf, this.pluginManager), opts); return text .split(/\n|\r\n|\r/) .filter(f => !!f.trim()) .filter(f => !f.startsWith('#')) .map((line, i) => { const [refName, start, end, name, type] = line.split('\t'); return new SimpleFeature({ uniqueId: `${i}`, refName: refName, start: +start, end: +end, name, type, gieStain: type || name, }); }); } }