NucMSA

class NucMSA(sequences: ImmutableList<NucSeqRecord>) : MultipleSeqAlignment, Collection<NucSeqRecord>

Immutable multiple sequence alignment object, consisting of two or more NucSeqRecords with equal lengths. The data can then be regarded as a matrix of letters, with well defined columns. NucMSA also supports all read-only collection operations on the list of NucSeqRecords.

Please note while the Kotlin "x..y" range operator is supported, and works very similarly to Python's slice "x:y", y is inclusive here in Kotlin, and exclusive in Python.

Creating a NucMSA object: You will typically use Bio.AlignIO to read in alignments from files as NucMSA objects. You can also use Bio.Align to align sequences of uneven length and generate a MultipleSeqAlignment object.

You can also create a MultipleSeqAlignment object directly, with argument:

  • seqs - List of sequence records, required (type: ImmutableList or List)

@throws IllegalStateException if seqs has less than two elements, or if the sequence records in seqs are not all of the same length.

from Bio.Seq import Seq from Bio.Seq import NucSeqRecord from Bio.Seq import MultipleSeqAlignment val record_1 = NucSeqRecord(Seq("ATCG"), "1") val record_2 = NucSeqRecord(Seq("ATCC"), "2") val alignment = NucMSA(listOf(record_1, record_2))

Constructors

Link copied to clipboard
constructor(sequences: List<NucSeqRecord>)
constructor(sequences: ImmutableList<NucSeqRecord>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val size: Int

Functions

Link copied to clipboard

Returns the list of sequences in the NucMSA

Link copied to clipboard
open operator override fun contains(element: NucSeqRecord): Boolean
Link copied to clipboard
open override fun containsAll(elements: Collection<NucSeqRecord>): Boolean
Link copied to clipboard
open fun forEach(p0: Consumer<in NucSeqRecord>)
Link copied to clipboard
fun gappedSequence(sampleIdx: Int): NucSeq

Function to create a new NucSeq containing the sequence with all of the gaps for a given sampleIdx index. This allows for retrieval of sequence out of the NucSeq Note: this is 0 based.

Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open operator override fun iterator(): Iterator<NucSeqRecord>
Link copied to clipboard
fun nonGappedSequence(sampleIdx: Int): NucSeq

Function to create a new NucSeq removing the gaps from the sequence for a given sampleIdx index. This allows for retrieval of sequence out of the NucSeq Note: This is 0 based.

Link copied to clipboard

Returns the number of sequences in the alignment.

Link copied to clipboard
fun numSites(): Int

Returns the number of sites in the MSA. Because each SeqRecord has the same length, this can be used to further filter down the Seq objects.

Link copied to clipboard
Link copied to clipboard
fun sample(idx: Int): NucMSA

Returns the NucMSA with a single NucSeqRecord at the specified sample index idx with idx starting at zero. Negative indices start from the end of the sampleList, i.e. -1 is the last sample

Link copied to clipboard

Returns the list of sample names in the NucMSA

Link copied to clipboard
fun samples(filterLambda: (Int) -> Boolean): NucMSA

Function to filter the MSA by sample index based on the provided filterLambda. This will return another NucMSA. Note this will not work with negative indices

fun samples(sampleCollection: Collection<Any>): NucMSA

Function to return a NucMSA given a collection of both indices and sample names. Returns a subset of the NucSeqRecords in the NucMSA as a new NucMSA based on the provided indices and sample names. Note this will work with both positive and negative indices.

fun samples(range: IntRange): NucMSA

Returns a subset of the NucSeqRecords in the NucMSA as a NucMSA, based on the sample IntRange given. Kotlin range operator is "..". Indices start at zero. Note Kotlin IntRange are inclusive end, while Python slices exclusive end. Negative slices "-3..-1" start from the last base (i.e. would return the last three bases).

Link copied to clipboard
fun samplesByName(filterLambda: (String) -> Boolean): NucMSA

Function to filter the MSA by sample index based on the provided filterLambda. This will return another NucMSA.

Link copied to clipboard
fun sites(filterLambda: (Int) -> Boolean): NucMSA

Function to filter the NucMSA sites using a lambda function. This will return another NucMSA object Note this will not work with negative indices

fun sites(site: Int): NucMSA

Function to filter down a NucMSA at a single site. This will return another NucMSA

fun sites(siteIndices: Collection<Int>): NucMSA

Function to filter out the NucMSA based on a collection of siteIndices This Collection will first be Sorted and Duplicates removed so the resulting NucMSA's NucSeqs will be in the correct order. Note: This will work with negative indices.

fun sites(siteRange: IntRange): NucMSA

Function to slice the NucMSA by siteRange. This will return another NucMSA and does support negative indices

Link copied to clipboard
open override fun spliterator(): Spliterator<NucSeqRecord>
Link copied to clipboard
Link copied to clipboard
open fun <T : Any> toArray(p0: IntFunction<Array<T>>): Array<T>
Link copied to clipboard
open override fun toString(): String

Returns a string summary of the NucMSA.