Skip to content

Commit

Permalink
Add InterPro color scheme in interpro-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Swaathik committed Nov 27, 2023
1 parent 888fa48 commit bad5190
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/protvista-interpro-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
"bugs": {
"url": "https://github.com/ebi-webcomponents/nightingale/issues"
},
"homepage": "https://ebi-webcomponents.github.io/nightingale/"
"homepage": "https://ebi-webcomponents.github.io/nightingale/",
"dependencies": {
"color-hash": "2.0.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
import ColorHash from "color-hash";

// Copied from InterPro to replicate the same colours for the representative domains
/* eslint-disable no-magic-numbers */
const colorHash = new ColorHash({
hash: "bkdr",
saturation: [0.65, 0.35, 0.5],
lightness: [0.65, 0.35, 0.5],
});
/* eslint-enable no-magic-numbers */

export const transformData = (data) => {
try {
return data?.results?.map(({ metadata, proteins }) => ({
Expand All @@ -13,6 +24,9 @@ export const transformData = (data) => {
Math.max(...location.fragments.map((fragment) => fragment.end))
)
),
color: colorHash.hex(
metadata.accession.toLowerCase().split("").reverse().join("")
),
tooltipContent: `
<h5>Accession</h5>
<p>
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4674,6 +4674,11 @@ color-convert@^2.0.1:
dependencies:
color-name "~1.1.4"

color-hash@2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/color-hash/-/color-hash-2.0.2.tgz#abf735705da71874ddec7dcef50cd7479e7d64e9"
integrity sha512-6exeENAqBTuIR1wIo36mR8xVVBv6l1hSLd7Qmvf6158Ld1L15/dbahR9VUOiX7GmGJBCnQyS0EY+I8x+wa7egg==

color-name@1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
Expand Down

0 comments on commit bad5190

Please sign in to comment.