Browse Source

check if carbs are applicable without calculating them

Alexander Rose 5 years ago
parent
commit
f5667411d7

+ 3 - 1
src/mol-repr/structure/representation/carbohydrate.ts

@@ -45,5 +45,7 @@ export const CarbohydrateRepresentationProvider = StructureRepresentationProvide
     defaultValues: PD.getDefaultValues(CarbohydrateParams),
     defaultColorTheme: { name: 'carbohydrate-symbol' },
     defaultSizeTheme: { name: 'uniform' },
-    isApplicable: (structure: Structure) => structure.carbohydrates.elements.length > 0
+    isApplicable: (structure: Structure) => {
+        return structure.models.reduce((a, v) => a + v.properties.saccharideComponentMap.size, 0) > 0
+    }
 })

+ 3 - 1
src/mol-theme/color/carbohydrate-symbol.ts

@@ -67,5 +67,7 @@ export const CarbohydrateSymbolColorThemeProvider: ColorTheme.Provider<Carbohydr
     factory: CarbohydrateSymbolColorTheme,
     getParams: getCarbohydrateSymbolColorThemeParams,
     defaultValues: PD.getDefaultValues(CarbohydrateSymbolColorThemeParams),
-    isApplicable: (ctx: ThemeDataContext) => !!ctx.structure && ctx.structure.carbohydrates.elements.length > 0
+    isApplicable: (ctx: ThemeDataContext) => {
+        return !!ctx.structure && ctx.structure.models.reduce((a, v) => a + v.properties.saccharideComponentMap.size, 0) > 0
+    }
 }