SDK reference

neurosnap.sequence.nucleotide

Python SDK 2026.11.05 · generated package reference

On this page

Provides functions and classes related to processing nucleotide data.

neurosnap.sequence.nucleotide.generate_random_rna_sequence(length=100, gc_content=50, *, add_start_codon=True, add_stop_codon=True, add_5_utr=False, add_3_utr=False, poly_a_tail_length=0, stem_loops=0, include_pseudouridine=False, rng=None)[source]#

Generate one RNA sequence with optional transcript-like features.

length includes all selected features. Randomized positions are adjusted toward the requested GC percentage; fixed codons, motifs, and poly-A can prevent the complete sequence from reaching that percentage.

Raises:

ValueError – If numeric settings are invalid or features exceed length.

Return type:

str

neurosnap.sequence.nucleotide.get_reverse_complement(seq)[source]#

Generate the complementary strand of a DNA or RNA sequence in reverse order.

Parameters:

seq (str) – A string representing the nucleotide sequence. Valid characters are ‘A’, ‘T’, ‘C’, ‘G’ for DNA and ‘A’, ‘U’, ‘C’, ‘G’ for RNA.

Returns:

A string representing the reverse complementary strand of the input sequence.

Return type:

str

Raises:

KeyError – If the input sequence contains invalid nucleotide characters.

neurosnap.sequence.nucleotide.interleave_fastq(fn_left, fn_right, output_dir, *, preserve_identifier_names=False)[source]#

Interleave matched R1/R2 FASTQ records into interleaved.fq.

Streams plain or gzip-compressed .fastq.gz/.fq.gz inputs, validating four-line records, sequence/quality lengths, matching identifiers, and equal nonzero record counts. Inputs must already have mates in the same order. Mate suffixes /1, /2, .1, and .2 are normalized for comparison.

Parameters:
  • fn_left (Union[str, Path]) – Forward (R1) FASTQ path.

  • fn_right (Union[str, Path]) – Reverse (R2) FASTQ path.

  • output_dir (Union[str, Path]) – Directory for the uncompressed interleaved FASTQ.

  • preserve_identifier_names (bool) – Preserve identifiers with normalized /1 and /2 suffixes; otherwise rewrite them as @<index>/1 and @<index>/2.

Return type:

Path

Returns:

Path to the interleaved FASTQ, with R1 followed by R2 for each pair.

Raises:

ValueError – If records are malformed, empty, unequal in count, or unpaired.

neurosnap.sequence.nucleotide.split_interleaved_fastq(fn_in, output_dir, *, preserve_identifier_names=False)[source]#

Split an interleaved FASTQ into left/right FASTQ files.

Assumes pairs are adjacent (left read followed by right read) and rewrites headers as “@<index>/1” and “@<index>/2”.

Supports gzip-compressed inputs with filenames ending in “.fastq.gz” or “.fq.gz”. Compression is detected by filename and streamed during read.

Parameters:
  • fn_in (Union[str, Path]) – Path to the interleaved FASTQ file.

  • output_dir (Union[str, Path]) – Directory to write outputs into.

  • preserve_identifier_names (bool) – If True, preserve the input read identifiers (normalizing mate suffix to “/1” or “/2”). If False, rewrite identifiers as “@<index>/1” and “@<index>/2”.

Returns:

Paths to the left and right FASTQ output files.

Return type:

Tuple[Path, Path]

Search documentation