
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A comprehensive TypeScript library for molecular biology simulation, modeling the gene expression pathway from DNA transcription to polypeptide translation with biological accuracy.
A comprehensive TypeScript library for molecular biology simulation, modeling DNA replication, gene expression, and polypeptide translation with biological accuracy.
🧬 DNA Replication & Gene Expression Pipeline
🛡️ Type-Safe & Immutable
ValidationResult pattern🔬 Biologically Accurate
🚀 Performance Optimized
npm install ts-dna
yarn add ts-dna
Complete API documentation with detailed examples is available at GitHub pages.
import { DNA, RNA, convertToRNA, NucleicAcidType } from 'ts-dna';
// Create and manipulate nucleic acids
const dna = new DNA('ATGTGCGACGAATTC');
const rna = convertToRNA(dna);
console.log(dna.getComplement()); // 'TACGCGCTGTTAAG'
console.log(rna.getSequence()); // 'AUGUGCGACGAAUC'
import { DNA, replicateDNA, replicateDNASimple, E_COLI, HUMAN } from 'ts-dna';
// Simple DNA replication
const originalDNA = new DNA('ATGTGCGACGAATTC');
const result = replicateDNASimple(originalDNA);
if (result.success) {
const [strand1, strand2] = result.data;
console.log('Original:', originalDNA.getSequence());
console.log('Strand 1:', strand1.getSequence());
console.log('Strand 2:', strand2.getSequence());
}
// Advanced replication with organism-specific parameters
const replicationResult = replicateDNA(originalDNA, {
organism: E_COLI, // 1000 bp/s, 1000-2000 nt Okazaki fragments
includeStatistics: true,
validateReplication: true
});
if (replicationResult.success) {
const { replicatedStrands, statistics } = replicationResult.data;
console.log(`Replication events: ${statistics.totalEvents}`);
console.log(`Okazaki fragments: ${statistics.okazakiFragments.length}`);
console.log(`Leading strand length: ${statistics.leadingStrandLength} bp`);
}
import {
Gene,
transcribe,
processRNA,
Polypeptide,
isSuccess
} from 'ts-dna';
// Define a simple gene
const geneSequence =
'GCGCTATAAAAGGCGC' + // Promoter with TATA box
'ATGAAAGCCTTTGAG' + // Exon 1: start codon + coding
'GTAAGTCCCCCCCAG' + // Intron 1: GT...AG splice sites
'TTCGATGCCATGGAG' + // Exon 2: more coding
'GTAAGTAAAAAAAAG' + // Intron 2
'CTGAAGGACCTGTAG'; // Exon 3: coding + stop codon
const exons = [
{ start: 16, end: 31 }, // Exon 1
{ start: 46, end: 61 }, // Exon 2
{ start: 76, end: 91 } // Exon 3
];
// Complete gene expression pathway
const gene = new Gene(geneSequence, exons);
const preMRNA = transcribe(gene).unwrap();
const mRNA = processRNA(preMRNA).unwrap();
const polypeptide = new Polypeptide(mRNA);
console.log(`Gene length: ${gene.getSequence().length} bp`);
console.log(`mRNA length: ${mRNA.getCodingSequence().length} bp`);
console.log(`Polypeptide length: ${polypeptide.aminoAcidSequence.length} amino acids`);
console.log(`First amino acid: ${polypeptide.aminoAcidSequence[0].name}`);
import {
Gene,
AlternativeSplicingProfile,
transcribe,
processAllSplicingVariants
} from 'ts-dna';
// Define splicing variants
const splicingProfile: AlternativeSplicingProfile = {
geneId: 'EXAMPLE',
defaultVariant: 'full-length',
variants: [
{
name: 'full-length',
includedExons: [0, 1, 2, 3],
description: 'Complete polypeptide with all domains'
},
{
name: 'short-isoform',
includedExons: [0, 1, 3],
description: 'Alternative splicing skips exon 2'
}
]
};
const gene = new Gene(sequence, exons, 'EXAMPLE', splicingProfile);
const preMRNA = transcribe(gene).unwrap();
const outcomes = processAllSplicingVariants(preMRNA).unwrap();
for (const outcome of outcomes) {
console.log(`${outcome.variant.name}: ${outcome.proteinLength} amino acids`);
}
import { NucleotidePattern, DNA } from 'ts-dna';
// IUPAC pattern matching
const tataBox = new NucleotidePattern('TATAAWAW');
const promoterDNA = new DNA('GCGCTATAAAAGGCGC');
console.log(tataBox.test(promoterDNA)); // true
console.log(tataBox.findFirst(promoterDNA)); // { start: 4, end: 12 }
// Find all TATA box occurrences
const matches = tataBox.findAll(promoterDNA);
console.log(`Found ${matches.length} TATA boxes`);
import { AminoAcid, RNA, getAminoAcidByCodon } from 'ts-dna';
// Single amino acid properties
const phe = new AminoAcid(new RNA('UUU'));
console.log(phe.name); // 'Phenylalanine'
console.log(phe.singleLetterCode); // 'F'
console.log(phe.molecularWeight); // 165.19
console.log(phe.polarity); // AminoAcidPolarity.NONPOLAR
console.log(phe.getAllAlternateCodons()); // ['UUU', 'UUC']
// Direct codon lookup
const codonData = getAminoAcidByCodon('UUU');
console.log(codonData.name); // 'Phenylalanine'
import {
Replisome,
ReplicationFork,
EnzymeFactory,
E_COLI,
HUMAN,
isSuccess
} from 'ts-dna';
// Create replication machinery
const dna = new DNA('ATGTGCGACGAATTCGGCATGGCC');
const fork = new ReplicationFork(0, dna.length(), E_COLI);
const replisome = new Replisome(fork, E_COLI);
// Manual enzyme creation with validation
const helicaseResult = EnzymeFactory.createHelicase(100);
if (isSuccess(helicaseResult)) {
const helicase = helicaseResult.data;
console.log(`Helicase at position: ${helicase.position}`);
console.log(`Enzyme type: ${helicase.type}`);
}
// Access replication statistics
const statistics = replisome.getStatistics();
console.log(`Fork position: ${statistics.forkPosition}`);
console.log(`Completion: ${statistics.completionPercentage}%`);
console.log(`Active Okazaki fragments: ${statistics.activeOkazakiFragments}`);
import { findPromoters, TATA_BOX, GC_BOX } from 'ts-dna';
const dna = new DNA('GCGCTATAAAAGGCCAATCGGGGCGG');
const promoters = findPromoters(dna, {
elements: [TATA_BOX, GC_BOX],
maxDistance: 200,
minStrength: 0.7
});
for (const promoter of promoters) {
console.log(`Promoter at ${promoter.transcriptionStartSite}`);
console.log(`Elements: ${promoter.elements.map(e => e.name).join(', ')}`);
}
import {
processRNA,
findPolyadenylationSites,
add5PrimeCap,
add3PrimePolyATail
} from 'ts-dna';
// Custom RNA processing
const preMRNA = transcribe(gene).unwrap();
// Manual processing steps
const cappedRNA = add5PrimeCap(preMRNA);
const splicedRNA = spliceRNA(cappedRNA).unwrap();
// Find poly-A sites
const polyASites = findPolyadenylationSites(splicedRNA);
const strongestSite = polyASites[0];
const mRNA = add3PrimePolyATailAtSite(
splicedRNA,
strongestSite.position,
200 // tail length
);
import { DNA, ValidationResult, isSuccess, isFailure } from 'ts-dna';
// Safe construction with validation
const result: ValidationResult<DNA> = DNA.create('INVALID_SEQUENCE');
if (isSuccess(result)) {
console.log('Valid DNA:', result.data.getSequence());
} else {
console.log('Validation error:', result.error);
}
// Functional error handling
const processedResult = transcribe(gene)
.chain(preMRNA => processRNA(preMRNA))
.map(mRNA => new Polypeptide(mRNA));
if (isSuccess(processedResult)) {
console.log('Polypeptide created successfully');
} else {
console.log('Pipeline failed:', processedResult.error);
}
The library includes comprehensive biological constants for realistic simulations:
import {
// Genetic code
START_CODON,
STOP_CODONS,
CODON_LENGTH,
// Splice sites
DONOR_SPLICE_CONSENSUS,
ACCEPTOR_SPLICE_CONSENSUS,
// Promoter elements
TATA_BOX_CONSENSUS,
INITIATOR_CONSENSUS,
GC_BOX_CONSENSUS,
// Polyadenylation
DEFAULT_POLYA_SIGNALS,
CANONICAL_POLYA_SIGNAL_DNA,
// Gene structure
MIN_EXON_SIZE,
MAX_EXON_SIZE,
MIN_INTRON_SIZE,
MAX_INTRON_SIZE,
// DNA Replication
E_COLI_POLYMERASE_SPEED,
HUMAN_POLYMERASE_SPEED,
MIN_RNA_PRIMER_LENGTH,
MAX_RNA_PRIMER_LENGTH,
PROKARYOTIC_FRAGMENT_SIZE_RANGE,
EUKARYOTIC_FRAGMENT_SIZE_RANGE
} from 'ts-dna';
MIT License - see LICENSE.md for details.
FAQs
A comprehensive TypeScript library for molecular biology simulation, modeling the gene expression pathway from DNA transcription to polypeptide translation with biological accuracy.
We found that ts-dna demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.