A nonempty regex string containing only nucleotide IUPAC notation symbols and valid regex symbols/operators
InvalidNucleotidePatternError Thrown if the pattern is empty, or contains invalid characters
Readonly
patternPrivate
Readonly
patternFinds the first occurrence of the pattern within a nucleic acid sequence
The NucleicAcid to search within
Match object with start position, end position, and matched sequence, or null if no match found
const pattern = new NucleotidePattern('RY');
const dna = new DNA('ATGAGCGATC');
const match = pattern.findFirst(dna);
// Returns: { start: 2, end: 4, match: 'GA' }
Finds all occurrences of the pattern within a nucleic acid sequence
The NucleicAcid to search within
Array of match objects with start position, end position, and matched sequence
const pattern = new NucleotidePattern('RY');
const dna = new DNA('ATGAGCGATC');
const matches = pattern.findMatches(dna);
// Returns: [{ start: 2, end: 4, match: 'GA' }, { start: 5, end: 7, match: 'GC' }]
Finds all occurrences of the pattern within a string sequence
The sequence string to search within
Array of match objects with start position, end position, and matched sequence
const pattern = new NucleotidePattern('RY');
const matches = pattern.findMatchesString('ATGAGCGATC');
// Returns: [{ start: 2, end: 4, match: 'GA' }, { start: 5, end: 7, match: 'GC' }]
Creates a NucleotidePattern representing the reverse complement of this pattern.
A new NucleotidePattern representing the reverse complement
const pattern = new NucleotidePattern('GAATTC');
const reverseComplement = pattern.getReverseComplement();
// Returns pattern equivalent to 'GAATTC' (EcoRI site is palindromic)
const asymmetric = new NucleotidePattern('ATCG');
const rcAsymmetric = asymmetric.getReverseComplement();
// Returns pattern equivalent to 'CGAT'
Checks if a given NucleicAcid matches the nucleotide IUPAC notation pattern
The NucleicAcid to check against the pattern
True if the NucleicAcid matches the pattern, false otherwise
//given the following pattern object
const pattern = new NucleotidePattern('ANNT');
//check a valid DNA match
pattern.matches(new DNA('AAAT')); //returns true
//check an invalid DNA match
pattern.matches(new DNA('CCCC')); //returns false
//check an invalid RNA match
pattern.matches(new RNA('AGCU')); //returns false
//check DNA that matches the pattern, but is longer than the pattern
pattern.matches(new DNA('ACCTAAA')); //returns false
Checks if the pattern matches either the forward strand or reverse complement strand of the given nucleic acid sequence
The NucleicAcid to check against both strands
True if the pattern matches either the forward or reverse complement strand
const pattern = new NucleotidePattern('GAATTC'); // EcoRI restriction site
const dna = new DNA('CTTAAG'); // Reverse complement of GAATTC
console.log(pattern.matches(dna)); // false
console.log(pattern.matchesEitherStrand(dna)); // true
Replaces all occurrences of the pattern in a nucleic acid sequence.
The nucleic acid containing the sequence to modify
The replacement string
The modified sequence string
Splits a nucleic acid sequence by the pattern.
The nucleic acid to split
Array of sequence parts split by the pattern
Tests if a nucleic acid sequence contains the pattern.
The nucleic acid to test
True if the pattern is found in the sequence
Static
createCreates a NucleotidePattern representing the complement of the given pattern.
The pattern to get the complement of
A new NucleotidePattern representing the complement
Static
Private
getInternal method to convert IUPAC nucleotide patterns to regular expressions.
The IUPAC nucleotide pattern string
Whether to get the complement pattern
Whether to return RegExp (true) or string (false)
Regular expression or string representation
InvalidNucleotidePatternError Thrown if the pattern input contains invalid alpha characters (must be a valid IUPAC nucleotide symbol) or is not a valid regex
A class to represent patterns comprised of nucleotide IUPAC notation symbols. The constructor enforces validation, and all members are readonly. Therefor, all NucleotidePattern objects can only exist in a valid state.
See