Browse Source

fix residue label; CIF export tweak

David Sehnal 5 years ago
parent
commit
2a0783d005

+ 4 - 1
src/mol-model/structure/export/categories/atom_site.ts

@@ -36,7 +36,10 @@ const atom_site_fields = CifWriter.fields<StructureElement.Location, Structure>(
     .float('Cartn_y', P.atom.y, { digitCount: 3, encoder: E.fixedPoint3 })
     .float('Cartn_z', P.atom.z, { digitCount: 3, encoder: E.fixedPoint3 })
     .float('occupancy', P.atom.occupancy, { digitCount: 2, encoder: E.fixedPoint2 })
-    .int('pdbx_formal_charge', P.atom.pdbx_formal_charge, { encoder: E.deltaRLE })
+    .int('pdbx_formal_charge', P.atom.pdbx_formal_charge, { 
+        encoder: E.deltaRLE,
+        valueKind: (k, d) =>  k.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.valueKind(k.element)
+    })
 
     .str('auth_atom_id', P.atom.auth_atom_id)
     .str('auth_comp_id', P.residue.auth_comp_id)

+ 8 - 0
src/mol-model/structure/structure/element/location.ts

@@ -49,4 +49,12 @@ namespace Location {
         b.unit.conformation.position(b.element, pB);
         return Vec3.distance(pA, pB);
     }
+
+    export function residueIndex(l: Location) {
+        return l.unit.model.atomicHierarchy.residueAtomSegments.index[l.element];
+    }
+
+    export function chainIndex(l: Location) {
+        return l.unit.model.atomicHierarchy.chainAtomSegments.index[l.element];
+    }
 }

+ 3 - 1
src/mol-theme/label.ts

@@ -196,9 +196,11 @@ function _elementLabel(location: StructureElement.Location, granularity: LabelGr
 }
 
 function _atomicElementLabel(location: StructureElement.Location<Unit.Atomic>, granularity: LabelGranularity): string[] {
+    const rI = StructureElement.Location.residueIndex(location);
+
     const label_asym_id = Props.chain.label_asym_id(location)
     const auth_asym_id = Props.chain.auth_asym_id(location)
-    const has_label_seq_id = location.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(location.element) === Column.ValueKind.Present;
+    const has_label_seq_id = location.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(rI) === Column.ValueKind.Present;
     const label_seq_id = Props.residue.label_seq_id(location)
     const auth_seq_id = Props.residue.auth_seq_id(location)
     const ins_code = Props.residue.pdbx_PDB_ins_code(location)