A mature mRNA sequence that codes for a sequence of amino acids
InvalidSequenceError Thrown if the mRNA coding sequence length is not divisible by 3 (invalid codons)
InvalidCodonError Thrown if any codon is invalid (doesn't code for an amino acid and is not a stop codon)
const mRNA = new MRNA('GAUGAAAGGGAAAUAG', 'AUGAAAGGGAAAUAG', 1, 16);
const polypeptide = new Polypeptide(mRNA); // 4 codons: Met-Lys-Gly-Lys, stops at UAG
console.log(polypeptide.aminoAcidSequence.length); // 4
Readonly
aminoReadonly
mRNAChecks if the polypeptide contains the specified amino acid subsequence
The amino acid subsequence to search for (string or Polypeptide)
True if the subsequence is found, false otherwise
const polypeptide = new Polypeptide(mRNA); // sequence: 'MKGK'
console.log(polypeptide.contains('KG')); // true
console.log(polypeptide.contains('AA')); // false
Checks if the polypeptide ends with the specified amino acid suffix
The amino acid suffix to check for (string or Polypeptide)
True if the sequence ends with the suffix, false otherwise
const polypeptide = new Polypeptide(mRNA); // sequence: 'MKGK'
console.log(polypeptide.endsWith('GK')); // true
console.log(polypeptide.endsWith('MK')); // false
Returns a sub-polypeptide 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 Polypeptide instance containing the amino acid subsequence
const polypeptide = new Polypeptide(mRNA); // sequence: 'MKGK'
const sub = polypeptide.getSubsequence(1, 3); // Creates polypeptide with 'KG'
console.log(sub.getSequence()); // 'KG'
Returns the index of the first occurrence of the specified amino acid subsequence
The amino acid subsequence to search for (string or Polypeptide)
The position to start searching from (default: 0)
The index of the first occurrence, or -1 if not found
const polypeptide = new Polypeptide(mRNA); // sequence: 'MKGK'
console.log(polypeptide.indexOf('K')); // 1 (first K)
console.log(polypeptide.indexOf('K', 2)); // 3 (second K)
console.log(polypeptide.indexOf('AA')); // -1 (not found)
Checks if the polypeptide starts with the specified amino acid prefix
The amino acid prefix to check for (string or Polypeptide)
True if the sequence starts with the prefix, false otherwise
const polypeptide = new Polypeptide(mRNA); // sequence: 'MKGK'
console.log(polypeptide.startsWith('MK')); // true
console.log(polypeptide.startsWith('GK')); // false
A class representing a polypeptide. It has a sequence of amino acids and an mRNA sequence that contains the coding sequence. The constructor enforces validation, and all members are readonly. Therefore, all Polypeptide objects can only exist in a valid state.
Biologically accurate: Translation occurs from mature mRNA, not pre-mRNA or other RNA types.