dasmoth / dalliance

Interactive web-based genome browser.
http://www.biodalliance.org/
BSD 2-Clause "Simplified" License
226 stars 68 forks source link

Changing default settings per Javascript-Code #212

Closed cwuensch closed 7 years ago

cwuensch commented 7 years ago

I would like Biodalliance genome browser to be started with some pre-configured default settings. In particular, the option "Highlight mismatches and strands" in the bam-track shall be selected. How can I modify the settings from javascript code? Is there something like an API?

dasmoth commented 7 years ago

This can be done via the stylesheet system. An easy way to see how is to configure a track via the UI then click the Export button and select "Dalliance config". To get the effect you're looking for, you'll want a config along the lines of:

{
    "name": "BAM test",
    "bamURI": "/path/to/subset22-sorted.bam",
    "style": [
      {
        "type": "density",
        "zoom": "low",
        "style": {
          "glyph": "HISTOGRAM",
          "COLOR1": "black",
          "COLOR2": "red",
          "HEIGHT": 30
        }
      },
      {
        "type": "density",
        "zoom": "medium",
        "style": {
          "glyph": "HISTOGRAM",
          "COLOR1": "black",
          "COLOR2": "red",
          "HEIGHT": 30
        }
      },
      {
        "type": "bam",
        "zoom": "high",
        "style": {
          "glyph": "__SEQUENCE",
          "FGCOLOR": "black",
          "BGCOLOR": "blue",
          "HEIGHT": 8,
          "BUMP": true,
          "LABEL": false,
          "ZINDEX": 20,
          "__SEQCOLOR": "mismatch"
        }
      }
    ]
  }

The key option here is the:

   "__SEQCOLOR": "mismatch"
cwuensch commented 7 years ago

Thanks for the answer! I did what you suggested. But, it does not work. Reads are still displayed in multi-color according to bases, not in a uniform color with highlighted mismatches. Also the checkbox "Highlight mismatches and strands" is not selected. What to do now?

dasmoth commented 7 years ago

Sorry to hear you're having trouble.

Could you send me the exact config you've been using (just for this track). Also, what version of Biodalliance?

dasmoth commented 7 years ago

I'm currently seeing a rendering glitch under certain circumstances when "colour by mismatch" is selected in the git-master version of Biodalliance. I'll fix this tonight. But shouldn't affect the ability to configure this option (and 0.13.x should work fine).

max-l commented 7 years ago

I would love to see more examples and documentation of the JSON style sheet format, I've tried to "translate" the XML samples I have found into JSON, and I found it difficult and was unsuccessful. Perhaps the fact that I'm XMLo phobic is part of the explanation, but I don't know that there is a cure from XML hatred affliction ! ;-)

cwuensch commented 7 years ago

Figured it out. I did something wrong. It works now. Thank you very much!!