molstar
Version:
A comprehensive macromolecular library.
24 lines (23 loc) • 686 B
JavaScript
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { memoize1 } from '../../../mol-util/memoize';
var ChainIdAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function _getChainId(index) {
var n = ChainIdAlphabet.length;
var j = index;
var k = 0;
var chainId = ChainIdAlphabet[j % n];
while (j >= n) {
j = Math.floor(j / n);
chainId += ChainIdAlphabet[j % n];
k += 1;
}
if (k >= 5) {
console.warn('getChainId overflow');
}
return chainId;
}
export var getChainId = memoize1(_getChainId);