UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

11 lines (10 loc) 391 B
import { stitch } from "../BaseFeatureWidget/util.js"; export function convertCodingSequenceToPeptides({ cds, sequence, codonTable, }) { const phase = cds[0]?.phase ?? 0; const str = stitch(cds, sequence); let protein = phase > 0 ? '&' : ''; for (let i = phase; i < str.length; i += 3) { protein += codonTable[str.slice(i, i + 3)] || '&'; } return protein; }