index.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import './index.html';
  2. import {RcsbFv3DAssembly, RcsbFv3DAssemblyInterface} from "../../RcsbFv3D/RcsbFv3DAssembly";
  3. import {AlignmentResponse, AnnotationFeatures} from "@rcsb/rcsb-saguaro-api/build/RcsbGraphQL/Types/Borrego/GqlTypes";
  4. import {SequenceCollectorDataInterface} from "@rcsb/rcsb-saguaro-app/build/dist/RcsbCollectTools/SequenceCollector/SequenceCollector";
  5. import {RcsbFvDisplayTypes, RcsbFvRowConfigInterface} from "@rcsb/rcsb-saguaro";
  6. document.addEventListener("DOMContentLoaded", function(event) {
  7. function getJsonFromUrl() {
  8. const url = location.search;
  9. var query = url.substr(1);
  10. var result: any = {};
  11. query.split("&").forEach(function(part) {
  12. var item = part.split("=");
  13. result[item[0]] = decodeURIComponent(item[1]);
  14. });
  15. return result;
  16. }
  17. const args: {pdbId:string} = getJsonFromUrl() ?? {pdbId:"4hhb"};
  18. const sequenceConfig = {
  19. entryId:args.pdbId,
  20. title: args.pdbId,
  21. subtitle: "Subtitle for "+args.pdbId
  22. };
  23. const panel3d = new RcsbFv3DAssembly({
  24. elementId: "pfv",
  25. config: sequenceConfig,
  26. additionalConfig: {
  27. boardConfig: {
  28. elementClickCallBack: (e) => {
  29. console.log(`Element clicked ${e?.type}`)
  30. }
  31. },
  32. externalTrackBuilder:{
  33. processAlignmentAndFeatures(data: { annotations?: Array<AnnotationFeatures>; alignments?: AlignmentResponse }) {
  34. },
  35. filterFeatures(annotations: Array<AnnotationFeatures>) {
  36. },
  37. addTo(tracks: { alignmentTracks?: SequenceCollectorDataInterface; annotationTracks?: Array<RcsbFvRowConfigInterface> }) {
  38. const myTrack: RcsbFvRowConfigInterface = {
  39. trackId: "blockTrack",
  40. trackHeight: 20,
  41. trackColor: "#F9F9F9",
  42. displayType: RcsbFvDisplayTypes.BLOCK,
  43. displayColor: "#FF0000",
  44. rowTitle: "MY TRACK",
  45. trackData: [{
  46. begin: 30,
  47. end: 60
  48. }]
  49. }
  50. tracks.annotationTracks?.push(myTrack);
  51. }
  52. }
  53. }
  54. });
  55. panel3d.render();
  56. });