dasi.models.AlignmentContainer¶
-
class
dasi.models.
AlignmentContainer
(seqdb, alignments=None)[source]¶ Bases:
collections.abc.Sized
Container for a set of query-to-subject alignments for a single query.
- Instance Attributes/Properties:
- alignments list of alignments for the container
List[Alignment]
- seqdb key to SeqRecord dictionary
Dict[str, SeqRecord]
- logger the instance’s logger
Loggable
- This class contains:
Methods grouping alignments together according to those
- alignments that share the same starting and ending points.
Methods for ‘expanding’ alignments
Methods
A hashable representation of an alignment for grouping.
Create a new alignment group for a PCR product.
_make_subgroup
(group, a, b, atype)Make a subgroup at the specified indices.
Remove redundant alignments.
copy_groups
(alignment_groups, atype)Copy alignments from the list of groups to a new alignment type.
expand
([expand_overlaps, expand_primers, …])Alignment expansion algorithm.
expand_overlaps
(alignment_groups[, atype, …])Expand the list of alignments from existing regions.
expand_primer_pairs
(alignment_groups[, lim_size])Creates new alignments for all possible primer pairs.
find_groups_by_pos
(a, b, group_type[, groups])Return a list of groups that have the same positions (a, b) and same group_type.
freeze
()Freeze the container, disallowing further modifications to alignments.
get_groups_by_types
(types)Return AlignmentGroups by fragment type.
Return alignment groups according to their alignment ‘type’.
redundent_alignment_groups
(alignments)Return AlignmentGroups that have been grouped by alignment_hash.
unfreeze
()Unfreeze the container, allowing modifications to alignments.
Attributes
Return all valid types.
-
__init__
(seqdb, alignments=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(seqdb[, alignments])Initialize self.
expand
([expand_overlaps, expand_primers, …])Alignment expansion algorithm.
expand_overlaps
(alignment_groups[, atype, …])Expand the list of alignments from existing regions.
expand_primer_extension_products
([…])expand_primer_pairs
(alignment_groups[, lim_size])Creates new alignments for all possible primer pairs.
filter_alignments_by_span
(alignments, region)find_groups_by_pos
(a, b, group_type[, groups])Return a list of groups that have the same positions (a, b) and same group_type.
freeze
()Freeze the container, disallowing further modifications to alignments.
get_alignments_by_types
(types)- rtype
List
[Alignment
]
get_groups_by_types
(types)Return AlignmentGroups by fragment type.
groups
()- rtype
List
[Union
[AlignmentGroup
,MultiPCRProductAlignmentGroup
]]
Return alignment groups according to their alignment ‘type’.
pcr_alignment_groups
()redundent_alignment_groups
(alignments)Return AlignmentGroups that have been grouped by alignment_hash.
unfreeze
()Unfreeze the container, allowing modifications to alignments.
Attributes
alignments
Return all valid types.
valid_types
-
_create_pcr_product_alignment
(template_group, fwd, rev, alignment_type, lim_size)[source]¶ Create a new alignment group for a PCR product.
Situations the PCRProductAlignmentGroup represents: <-------- ------------------ ----> <-------- ------------------ --------> <----- ------------------ --------> <------ ------------------ -------->
- Parameters
template_group (
AlignmentGroup
) –fwd (
Optional
[Alignment
]) –rev (
Optional
[Alignment
]) –alignment_type (
str
) –
- Returns
-
_make_subgroup
(group, a, b, atype)[source]¶ Make a subgroup at the specified indices.
Returns None if a, b and the indices of the group.query_region or if a == b
- Return type
Optional
[AlignmentGroup
]
-
copy_groups
(alignment_groups, atype)[source]¶ Copy alignments from the list of groups to a new alignment type.
-
expand
(expand_overlaps=True, expand_primers=True, expand_primer_dimers=False, lim_size=True)[source]¶ Alignment expansion algorithm.
- Parameters
expand_overlaps – if True, expand overlaps
expand_primers – if True, expand primer pairs
expand_primer_dimers – if True, expand primer dimer pairs
lim_size (
bool
) – if True, limit the size of the alignment according to theri Molecule definitions
- Returns
None
-
expand_overlaps
(alignment_groups, atype='PCR_PRODUCT', lim_size=True, pass_condition=None, include_left=True)[source]¶ Expand the list of alignments from existing regions. Produces new fragments in the following two situations:
if `include_left` |--------| alignment 1 |--------| alignment 2 |---| new alignment |--------| alignment 1 |--------| alignment 2 |---| new alignment
- Parameters
alignment_groups (
List
[AlignmentGroup
]) – list of alignment groups to expandatype – the alignment type label for expanded alignments
lim_size (
bool
) – if True, only add alignments that pass the size limitationspass_condition (
Optional
[Callable
]) – an optional callable that takes group_a (AlignmentGroup) and group_b (AlignmentGroup). If the returned value is False, alignments are skipped.include_left (
bool
) – if True, will add overlapping region and the left region up to the overlap.
- Return type
List
[Alignment
]- Returns
list of new alignments
-
expand_primer_pairs
(alignment_groups, lim_size=True)[source]¶ Creates new alignments for all possible primer pairs. Searches for fwd and rev primer pairs that exist within other alignments and produces all combinations of alignments that can form from these primer pairs.
- Return type
List
[Alignment
]- Returns
list
-
find_groups_by_pos
(a, b, group_type, groups=None)[source]¶ Return a list of groups that have the same positions (a, b) and same group_type.
- Parameters
a (
int
) – starting positionb (
int
) – ending positiongroup_type (
str
) – group_typegroups – optional list of groups to search
- Return type
List
[Union
[AlignmentGroup
,PCRProductAlignmentGroup
]]- Returns
list of groups
-
get_groups_by_types
(types)[source]¶ Return AlignmentGroups by fragment type.
- Parameters
types (
List
[str
]) – list of types- Return type
Union
[AlignmentGroup
,List
[AlignmentGroup
]]- Returns
-
groups_by_type
()[source]¶ Return alignment groups according to their alignment ‘type’.
- Return type
Dict
[str
,List
[Union
[AlignmentGroup
,PCRProductAlignmentGroup
]]]- Returns
dict
-
classmethod
redundent_alignment_groups
(alignments)[source]¶ Return AlignmentGroups that have been grouped by alignment_hash.
- Parameters
alignments (
List
[Alignment
]) –- Return type
List
[AlignmentGroup
]- Returns
-
property
types
¶ Return all valid types.
- Return type
Tuple
[Any
, …]- Returns