atom-set.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Koya Sakuma
  5. * Adapted from MolQL implemtation of atom-set.ts
  6. *
  7. * Copyright (c) 2017 MolQL contributors, licensed under MIT, See LICENSE file for more info.
  8. *
  9. * @author David Sehnal <david.sehnal@gmail.com>
  10. */
  11. import { StructureQuery } from '../query';
  12. import { StructureSelection } from '../selection';
  13. import { getCurrentStructureProperties } from './filters';
  14. import { QueryContext, QueryFn } from '../context';
  15. export function atomCount(ctx: QueryContext) {
  16. return (ctx: QueryContext) => {
  17. const all = StructureSelection.Singletons(ctx.currentStructure, ctx.currentStructure);
  18. const x: number = StructureSelection.structureCount(all);
  19. return x;
  20. };
  21. }
  22. export function countQuery(ctx: QueryContext, query: StructureQuery) {
  23. return (ctx: QueryContext) => {
  24. const sel = query(ctx);
  25. const x: number = StructureSelection.structureCount(sel);
  26. return x;
  27. };
  28. }
  29. // export function propertySet(ctx: QueryContext, prop: UnitTypeProperties) {
  30. export function propertySet(ctx: QueryContext, prop: QueryFn<any>) {
  31. return (ctx: QueryContext) => {
  32. const set = new Set();
  33. const x = getCurrentStructureProperties(ctx, prop, set);
  34. // console.log(x)
  35. return x;
  36. };
  37. }