Skip to content

Commit

Permalink
add rna logo
Browse files Browse the repository at this point in the history
  • Loading branch information
riyavsinha committed May 8, 2024
1 parent 0f23ab9 commit 3936229
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 37 deletions.
28 changes: 28 additions & 0 deletions src/components/logo/RNALogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react";

import { A, C, G, U } from "../glyphs";
import { Logo, LogoProps } from "./Logo";
import { UserDefinedAlphabet } from "../../types";

/**
* Represents the RNA alphabet, with the four nucleotides colored
* in a similar scheme to the MEME default.
*/
export const RNAAlphabet = [
{ component: A, regex: "A", color: "red" },
{ component: C, regex: "C", color: "blue" },
{ component: G, regex: "G", color: "orange" },
{ component: U, regex: "U", color: "seagreen" },
];

export type RNALogoProps = Omit<LogoProps, "alphabet"> & {
/** The DNA alphabet to use for the logo. */
alphabet?: UserDefinedAlphabet;
};

/**
* Renders a logo with the RNA alphabet, with nucleotides colored similarly to the MEME default.
*/
export const RNALogo = (props: RNALogoProps) => (
<Logo alphabet={RNAAlphabet} {...props} />
);
30 changes: 0 additions & 30 deletions src/components/logo/rnalogo.jsx

This file was deleted.

6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Logo } from "./components/logo/Logo";
import { RawLogo } from "./components/logo/RawLogo";
import ProteinLogo, { ProteinAlphabet } from "./components/logo/ProteinLogo";
import DNALogo, { DNAAlphabet } from "./components/logo/DNALogo";
import RNALogo, { RNAAlphabet } from "./components/logo/rnalogo";
import { ProteinLogo, ProteinAlphabet } from "./components/logo/ProteinLogo";
import { DNALogo, DNAAlphabet } from "./components/logo/DNALogo";
import { RNALogo, RNAAlphabet } from "./components/logo/RNALogo";
import CompleteLogo from "./components/logo/completelogo";
import { CompleteAlphabet } from "./common/alphabet";
import { xrange } from "./common/utils";
Expand Down
7 changes: 3 additions & 4 deletions src/js/embed.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { renderToStaticMarkup } from "react-dom/server";

import DNALogo from "../components/logo/DNALogo";
import RNALogo from "../components/logo/rnalogo";
import ProteinLogo from "../components/logo/ProteinLogo";
import { DNALogo } from "../components/logo/DNALogo";
import { RNALogo } from "../components/logo/RNALogo";
import { ProteinLogo } from "../components/logo/ProteinLogo";
import { Logo } from "../components/logo/Logo";
import { RawLogo } from "../components/logo/RawLogo";

Expand Down Expand Up @@ -56,4 +56,3 @@ export const embedLogo = (div, props) => {
export const embedRawLogo = (container, props) => {
container.innerHTML = renderToStaticMarkup(<RawLogo {...props} />);
};

35 changes: 35 additions & 0 deletions src/stories/RNALogo.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Meta, StoryObj } from "@storybook/react";
import React from "react";

import { RNALogo } from "../components/logo/RNALogo";
import { DataType } from "../types";

const meta = {
title: "RNALogo",
component: RNALogo,
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ["autodocs"],
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
layout: "centered",
},
} satisfies Meta<typeof RNALogo>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Basic: Story = {
args: {
data: [
[0.7, 0.1, 0.1, 0.1],
[0, 1, 0, 0],
[0, 0, 0, 1],
[1, 0, 0, 0],
[1, 0, 0, 0],
[0, 1, 0, 0],
[0.3, 0.2, 0.3, 0.2],
],
dataType: DataType.PPM,
width: 700,
},
};

0 comments on commit 3936229

Please sign in to comment.