analyses.helpers package¶
Submodules¶
analyses.helpers.data_readers module¶
Module containing tools for reading alignment files in various formats.
Todo
FASTA reader?
-
exception
analyses.helpers.data_readers.
AlignmentIOError
[source]¶ Bases:
Exception
Wrapper class for alignment errors.
-
analyses.helpers.data_readers.
create_sequence_list_from_dict
(values_dict)[source]¶ Creates a list of sequences from a dictionary
- Parameters
values_dict (dict) – A dictionary of taxon name keys and a list of values for each value.
Note
The dictionary should have structure:
{ "{taxon_name}" : [{values}] }
- Returns
A list of Sequence objects and None for headers.
- Raises
AlignmentIOError – If a dictionary value is not a list.
-
analyses.helpers.data_readers.
get_character_matrix_from_sequences_list
(sequences, var_headers=None)[source]¶ Converts a list of sequences into a character matrix.
-
analyses.helpers.data_readers.
load_alignment_from_filename
(filename)[source]¶ Attempts to load an alignment from a file path by guessing schema
- Parameters
filename (str) – The file location containing the alignment
- Raises
RuntimeError – Raised with the method needed to load the alignment cannot be determined.
- Returns
Containing a list of sequences and headers
- Return type
-
analyses.helpers.data_readers.
read_csv_alignment_flo
(csv_flo)[source]¶ Reads a CSV file-like object and return a list of sequences and headers.
- Parameters
csv_flo (file-like) – A file-like object with CSV alignment data.
- Returns
A list of Sequence objects and headers.
- Raises
AlignmentIOError – If the number of columns is inconsistent across the sequences.
-
analyses.helpers.data_readers.
read_json_alignment_flo
(json_flo)[source]¶ Read a JSON file-like object and return a list of sequences and headers.
- Parameters
json_flo (file-like) – A file-like object with JSON alignment data.
Note
File should have structure:
{ "headers" : [{header_names}], "values" : [ { "name" : "{taxon_name}", "values" : [{values}] } ] }
- Returns
A list of Sequence objects and headers.
- Raises
AlignmentIOError – If headers are provided but they are not a list.
-
analyses.helpers.data_readers.
read_phylip_alignment_flo
(phylip_flo)[source]¶ Reads a phylip alignment file-like object and return the sequences.
- Parameters
phylip_flo (file-like) – The phylip file-like object.
Note
- We assume that the phylip files are extended and not strict (in terms
of how many characters for taxon names).
- The phylip file is in the format::
numoftaxa numofsites seqlabel sequence seqlabel sequence
- Returns
A list of Sequence objects.
- Raises
AlignmentIOError – If there is a problem creating sequences.
-
analyses.helpers.data_readers.
read_table_alignment_flo
(table_flo)[source]¶ Reads a table from a file-like object.
- Parameters
table_flo (file-like) – A file-like object containing table data.
- Returns
A list of Sequence objects.
- Raises
AlignmentIOError – If there is a problem creating sequences.
analyses.helpers.sequence module¶
Module containing sequence class.
-
class
analyses.helpers.sequence.
Sequence
(name='', seq='')[source]¶ Bases:
object
Barebones class for sequences.
This is a barebones class for sequences. These can be aligned or not and can be any type of alphabet.
-
set_cont_values
(values)[source]¶ Set the continuous values for the sequence.
- Parameters
values (list) – A list of values.
-