GMOD / jbrowse-components

Source code for JBrowse 2, a modern React-based genome browser
https://jbrowse.org/jb2
Apache License 2.0
205 stars 61 forks source link

Strip default items from session snapshots(?) #4503

Open cmdcolin opened 2 months ago

cmdcolin commented 2 months ago

this could be a large-ish task but session snapshots tend to be kind of bloated with a lot of default values being included. config snapshots specifically have logic to remove these. it uses the fact that config slots have a defaultValue to compare to. with session/view/track/display model snapshots, this logic for removing might be more "bespoke"

cmdcolin commented 2 months ago

example of a potential before and after

{
  "session": {
    "drawerPosition": "right",
    "drawerWidth": 384,
    "widgets": {
      "hierarchicalTrackSelector": {
        "id": "hierarchicalTrackSelector",
        "type": "HierarchicalTrackSelectorWidget",
        "view": "integration_test",
        "faceted": {
          "filterText": "",
          "showSparse": false,
          "showFilters": true,
          "showOptions": false,
          "panelWidth": 400
        }
      },
      "GridBookmark": {
        "id": "GridBookmark",
        "type": "GridBookmarkWidget"
      }
    },
    "activeWidgets": {
      "hierarchicalTrackSelector": "hierarchicalTrackSelector"
    },
    "minimized": false,
    "id": "X2pTznil7TtrhV4z1r75O",
    "name": "Integration test example 7/30/2024, 9:58:25 AM",
    "margin": 0,
    "views": [
      {
        "id": "integration_test",
        "minimized": false,
        "type": "LinearGenomeView",
        "offsetPx": 2000,
        "bpPerPx": 0.05,
        "displayedRegions": [
          {
            "refName": "ctgA",
            "start": 0,
            "end": 50001,
            "assemblyName": "volvox"
          }
        ],
        "tracks": [
          {
            "id": "ZfLTDGAGgASvA7MNwZe-R",
            "type": "AlignmentsTrack",
            "configuration": "volvox-long-reads-sv-cram",
            "minimized": false,
            "displays": [
              {
                "id": "td2O2UMdbdkKFdlhNQF66",
                "type": "LinearAlignmentsDisplay",
                "PileupDisplay": {
                  "id": "KLfnmVzVvgs9qtaRcw7bv",
                  "type": "LinearPileupDisplay",
                  "heightPreConfig": 205,
                  "configuration": {
                    "type": "LinearPileupDisplay",
                    "displayId": "volvox-long-reads-sv-cram-LinearAlignmentsDisplay_LinearPileupDisplay_xyz"
                  },
                  "filterBy": {
                    "flagInclude": 0,
                    "flagExclude": 1540
                  },
                  "jexlFilters": [],
                  "showSoftClipping": false
                },
                "SNPCoverageDisplay": {
                  "id": "EvLGqRbKK7L8_CIR6hCX_",
                  "type": "LinearSNPCoverageDisplay",
                  "heightPreConfig": 45,
                  "configuration": {
                    "type": "LinearSNPCoverageDisplay",
                    "displayId": "volvox-long-reads-sv-cram-LinearAlignmentsDisplay_snpcoverage_xyz"
                  },
                  "selectedRendering": "",
                  "resolution": 1,
                  "constraints": {},
                  "filterBy": {
                    "flagInclude": 0,
                    "flagExclude": 1540
                  },
                  "jexlFilters": []
                },
                "snpCovHeight": 45,
                "configuration": "volvox-long-reads-sv-cram-LinearAlignmentsDisplay",
                "lowerPanelType": "LinearPileupDisplay"
              }
            ]
          }
        ],
        "hideHeader": false,
        "hideHeaderOverview": false,
        "hideNoTracksActive": false,
        "trackSelectorType": "hierarchical",
        "showCenterLine": false,
        "showCytobandsSetting": true,
        "trackLabels": "offset",
        "showGridlines": true,
        "highlight": [],
        "colorByCDS": false,
        "showTrackOutlines": true,
        "showBookmarkHighlights": true,
        "showBookmarkLabels": true
      }
    ],
    "sessionTracks": [],
    "sessionAssemblies": [],
    "temporaryAssemblies": [],
    "connectionInstances": [],
    "sessionConnections": [],
    "focusedViewId": "integration_test",
    "sessionPlugins": []
  }
}

after

{
  "session": {
    "widgets": {
      "hierarchicalTrackSelector": {
        "id": "hierarchicalTrackSelector",
        "type": "HierarchicalTrackSelectorWidget",
        "view": "integration_test"
      },
    },
    "activeWidgets": {
      "hierarchicalTrackSelector": "hierarchicalTrackSelector"
    },
    "id": "X2pTznil7TtrhV4z1r75O",
    "name": "Integration test example 7/30/2024, 9:58:25 AM",
    "views": [
      {
        "id": "integration_test",
        "type": "LinearGenomeView",
        "offsetPx": 2000,
        "bpPerPx": 0.05,
        "displayedRegions": [
          {
            "refName": "ctgA",
            "start": 0,
            "end": 50001,
            "assemblyName": "volvox"
          }
        ],
        "tracks": [
          {
            "id": "ZfLTDGAGgASvA7MNwZe-R",
            "type": "AlignmentsTrack",
            "configuration": "volvox-long-reads-sv-cram",
            "displays": [
              {
                "id": "td2O2UMdbdkKFdlhNQF66",
                "type": "LinearAlignmentsDisplay",
                "PileupDisplay": {
                  "id": "KLfnmVzVvgs9qtaRcw7bv",
                  "type": "LinearPileupDisplay",
                  "configuration": {
                    "type": "LinearPileupDisplay",
                    "displayId": "volvox-long-reads-sv-cram-LinearAlignmentsDisplay_LinearPileupDisplay_xyz"
                  },
                },
                "SNPCoverageDisplay": {
                  "id": "EvLGqRbKK7L8_CIR6hCX_",
                  "type": "LinearSNPCoverageDisplay",
                  "configuration": {
                    "type": "LinearSNPCoverageDisplay",
                    "displayId": "volvox-long-reads-sv-cram-LinearAlignmentsDisplay_snpcoverage_xyz"
                  },
                },
                "configuration": "volvox-long-reads-sv-cram-LinearAlignmentsDisplay",
                "lowerPanelType": "LinearPileupDisplay"
              }
            ]
          }
        ]
      }
    ],
    "focusedViewId": "integration_test"
  }
}

potentially the after could be simplified even further but that would be a good start