dasi.models.alignment_container¶
Alignment container.
Functions
|
Converts a blast data result to a Region. |
Classes
|
Container for a set of query-to-subject alignments for a single query. |
|
Class that maintains a shared list of alignments and shared sequence database. |
Classes
|
Container for a set of query-to-subject alignments for a single query. |
|
Class that maintains a shared list of alignments and shared sequence database. |
Functions
|
Converts a blast data result to a Region. |
-
class
dasi.models.alignment_container.
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.
-
_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
-
class
dasi.models.alignment_container.
AlignmentContainerFactory
(seqdb)[source]¶ Bases:
object
Class that maintains a shared list of alignments and shared sequence database.
AlignmentContainers can be retrieved in a dict grouped by their query via .containers()
Construct a new AlignmentContainer.
- Parameters
seqdb (
Dict
[str
,SeqRecord
]) – a sequence record database
Attributes
Return dict of alignments keyed by query_key.
Methods
Return dictionary of AlignmentContainers keyed by query_keys.
load_blast_json
(data, atype)Create alignments from a formatted BLAST JSON result.
-
property
alignments
¶ Return dict of alignments keyed by query_key.
- Return type
frozendict
- Returns
-
containers
()[source]¶ Return dictionary of AlignmentContainers keyed by query_keys.
- Return type
Dict
[str
,AlignmentContainer
]- Returns
-
dasi.models.alignment_container.
blast_to_region
(query_or_subject, seqdb)[source]¶ Converts a blast data result to a Region. Blast results are indicated by two positions with index starting at 1 and positions being inclusive. This returns a Region with index starting at 0 and the end point position being exclusive.
- Parameters
query_or_subject (
dict
) –seqdb (
Dict
[str
,SeqRecord
]) –
- Returns
- Return type