|
@@ -10,8 +10,9 @@ require('util.promisify').shim();
|
|
|
|
|
|
// import { Table } from 'mol-data/db'
|
|
|
import CIF from 'mol-io/reader/cif'
|
|
|
-import { Model } from 'mol-model/structure'
|
|
|
+import { Model, Structure, ElementSet, Unit } from 'mol-model/structure'
|
|
|
import { Run, Progress } from 'mol-task'
|
|
|
+import { OrderedSet } from 'mol-data/int';
|
|
|
|
|
|
async function parseCif(data: string|Uint8Array) {
|
|
|
const comp = CIF.parse(data);
|
|
@@ -37,24 +38,34 @@ export function atomLabel(model: Model, aI: number) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-function printBonds(model: Model) {
|
|
|
- // TODO: do bonds again
|
|
|
- // const { count, offset, neighbor } = Model.bonds(model)
|
|
|
- // for (let i = 0; i < count; ++i) {
|
|
|
- // const start = offset[i];
|
|
|
- // const end = offset[i + 1];
|
|
|
- // for (let bI = start; bI < end; bI++) {
|
|
|
- // console.log(`${atomLabel(model, i)} -- ${atomLabel(model, neighbor[bI])}`)
|
|
|
- // }
|
|
|
- // }
|
|
|
+function printBonds(structure: Structure) {
|
|
|
+
|
|
|
+ const { units, elements } = structure;
|
|
|
+ const unitIds = ElementSet.unitIndices(elements);
|
|
|
+
|
|
|
+ for (let i = 0, _i = OrderedSet.size(unitIds); i < _i; i++) {
|
|
|
+ const unit = units[OrderedSet.getAt(unitIds, i)];
|
|
|
+ const group = ElementSet.groupFromUnitIndex(elements, OrderedSet.getAt(unitIds, i));
|
|
|
+
|
|
|
+ const { count, offset, neighbor } = Unit.getGroupBonds(unit, group);
|
|
|
+ const { model } = unit;
|
|
|
+
|
|
|
+ for (let j = 0; j < count; ++j) {
|
|
|
+ const start = offset[j];
|
|
|
+ const end = offset[j + 1];
|
|
|
+ for (let bI = start; bI < end; bI++) {
|
|
|
+ console.log(`${atomLabel(model, j)} -- ${atomLabel(model, neighbor[bI])}`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async function run(pdb: string) {
|
|
|
const mmcif = await getPdb(pdb)
|
|
|
const models = Model.create({ kind: 'mmCIF', data: mmcif });
|
|
|
- // const structure = Structure.ofModel(models[0])
|
|
|
+ const structure = Structure.ofModel(models[0])
|
|
|
// console.log(structure)
|
|
|
- printBonds(models[0])
|
|
|
+ printBonds(structure)
|
|
|
}
|
|
|
|
|
|
const parser = new argparse.ArgumentParser({
|