rna_library.structure.motif¶
Motif classes that serve as the driver for this library’s functionality.
Module Contents¶
Classes¶
Abstract base class that |
Functions¶
|
Figures out the highest id number in a given |
-
class
rna_library.structure.motif.Motif(**kwargs)¶ Bases:
abc.ABC
Abstract base class that
Hairpin(),Helix(),Junction()andSingleStrand()all inherit from.-
link_children(self, depth=0)¶ Method used to link a
Motif()object to its children and vice versa. Should only be called once by the rootMotif().- Parameters
depth (int) – depth of the current
Motif()object. defaults to 0- Return type
None
-
__eq__(self, other)¶ Overloaded
==operator forMotif(). Requires that type of motif, sequence and token are identical.
-
__str__(self)¶ String representation of just the motif at hand.
-
is_helix(self)¶ If the motif is a helix or not. Overridden by child
Helix()class.- Returns
If the motif is of type
Helix()- Return type
bool()
-
is_singlestrand(self)¶ If the motif is a singlestrand or not. Overridden by child
SingleStrand()class.- Returns
If the motif is of type
SingleStrand()- Return type
bool()
-
is_hairpin(self)¶ If the motif is a hairpin or not. Overridden by child
Hairpin()class.- Returns
If the motif is of type
Hairpin()- Return type
bool
-
is_junction(self)¶ If the motif is a junction or not. Overridden by child
Junction()class.- Returns
If the motif is of type
Junction()- Return type
bool()
-
type(self)¶ Returns the
MotifType()type for the given motif.- Returns
The
MotifType()enum value for the given motif.- Return type
MotifType()
-
children(self)¶ Getter for the
Motif()’s child motifs. Returned as a list for iteration. Only returns direct children or an empty list if the motif has not children.
-
add_child(self, other)¶ Appends a new
Motif()to the internal list of children for the currentMotif().Warning
Should NOT be called directly. Other function calls must occur to ensure that the internal graph is accurate.
-
set_children(self, other)¶ Sets the entire list of Motif() to the internal list of children for the current
Motif().Warning
Should NOT be called directly. Other function calls must occur to ensure that the internal graph is accurate.
-
parent(self, other)¶
-
parent(self)¶ Gets the parent
Motif()’s for the currentMotif().- Returns
the parent motif
- Return type
-
token(self, tk)¶ Sets the
Motif()’s identifying token to an inputted string. Input is NOT validated.- Parameters
tk (str) – the new token for the
Motif().- Returns
None
- Return type
NoneType
-
structure(self, secstruct)¶ Sets the
Motif()’s structure to an inputted string. Input is NOT validated.- Parameters
tk (str) – the new structure for the
Motif().- Returns
None
- Return type
NoneType
-
strands(self)¶ Returns a list of list of
int()’ss where each sub list contains a contiguous set of nucleotides that “belong” to theMotif(). Output varies by motif type and the expected values are below:Hairpin()=> 1Helix()=> 2SingleStrand()=> 1Junction()=> number of branches inJunction()
- Returns
strands
- Return type
List[List[int]]
-
sequence(self)¶ Gets the sequence for the
Motif(). Because the nucleotides owned by theMotif()may not be contiguous, breaks will be separated by an ampersand ‘&’.- Returns
sequence
- Return type
str
-
sequence(self, seq)¶ Sets the sequence for the
Motif()to the supplied string. Warning the input NOT validated.- Parameters
seq (str) – the new sequence for the
Motif().
-
id(self, new_id)¶ Sets the id for the
Motif(). Warning: It is NOT currently validated.- Parameters
new_id (int) – the new id for the
Motif()- Returns
none
- Return type
NoneType
-
depth(self)¶ The depth of the
Motif(), which describes how deep it is in the internal graph.- Returns
depth
- Return type
int
-
depth(self, value)¶ Sets the depth of the current
Motif().- Parameters
value (int) – the new depth value for the current
Motif().
-
abstract
buffer(self)¶ Buffer refers to the size of the closest adjacent :motif:`Helix()`. Varies by type of motif as seen below:
Helix()=> size of the helix itselfHairpin()=> size of its parent helixSingleStrand()=> -1, meaningless in this contextJunction()=> alist()of the branching helices’ length with the parent helix going first the in the direction of increasing nucleotide index.
- Returns
buffer
- Return type
int
-
has_children(self)¶ Returns whether the
Motif()has any children.- Returns
has_children
- Return type
bool
-
abstract
recursive_sequence(self)¶ Builds and returns the continguous sequence of the structure viewing the current
Motif()as the root of the structure. The returned sequence will be part of the main sequence.- Returns
sequence
- Return type
str
-
abstract
recursive_structure(self)¶ Builds and returns the continguous structure of the structure viewing the current
Motif()as the root of the structure. The returned structure will be part of the main structure.- Returns
structure
- Return type
str
-
abstract
has_non_canonical(self)¶ Checks if the
Motif()has any non-canonical (i.e. non AU/UA, UG/GU or GC/CG) pairings.- Returns
has_nc
- Return type
bool
-
same_pattern(self, sequence)¶ Checks if a template sequence is compatible with an inputted sequence. Specifically if the length and placement of ‘&’ are the same.
- Parameters
sequence (str) – template string to compare against.
- Returns
is_same
- Return type
bool
-
start_pos(self)¶ Starting (or lowest) nucleotide index owned by the
Motif().- Returns
start_pos
- Return type
int
-
end_pos(self)¶ Ending (or highest) nucleotide index owned by the
Motif().- Returns
end_pos
- Return type
int
-
contains(self, pos)¶ Indicates if a nucleotide index is contained or belongs to the current
Motif().- Parameters
pos (list[int]) – the querying index
- Returns
is_contained
- Return type
bool
-
sequences(self, seqs)¶ Used to set the internal list of barcode temp sequences.
- Parameters
seqs (List[str]) – the new barcode sequences to be applied to the current
Motif().- Return type
None
-
number_sequences(self)¶ Gives the number of barcode sequences that the
Motif()currently has.- Returns
num_sequence
- Return type
int
-
set_sequence(self, idx)¶ Sets the current sequence to the sequence of the existing index from the internal barcodes list. Note that the Motif.number_sequences() method should be queried prior so that the index call will be known to be valid.
- Parameters
idx (int) – The index to be used.
- Return type
None
-
abstract
generate_sequences(self)¶ Builds out all possible barcode sequences that fit the known constraints.
-