From 9416a8874add31c339a6f40a99629bde93b4bb9d Mon Sep 17 00:00:00 2001
From: David Sehnal <david.sehnal@gmail.com>
Date: Fri, 3 Nov 2017 23:05:25 +0100
Subject: [PATCH] CIF export tweak

---
 src/mol-data/structure/export/mmcif.ts     | 51 +++++++++++-----------
 src/mol-data/structure/query/properties.ts |  3 +-
 src/perf-tests/structure.ts                |  8 ++--
 3 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/src/mol-data/structure/export/mmcif.ts b/src/mol-data/structure/export/mmcif.ts
index 47e54ac0b..d3fb005b0 100644
--- a/src/mol-data/structure/export/mmcif.ts
+++ b/src/mol-data/structure/export/mmcif.ts
@@ -51,31 +51,32 @@ const entity: Encoder.CategoryDefinition<number, Entity> = {
 const atom_site: Encoder.CategoryDefinition<Atom.Location> = {
     name: 'atom_site',
     fields: [
-        str<Atom.Location>('group_PDB', P.residue.group_PDB),
-        int<Atom.Location>('id', P.atom.id),
-        str<Atom.Location>('type_symbol', P.atom.type_symbol as any),
-        str<Atom.Location>('label_atom_id', P.atom.label_atom_id),
-        str<Atom.Location>('label_alt_id', P.atom.label_alt_id),
-
-        str<Atom.Location>('label_comp_id', P.residue.label_comp_id),
-        int<Atom.Location>('label_seq_id', P.residue.label_seq_id),
-        str<Atom.Location>('pdbx_PDB_ins_code', P.residue.pdbx_PDB_ins_code),
-
-        str<Atom.Location>('label_asym_id', P.chain.label_asym_id),
-        str<Atom.Location>('label_entity_id', P.chain.label_entity_id),
-
-        float<Atom.Location>('Cartn_x', P.atom.x),
-        float<Atom.Location>('Cartn_y', P.atom.y),
-        float<Atom.Location>('Cartn_z', P.atom.z),
-        float<Atom.Location>('occupancy', P.atom.occupancy),
-        str<Atom.Location>('pdbx_formal_charge', P.atom.pdbx_formal_charge),
-
-        str<Atom.Location>('auth_atom_id', P.atom.auth_atom_id),
-        str<Atom.Location>('auth_comp_id', P.residue.auth_comp_id),
-        int<Atom.Location>('auth_seq_id', P.residue.auth_seq_id),
-        str<Atom.Location>('auth_asym_id', P.chain.auth_asym_id),
-
-        str<Atom.Location>('pdbx_operator_name', P.unit.operator_name),
+        str('group_PDB', P.residue.group_PDB),
+        int('id', P.atom.id),
+        str('type_symbol', P.atom.type_symbol as any),
+        str('label_atom_id', P.atom.label_atom_id),
+        str('label_alt_id', P.atom.label_alt_id),
+
+        str('label_comp_id', P.residue.label_comp_id),
+        int('label_seq_id', P.residue.label_seq_id),
+        str('pdbx_PDB_ins_code', P.residue.pdbx_PDB_ins_code),
+
+        str('label_asym_id', P.chain.label_asym_id),
+        str('label_entity_id', P.chain.label_entity_id),
+
+        float('Cartn_x', P.atom.x),
+        float('Cartn_y', P.atom.y),
+        float('Cartn_z', P.atom.z),
+        float('occupancy', P.atom.occupancy),
+        str('pdbx_formal_charge', P.atom.pdbx_formal_charge),
+
+        str('auth_atom_id', P.atom.auth_atom_id),
+        str('auth_comp_id', P.residue.auth_comp_id),
+        int('auth_seq_id', P.residue.auth_seq_id),
+        str('auth_asym_id', P.chain.auth_asym_id),
+
+        int('pdbx_PDB_model_num', P.unit.model_num),
+        str('pdbx_operator_name', P.unit.operator_name)
     ]
 };
 
diff --git a/src/mol-data/structure/query/properties.ts b/src/mol-data/structure/query/properties.ts
index 5b396b4a4..87cfa8cec 100644
--- a/src/mol-data/structure/query/properties.ts
+++ b/src/mol-data/structure/query/properties.ts
@@ -68,7 +68,8 @@ const entity = {
 }
 
 const unit = {
-    operator_name: Atom.property(l => l.unit.operator.name)
+    operator_name: Atom.property(l => l.unit.operator.name),
+    model_num: Atom.property(l => l.unit.model.modelNum)
 }
 
 const Properties = {
diff --git a/src/perf-tests/structure.ts b/src/perf-tests/structure.ts
index d5815068f..613782de8 100644
--- a/src/perf-tests/structure.ts
+++ b/src/perf-tests/structure.ts
@@ -241,9 +241,9 @@ export namespace PropertyAccess {
         //const { structures, models } = await readCIF('e:/test/quick/1jj2_full.bcif');
         //const { structures, models } = await readCIF('e:/test/quick/3j3q_updated.cif');
 
-        console.log(toMmCIFString('test', structures[0]));
+        // console.log(toMmCIFString('test', structures[0]));
 
-        return;
+        // return;
 
         console.log('parsed');
 
@@ -280,7 +280,9 @@ export namespace PropertyAccess {
             chainTest: Q.pred.inSet(P.chain.auth_asym_id, ['A', 'B', 'C', 'D']),
             residueTest: Q.pred.eq(P.residue.auth_comp_id, 'ALA')
         });
-        q(structures[0]);
+        const q0r = q(structures[0]);
+        console.log(toMmCIFString('test', Selection.union(q0r)));
+
         console.time('q1')
         q1(structures[0]);
         console.timeEnd('q1')
-- 
GitLab