rcsb.ts 977 B

1234567891011121314151617181920212223
  1. /**
  2. * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { AssemblySymmetry } from '../../../../mol-model-props/rcsb/assembly-symmetry';
  7. import { AttachModelProperty } from '../../property-provider';
  8. import { ajaxGet } from '../../../../mol-util/data-source';
  9. import { GraphQLClient } from '../../../../mol-util/graphql-client';
  10. import { getParam } from '../../../common/util';
  11. export const RCSB_assemblySymmetry: AttachModelProperty = ({ model, params }) => {
  12. const url = getApiUrl(params, 'assembly_symmetry', `https:${AssemblySymmetry.GraphQLEndpointURL}`)
  13. const client = new GraphQLClient(url, ajaxGet)
  14. return AssemblySymmetry.attachFromCifOrAPI(model, client)
  15. }
  16. function getApiUrl(params: any, name: string, fallback: string) {
  17. const path = getParam<string>(params, 'RCSB', 'API', name);
  18. if (!path) return fallback;
  19. return path;
  20. }