rna_library.structure¶
Submodules¶
Package Contents¶
Classes¶
Abstract base class that |
|
Represents a helix or stack in an RNA structure. Inherits from |
|
Represents a hairpin loop in an RNA structure. Inherits from |
|
Represents a junction of any size in an RNA structure including bulges and multi-loops. |
|
Represents a single stranded region in an RNA structure. Does not include unpaired regions that are part of a |
|
Represents a |
Functions¶
|
Method takes a structure sequence pair and returns a root |
|
Figures out the highest id number in a given |
-
class
rna_library.structure.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.
-
-
class
rna_library.structure.Helix(**kwargs)¶ Bases:
rna_library.structure.motif.Motif
Represents a helix or stack in an RNA structure. Inherits from
Motif().-
size(self)¶ Returns the size of the
Helix()which is just the number of pairs in the stack.- Returns
size
- Return type
int
-
size(self, val)¶ Sets the current size for the
Helix().- Parameters
val (int) – the new size of the helix.
-
buffer(self)¶ Returns the buffer of the
Helix()which is just the number of pairs in the stack.- Returns
buffer
- Return type
int
-
pairs(self)¶ Returns the basepairs in the stack as a list of strings of length 2. Pairs are returned in order of lowest 3 prime starting index.
- Returns
pairs
- Return type
List[str]
-
recursive_structure(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
-
recursive_sequence(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
-
has_non_canonical(self)¶ Checks if any of the basepairs are non-canonical (i.e. non- AU/UA, GU/UG, GC/CG).
- Returns
has_non_canonical
- Return type
bool
-
-
class
rna_library.structure.Hairpin(**kwargs)¶ Bases:
rna_library.structure.motif.Motif
Represents a hairpin loop in an RNA structure. Inherits from
Motif().-
buffer(self)¶ For the
Hairpin()type, this is simply the size of the closing helix meaning the number of closing pairs.- Returns
buffer
- Return type
int
-
is_hairpin(self)¶ Indicates that the
Motif()is of typeHairpin().- Returns
is_hairpin
- Return type
bool
-
recursive_structure(self)¶ Returns the owned portion of the structure. In this coding of structure it is just the loop portion and does not include the closing pair.
- Returns
recursive_structure
- Return type
str
-
recursive_sequence(self)¶ Returns the owned portion of the sequence. In this coding of sequence it is just the loop portion and does not include the closing pair.
- Returns
recursive_sequence
- Return type
str
-
has_non_canonical(self)¶ Returns whether or not the closing pair is canonical (i.e. is AU/UA, CG/GC, GU/UG).
- Returns
has_non_canonical
- Return type
bool
-
-
class
rna_library.structure.Junction(**kwargs)¶ Bases:
rna_library.structure.motif.Motif
Represents a junction of any size in an RNA structure including bulges and multi-loops.
-
dms_active_idxs(self)¶
-
buffer(self)¶ For the
Junction()type this is alist()ofint()’s where the first is the size of the parentHelix()and then they are arranged in 3’ to 5’ order. Will have the same size as number of branches in theJucntion().- Returns
buffers
- Return type
List[int]
-
gaps(self)¶ Returns a
list()ofint()’s of gap sizes in 3’ to 5’ order. Will have the same size as number of branches in theJucntion().- Returns
gaps
- Return type
List[int]
-
is_junction(self)¶ Indicates that the
Motif()is of typeJunction().- Returns
is_hairpin
- Return type
bool
-
recursive_structure(self)¶ Returns the owned portion of the structure. In this coding of structure it is the closing pairs as well as the child
Helix()’s and their children.- Returns
recursive_structure
- Return type
str
-
recursive_sequence(self)¶ Returns the owned portion of the sequence. In this coding of structure it is the closing pairs as well as the child
Helix()’s and their children.- Returns
recursive_sequence
- Return type
str
-
closing_pairs(self)¶ Returns a
list()ofstr()’s that correspond to the closing pairs in theJunction()Motif.- Returns
closing_pairs
- Return type
List[str]
-
has_non_canonical(self)¶ Returns whether or not any of the closing pairs are non-canonical (i.e. not AU/UA, CG/GC, GU/UG).
- Returns
has_non_canonical
- Return type
bool
-
number_branches(self)¶ Returns the number of branches in the current
Junction().- Returns
number_branches
- Return type
int
-
symmetric(self)¶ Indicates if the current
Junction()is symmetric, that is the sizes of all of the gaps are the same.- Returns
is_symmetric
- Return type
bool
-
generate_sequences(self)¶ Would generate all possible sequences for the
Junction()that are compatible with the constraints for the motif. Not currently implemented.- Raises
TypeError
-
-
class
rna_library.structure.SingleStrand(**kwargs)¶ Bases:
rna_library.structure.motif.Motif
Represents a single stranded region in an RNA structure. Does not include unpaired regions that are part of a
Junction()orHelix().-
buffer(self)¶ For the
SingleStrand()type, this does not have any meaning and is always the value-1.- Returns
buffer
- Return type
int
-
is_singlestrand(self)¶ Indicates that the
Motif()is of typeSingleStrand().- Returns
is_singlestrand
- Return type
bool
-
recursive_structure(self)¶ Returns the owned portion of the structure. In this coding of structure it is just the nucleotides in the single strand plus its child if it exists.
- Returns
recursive_structure
- Return type
str
-
recursive_sequence(self)¶ Returns the owned portion of the sequence. In this coding of sequence it is just the nucleotides in the single strand plus its child if it exists.
- Returns
recursive_sequence
- Return type
str
-
has_non_canonical(self)¶ Because there are no pairs “owned” by
SingleStrand()’s, it always returnsFalse.- Returns
has_non_canonical
- Return type
bool
-
generate_sequences(self)¶ Generates all possible sequences for the
SingleStrand()that are compatible with the constraints for the motif.
-
-
rna_library.structure.parse_to_motifs(structure, sequence)¶ Method takes a structure sequence pair and returns a root
Motif()with a complete associated graph.- Parameters
structure (str) – a valid dot-bracket structure
sequence (str) – the corresponding sequence composed of the alphabet [ACGUTNB]
- Returns
motif
- Return type
-
class
rna_library.structure.SecStruct(secstruct, sequence)¶ Represents a
-
display(self)¶
-
property
sequence(self)¶
-
property
structure(self)¶
-
helix_replace_(self, id, secstruct, sequence)¶
-
motif_replace_(self, id, new_secstruct, new_sequence)¶
-
change_motif(self, id, new_secstruct, new_sequence)¶
-
get_sequence_structure(self)¶
-
_get_ids_internal(self, m, ids, mtype)¶
-
get_ids(self, motif_type)¶
-
get_substructure(self, id1, id2=None)¶
-
get(self, id)¶
-
__iter__(self)¶
-
itermotifs(self)¶
-
hairpins(self, **kwargs)¶
-
helix(self)¶
-
junctions(self)¶
-
singlestrands(self)¶
-
set_barcode(self, m_id, bc_seq)¶
-
__add__(self, other)¶
-