UNPKG

generic-sequence-panel

Version:

read feature and sequence data and produce highlighted fasta

36 lines (35 loc) 1.42 kB
import { RemoteFile } from "generic-filehandle2"; import NCList from "@gmod/nclist"; // Create transcriptList function this function is called by the SeqPanel // component when it needs to fetch a list of transcripts for a given gene it // should return an array of transcript names (see @gmod/nclist for more info) // // it is called with five arguments: // - nclistbaseurl: the base URL of the NCList file // - urltemplate: the URL template for the NCList file // - refseq: the reference sequence (name, like "chr1") // - start: the start of the range (in interbase coordinates) // - end: the end of the range (in interbase coordinates) // - gene: the name of the gene export default async function fetchTranscripts({ nclistbaseurl, urltemplate, refseq, start, end, gene, }) { var _a; if (refseq == "NC_045512.2") { throw new Error("Unfortunately, Sequence Details doesn't yet support fetching viral sequences; sorry."); } const store = new NCList({ urlTemplate: urltemplate, baseUrl: nclistbaseurl, readFile: (url) => new RemoteFile(url).readFile(), }); for await (const feature of store.getFeatures({ refName: refseq, start: start, end: end, })) { const f = feature; if (f.get("name") === gene) { return (_a = f.get("subfeatures")) !== null && _a !== void 0 ? _a : []; } } return []; }