Creates a Gene instance with the specified DNA sequence and exon definitions. Introns are automatically calculated from the gaps between exons.
The complete gene DNA sequence
Array of GenomicRegion objects defining exon locations
Optional
name: stringOptional name for the gene
Optional
splicingProfile: AlternativeSplicingProfileOptional alternative splicing profile for this gene
InvalidSequenceError Thrown if the sequence is invalid, exons are invalid, or exons extend beyond sequence
const gene = new Gene('ATGCCCGGGAAATTT', [
{ start: 0, end: 3, name: 'exon1' },
{ start: 9, end: 15, name: 'exon2' }
], 'BRCA1');
// Introns automatically calculated: [{ start: 3, end: 9 }]
Private
Readonly
exonsPrivate
Readonly
intronsPrivate
Optional
Readonly
nameReadonly
nucleicPrivate
Optional
Readonly
splicingPrivate
calculateCalculates intron regions from exon definitions.
Array of validated exon regions
Array of GenomicRegion objects representing introns
Checks if the sequence contains the specified subsequence
The subsequence to search for (string or same nucleic acid type)
True if the subsequence is found, false otherwise
const dna = new DNA('ATCGATCG');
console.log(dna.contains('TCG')); // true
console.log(dna.contains('AAA')); // false
Checks if the sequence ends with the specified suffix
The suffix to check for (string or same nucleic acid type)
True if the sequence ends with the suffix, false otherwise
const dna = new DNA('ATCGATCG');
console.log(dna.endsWith('TCG')); // true
console.log(dna.endsWith('ATC')); // false
Checks if the given NucleicAcid is equal
The NucleicAcid to compare
True if the NucleicAcids are equal, false otherwise
Returns the complement as a new DNA instance This is the object-oriented API for getting DNA complements
A new DNA instance containing the complement sequence
const dnaResult = DNA.create('ATCG');
if (dnaResult.success) {
const complement = dnaResult.data.getComplement(); // Returns new DNA('TAGC')
console.log(complement.getSequence()); // 'TAGC'
}
Gets the default splice variant for this gene.
The default splice variant, or undefined if no splicing profile
Gets the exon regions of this gene.
Readonly array of GenomicRegion objects representing exons
Gets the intron regions of this gene.
Readonly array of GenomicRegion objects representing introns
Returns the reverse complement as a new DNA instance This represents the opposite strand of double-stranded DNA
A new DNA instance containing the reverse complement sequence
const dnaResult = DNA.create('ATCG');
if (dnaResult.success) {
const dna = dnaResult.data;
const reverseComplement = dna.getReverseComplement(); // Returns new DNA('CGAT')
// Chainable operations
const original = dna.getReverseComplement().getReverseComplement(); // Returns new DNA('ATCG')
const doubleComplement = dna.getComplement().getComplement(); // Returns new DNA('ATCG')
}
Returns the reverse complement of the sequence This represents the opposite strand of double-stranded nucleic acids
String representing the reverse complement of the sequence
const dna = new DNA('ATCG');
console.log(dna.getReverseComplementSequence()); // 'CGAT'
const rna = new RNA('AUCG');
console.log(rna.getReverseComplementSequence()); // 'CGAU'
Gets the alternative splicing profile for this gene, if available.
The splicing profile, or undefined if no profile was provided
Gets a specific splice variant by name.
Name of the variant to retrieve
The splice variant, or undefined if not found
Gets all available splice variants for this gene.
Array of splice variants, or empty array if no splicing profile
Returns a DNA subsequence from the specified start position to the end position
The starting position (inclusive, 0-based)
Optional
end: numberThe ending position (exclusive, 0-based). If not specified, goes to end of sequence
A new DNA instance containing the subsequence
const dnaResult = DNA.create('ATCGATCG');
if (dnaResult.success) {
const sub = dnaResult.data.getSubsequence(2, 5); // Creates new DNA with 'CGA'
console.log(sub.getSequence()); // 'CGA'
}
Gets the mature sequence for a specific splice variant.
The splice variant to process
DNA sequence string of the variant's concatenated exons
Error if variant contains invalid exon indices
Returns the index of the first occurrence of the specified subsequence
The subsequence to search for (string or same nucleic acid type)
The position to start searching from (default: 0)
The index of the first occurrence, or -1 if not found
const dna = new DNA('ATCGATCG');
console.log(dna.indexOf('TCG')); // 1
console.log(dna.indexOf('TCG', 2)); // 5
console.log(dna.indexOf('AAA')); // -1
Checks if the sequence starts with the specified prefix
The prefix to check for (string or same nucleic acid type)
True if the sequence starts with the prefix, false otherwise
const dna = new DNA('ATCGATCG');
console.log(dna.startsWith('ATC')); // true
console.log(dna.startsWith('GTC')); // false
Private
validateValidates a splicing profile to ensure all variants reference valid exon indices.
The splicing profile to validate
Total number of exons in the gene
ValidationResult indicating success or failure with error message
Static
createCreates a DNA instance with validation.
String sequence OR any NucleicAcid to convert to DNA
ValidationResult containing DNA or error
Static
createCreates a Gene instance, returning a ValidationResult instead of throwing.
The complete gene DNA sequence
Array of GenomicRegion objects defining exon locations
Optional
name: stringOptional name for the gene
Optional
splicingProfile: AlternativeSplicingProfileOptional alternative splicing profile for this gene
ValidationResult containing Gene instance or error message
A class representing a Gene with exons and introns. Extends DNA to provide gene-specific functionality including exon/intron structure. Supports alternative splicing through splice variant profiles.