molstar
Version:
A comprehensive macromolecular library.
36 lines (35 loc) • 1.48 kB
JavaScript
/**
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { StructureSequence } from '../../../mol-model/structure/model/properties/sequence';
import { Column } from '../../../mol-data/db';
import { Sequence } from '../../../mol-model/sequence';
export function getSequence(data, entities, atomicHierarchy, coarseHierarchy) {
if (!data.entity_poly_seq || !data.entity_poly_seq._rowCount) {
return StructureSequence.fromHierarchy(entities, atomicHierarchy, coarseHierarchy);
}
var _a = data.entity_poly_seq, entity_id = _a.entity_id, num = _a.num, mon_id = _a.mon_id;
var byEntityKey = {};
var sequences = [];
var count = entity_id.rowCount;
var i = 0;
while (i < count) {
var start = i;
while (i < count - 1 && entity_id.areValuesEqual(i, i + 1))
i++;
i++;
var id = entity_id.value(start);
var compId = Column.window(mon_id, start, i);
var seqId = Column.window(num, start, i);
var entityKey = entities.getEntityIndex(id);
byEntityKey[entityKey] = {
entityId: id,
sequence: Sequence.ofResidueNames(compId, seqId)
};
sequences.push(byEntityKey[entityKey]);
}
return { byEntityKey: byEntityKey, sequences: sequences };
}