Ver Fonte

Merge branch 'master' of https://github.com/molstar/molstar

Alexander Rose há 4 anos atrás
pai
commit
88b9be5fd1

+ 21 - 0
src/mol-model/structure/model/model.ts

@@ -144,6 +144,27 @@ export namespace Model {
 
     //
 
+    export function hasCarbohydrate(model: Model): boolean {
+        return model.properties.saccharideComponentMap.size > 0;
+    }
+
+    export function hasProtein(model: Model): boolean {
+        const { subtype } = model.entities;
+        for (let i = 0, il = subtype.rowCount; i < il; ++i) {
+            if (subtype.value(i).startsWith('polypeptide')) return true;
+        }
+        return false;
+    }
+
+    export function hasNucleic(model: Model): boolean {
+        const { subtype } = model.entities;
+        for (let i = 0, il = subtype.rowCount; i < il; ++i) {
+            const s = subtype.value(i);
+            if (s.endsWith('ribonucleotide hybrid') || s.endsWith('ribonucleotide')) return true;
+        }
+        return false;
+    }
+
     export function isFromPdbArchive(model: Model): boolean {
         if (!MmcifFormat.is(model.sourceData)) return false;
         const { db } = model.sourceData.data;

+ 4 - 8
src/mol-model/structure/model/properties/utils/atomic-ranges.ts

@@ -88,24 +88,20 @@ export function getAtomicRanges(hierarchy: AtomicHierarchy, entities: Entities,
                         startIndex = residueSegment.start;
                     } else if (!residueIt.hasNext) {
                         polymerRanges.push(startIndex, residueSegment.end - 1);
-                        // TODO
-                        // if (seqId !== maxSeqId) {
-                        //     gapRanges.push(residueSegment.end - 1, residueSegment.end - 1)
-                        // }
+                        // TODO store terminal gaps
                     } else {
                         const riStart = hierarchy.residueAtomSegments.index[residueSegment.start];
                         const riEnd = hierarchy.residueAtomSegments.index[prevEnd - 1];
                         if (conformation.xyzDefined && !areBackboneConnected(riStart, riEnd, conformation, hierarchy.index, derived)) {
                             polymerRanges.push(startIndex, prevEnd - 1);
+                            // add gap even for consecutive residues if they are not connected
+                            gapRanges.push(prevStart, residueSegment.end - 1);
                             startIndex = residueSegment.start;
                         }
                     }
                 } else {
                     startIndex = residueSegment.start; // start polymer
-                    // TODO
-                    // if (seqId !== 1) {
-                    //     gapRanges.push(residueSegment.start, residueSegment.start)
-                    // }
+                    // TODO store terminal gaps
                 }
             } else {
                 if (startIndex !== -1) {

+ 2 - 2
src/mol-repr/structure/representation/carbohydrate.ts

@@ -4,7 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Structure } from '../../../mol-model/structure';
+import { Structure, Model } from '../../../mol-model/structure';
 import { Representation, RepresentationContext, RepresentationParamsGetter } from '../../../mol-repr/representation';
 import { ThemeRegistryContext } from '../../../mol-theme/theme';
 import { ParamDefinition as PD } from '../../../mol-util/param-definition';
@@ -46,6 +46,6 @@ export const CarbohydrateRepresentationProvider = StructureRepresentationProvide
     defaultColorTheme: { name: 'carbohydrate-symbol' },
     defaultSizeTheme: { name: 'uniform' },
     isApplicable: (structure: Structure) => {
-        return structure.models.reduce((a, v) => a + v.properties.saccharideComponentMap.size, 0) > 0;
+        return structure.models.some(m => Model.hasCarbohydrate(m));
     }
 });

+ 2 - 2
src/mol-theme/color/carbohydrate-symbol.ts

@@ -4,7 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { StructureElement, Bond, ElementIndex, Unit } from '../../mol-model/structure';
+import { StructureElement, Bond, ElementIndex, Unit, Model } from '../../mol-model/structure';
 import { SaccharideColors, MonosaccharidesColorTable } from '../../mol-model/structure/structure/carbohydrates/constants';
 import { Location } from '../../mol-model/location';
 import { ColorTheme, LocationColor } from '../color';
@@ -68,6 +68,6 @@ export const CarbohydrateSymbolColorThemeProvider: ColorTheme.Provider<Carbohydr
     getParams: getCarbohydrateSymbolColorThemeParams,
     defaultValues: PD.getDefaultValues(CarbohydrateSymbolColorThemeParams),
     isApplicable: (ctx: ThemeDataContext) => {
-        return !!ctx.structure && ctx.structure.models.reduce((a, v) => a + v.properties.saccharideComponentMap.size, 0) > 0;
+        return !!ctx.structure && ctx.structure.models.some(m => Model.hasCarbohydrate(m));
     }
 };