npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

central-dogma

v0.0.5

Published

used to manipulate and convert genetic strings from nucleotide to codon to protein

Downloads

27

Readme

central-dogma

central-dogma is an npm package used for writing and manipulating genetic sequences. It accepts both DNA and RNA input in the form of nucleotide sequences or codon arrays and provides functions to convert them between nucleotides to codons to amino acids.

The name 'central-dogma' refers to the Central Dogma of Biology which describes the process of DNA being transcribed to RNA which is then translated to Amino Acids and Proteins.

Getting Started

Install via npm:

npm install central-dogma

Require the nucleotide and/or codon objects from the package:

'use strict'
const nuc = require('central-dogma').nucleotide;
const cod = require('central-dogma').codon;

Example Usage

Convert DNA Nucleotide sequence to codon to amino acid

const dnaSequence = 'CCTATTAATAAA';
const dnaCodons = nuc.toCodon(dnaSequence);         // dnaCodons = ['CCT', 'ATT', 'AAT', 'AAA']
const aminoAcids = cod.sequenceToAminoAcid(dnaCodons);
console.log(aminoAcids)                             // --> ['P', 'I', 'N', 'K']

Convert DNA Nucleotide sequence to its complement

const dnaSequence = 'CCTATTAATAAA';
const complement = nuc.toComplement(dnaSequence); 
console.log(complement)                             // --> 'GGATAATTATTT'

Convert DNA Nucleotide sequence to its RNA complement to codon number representation to amino acid

const dnaSequence = 'GTGCTTGAGGACCGA';
const complement = nuc.toComplement(dnaSequence);   // complement = 'GTGCTTGAGGACCGA'
const rnaComplement = nuc.dnaToRna(complement);     // rnaComplement = 'GUGCUUGAGGACCGA'
const rnaCodons = nuc.toCodon(rnaComplement);       // rnaCodons = ['GUG', 'CUU', 'GAG', 'GAC', 'CGA']

cod.setBase('rna')                                  // change the lookup table from DNA to RNA 
const rnaCodonNumbers = cod.toNumber(rnaCodons);    // rnaCodonNumbers = [ 25, 58, 17, 19, 52 ]
const aminoAcids = cod.numberToAminoAcid(rnaCodonNumbers);
console.log(aminoAcids)                             // --> ['H', 'E', 'L', 'L', 'A']

Functions

Nucleotide

nuc.setBase(baseType)

  • input: 'dna' or 'rna'
  • changes lookup table to DNA or RNA (swap thymine for uracil)

nuc.toValue(nucSeq)

  • input: nucleotide string sequence (eg "TCCTTG")
  • Converts sequence of nucleotides to number representation

nuc.toSequence(nucSeq)

  • input: number representation string sequence (eg "011003")
  • Converts sequence of numbers [0-3] to nucleotides

nuc.toComplement(nucSeq)

  • input: nucleotide string sequence
  • Returns the complement sequence of the input string (T <-> C, A <-> G)

nuc.toCodon(nucSeq)

  • input: nucleotide string sequence
  • Splits into an array of triplet codons

nuc.dnaToRna(nucSeq)

  • input: nucleotide string sequence
  • Replaces Thymine (T) with Uracil (U)

nuc.rnaToDna(nucSeq)

  • input: nucleotide string sequence
  • Replaces Uracil (U) with Thymine (T)

Codon

cod.setBase(baseType)

  • input: 'dna' or 'rna'
  • changes lookup table to DNA or RNA (swap thymine for uracil)

cod.toNumber(codArray)

  • input: array of nucleotide string codons (eg ['TCC', 'ATT'])
  • Converts each codon in the array to number representation [0-63]

cod.toSequence(codArray)

  • input: array of codon numbers (eg [5, 32])
  • Converts each number to its nucleotide codon

cod.numberToAminoAcid(codArray)

  • input: array of codon numbers (eg [5, 32])
  • Returns array of amino acids that the codons encode for

cod.sequenceToAminoAcid(codArray)

  • input: array of nucleotide string codons
  • Returns array of amino acids that the codons encode for

Future Directions

In future versions, I intend to implement:

  • a conversion from single character amino acid representation to 3 character and full amino acid name (eg: 'Y' --> 'TYR' --> 'Tyrosine')

  • the ability to supply a custom amino acid dictionary - useful in protein encoding for other species (eg 'TTT' codon encodes for Tyrosine instead of Phenyalanine)