utils ===== .. py:module:: utils Attributes ---------- .. autoapisummary:: utils.ALL_CODONS utils.CODON_TABLE utils.CODON_TO_IDX utils.IDX_TO_CODON utils.N_CODONS utils.STOP_CODONS utils.codon_gc_counts Functions --------- .. autoapisummary:: utils.compute_cai utils.compute_gc_content_vectorized utils.compute_mfe_energy utils.compute_reward utils.compute_reward_components utils.decode_sequence utils.get_synonymous_indices utils.load_config utils.plot_training_curves utils.to_mRNA_string utils.tokenize_sequence_to_tensor Module Contents --------------- .. py:data:: ALL_CODONS :type: List[str] .. py:data:: CODON_TABLE :type: Dict[str, List[str]] .. py:data:: CODON_TO_IDX :type: Dict[str, int] .. py:data:: IDX_TO_CODON :type: Dict[int, str] .. py:data:: N_CODONS :type: int .. py:data:: STOP_CODONS :type: List[str] :value: ['UAA', 'UAG', 'UGA'] .. py:data:: codon_gc_counts .. py:function:: compute_cai(indices, energies=None, loop_min=4) Compute CAI using the CAICalculator. .. py:function:: compute_gc_content_vectorized(indices, codon_gc_counts) Vectorized GC content calculation using precomputed codon GC counts .. py:function:: compute_mfe_energy(indices, energies=None, loop_min=4) Compute the minimum free energy (MFE) of an RNA sequence using Zucker Algorithm. .. py:function:: compute_reward(state, codon_gc_counts, weights) Compute the total weighted reward and its components: reward = w1 * GC + w2 * (-MFE) + w3 * CAI .. py:function:: compute_reward_components(state, codon_gc_counts) Compute GC content, MFE, and CAI for a given RNA tensor state. .. py:function:: decode_sequence(tensor_seq) .. py:function:: get_synonymous_indices(amino_acid) Return the list of global codon indices that encode the given amino acid. Handles standard amino acids and '*'. .. py:function:: load_config(path) .. py:function:: plot_training_curves(loss_history, reward_components, out_path='training_curves.png') .. py:function:: to_mRNA_string(rna_tensor) .. py:function:: tokenize_sequence_to_tensor(seq)