combinators.ts 723 B

1234567891011121314151617181920212223
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. import { StructureQuery } from '../query';
  7. import { StructureSelection } from '../selection';
  8. export function merge(queries: ArrayLike<StructureQuery>): StructureQuery {
  9. return ctx => {
  10. const ret = StructureSelection.UniqueBuilder(ctx.inputStructure);
  11. for (let i = 0; i < queries.length; i++) {
  12. StructureSelection.forEach(queries[i](ctx), (s, j) => {
  13. ret.add(s);
  14. if (i % 100) ctx.throwIfTimedOut();
  15. });
  16. }
  17. return ret.getSelection();
  18. }
  19. }
  20. // TODO: intersect, distanceCluster