Skip to main content
Random Nucleotide Mutation
License: Random Nucleotide Sampling is open source and free for academic and commercial use under an Apache-2.0 license. Please refer to the license for full terms.

This generator is open source. Any third-party models, product names, or trademarks referenced are the property of their respective owners, and Proto is not affiliated with them.


Go to Tool Page
proto-bio/proto-language/proto_language/generator/random_nucleotide_generator.py
View source
Nucleotide sequence generator that introduces random mutations. This generator creates sequence diversity by randomly mutating masked positions in DNA or RNA sequences. Nucleotide selection is controlled by the IUPAC substitution scheme, allowing targeted mutation strategies (e.g., transitions only with "R"/"Y", or any base with "N"). The generator category is "mutation". When the assigned segment has a starting sequence (or an upstream optimizer stage has populated proposals), masking_strategy controls which positions are mutated on each call. When the segment has no starting sequence, the first sample() call fills each proposal with a fully random sequence of the segment’s length using the configured substitution_scheme; subsequent calls then apply masking_strategy normally.

API Reference

ConfigRandomNucleotideGeneratorConfig Source
Configuration object for RandomNucleotideGenerator.This class defines configuration parameters for the random nucleotide generator, which introduces random nucleotide mutations at masked positions using IUPAC ambiguity code-based sampling.
masking_strategy
MaskingStrategy
Controls which positions to mask for sampling. Default: random 30%.
substitution_scheme
enum
default:"N"
IUPAC code defining the nucleotide substitution pool.Options: N, R, Y, S, W, K, M, B, D, H, V

Usage

python
>>> from proto_language.generator import RandomNucleotideGenerator, RandomNucleotideGeneratorConfig
>>> from proto_language.core import Segment
>>> config = RandomNucleotideGeneratorConfig(
...     masking_strategy=MaskingStrategy(num_mutations=2),
... )
>>> gen = RandomNucleotideGenerator(config)
>>> segment = Segment(length=100, sequence_type="dna")
>>> gen.assign(segment)
>>> gen.sample()  # First call: random init (no starting sequence)
>>> gen.sample()  # Second call onward: 2 random nucleotide mutations

Metadata

PropertyValue
Keyrandom-nucleotide
ClassRandomNucleotideGenerator
Categorymutation
Input Typestarting_sequence
Uses GPUFalse
Supported Sequence Typesdna, rna
Allows Empty StartTrue