Skip to content

Commit

Permalink
Add button to change background color of protein
Browse files Browse the repository at this point in the history
  • Loading branch information
WillHannon-MCB committed Mar 12, 2024
1 parent c39745a commit 911f695
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions v0/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ kbd {
min-width: 300px;
min-height: 300px;
max-height: 600px;
border-radius: 10px
}

.heatmap-tooltip,
Expand Down
4 changes: 4 additions & 0 deletions v0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ <h1 class="logo">
<label for="ligandColor">Ligand Color </label>
<input type="color" id="ligandColor" />
</div>
<div class="accordion-option color">
<label for="screenColor">Background Color </label>
<input type="color" id="screenColor" />
</div>
<div class="accordion-option">
<label for="proteinElement"
>Color Protein By Element
Expand Down
3 changes: 3 additions & 0 deletions v0/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ function setUpProteinOptionListeners() {
d3.select("#ligandColor").on("change", function () {
State.updateProteinOptions(this);
});
d3.select("#screenColor").on("change", function () {
State.updateProteinOptions(this);
});
d3.select("#ligandElement").on("change", function () {
this.value = this.checked ? "true" : "false";
State.updateProteinOptions(this);
Expand Down
7 changes: 5 additions & 2 deletions v0/js/protein.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Protein extends EventTarget {

// Initialize the stage object for the target element
protein.stage = new NGL.Stage(protein.config.parentElement, {
backgroundColor: "#FFFFFF",
backgroundColor: protein.config.screenColor,
});

// Set the initial size of the stage
Expand Down Expand Up @@ -183,6 +183,10 @@ export class Protein extends EventTarget {
updateRepresentation() {
let protein = this;

// Set the background color of the stage
protein.stage.setParameters({
backgroundColor: protein.config.screenColor,
});
protein.stage.getRepresentationsByName("dataChains").dispose();
protein.component.addRepresentation(protein.config.proteinRepresentation, {
sele: protein.config.showNonCarbonHydrogens
Expand Down Expand Up @@ -439,7 +443,6 @@ export class Protein extends EventTarget {
? `protein and (${selectedSitesStrings.join(" or ")})`
: undefined;

console.log(protein.currentSelectionSiteString);
// Create a representation of the selected sites on the protein structure
if (protein.currentSelectionSiteString !== undefined) {
protein.stage.getRepresentationsByName("currentSelection").dispose();
Expand Down
3 changes: 3 additions & 0 deletions v0/js/tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class Tool {
tool.initColorPicker(d3.select("#proteinColor"), tool.proteinColor);
tool.initColorPicker(d3.select("#backgroundColor"), tool.backgroundColor);
tool.initColorPicker(d3.select("#ligandColor"), tool.ligandColor);
tool.initColorPicker(d3.select("#screenColor"), tool.screenColor);
tool.initCheckbox(d3.select("#ligandElement"), tool.ligandElement);
tool.initCheckbox(d3.select("#proteinElement"), tool.proteinElement);
tool.initCheckbox(d3.select("#proteinElement"), tool.proteinElement);
Expand Down Expand Up @@ -219,6 +220,7 @@ export class Tool {
proteinColor: tool.proteinColor,
backgroundColor: tool.backgroundColor,
ligandColor: tool.ligandColor,
screenColor: tool.screenColor,
ligandElement: tool.ligandElement,
proteinElement: tool.proteinElement,
backgroundOpacity: tool.backgroundOpacity,
Expand Down Expand Up @@ -608,6 +610,7 @@ export class Tool {
proteinColor: { abbrev: "pc", default: "#c9c9c9", json: false },
backgroundColor: { abbrev: "bc", default: "#c9c9c9", json: false },
ligandColor: { abbrev: "lc", default: "#c9c9c9", json: false },
screenColor: { abbrev: "sc", default: "#FFFFFF", json: false },
ligandElement: { abbrev: "le", default: false, json: false },
proteinElement: { abbrev: "pce", default: false, json: false },
proteinOpacity: { abbrev: "po", default: "1", json: false },
Expand Down

0 comments on commit 911f695

Please sign in to comment.