pylogeny.alignment module

Object model defining a sequence alignment (DNA, RNA, protein sequences). Handle input biological sequence alignment files for the purposes of phylogenetic inference. Will read all types of alignment files by utilizing the P4 python phylogenetic library.

class pylogeny.alignment.alignment(inal=None)[source]

Bases: object

Wrap a biological sequence alignment to enable functionality necessary for phylogenetic inference. Makes use of temporary files; requires to be closed once no longer needed.

__init__(inal=None)[source]

Instantiate an object intended to wrap an alignment for the purposes of running phylogenetic inference.

Parameters:inal – An alignment file path (most formats are accepted).
close()[source]

Forcefully delete all temporary files and clear data.

getApproxMLNewick()[source]

Get a tree in newick format via use of FastTree that serves as an approximation of the maximum likelihood tree for this data.

Returns:a Newick or New Hampshire string
getApproxMLTree()[source]

Get a tree object for an approximation of the maximum likelihood tree for this data using FastTree.

Returns:a tree.tree object
getDataType()[source]

Get the data type associated with this alignment (e.g., protein).

Returns:a string indicating the data type (‘protein’, ‘DNA’)
getDim()[source]

Return the dimensionality of the sequence alignment (how many different types of characters).

Returns:an integer
getFASTA()[source]

Get (and create if not already) a path to a temporary FASTA file. This will be deleted upon closure of the alignment instance.

Returns:a string associated with a path in the file system
getNumSeqs()[source]

Return the number of sequences that are present in the sequence alignment.

Returns:an integer
getSequenceString(i)[source]

Acquire the ith sequence as a string.

Parameters:i (an integer) – an index in the alignment (associated with a sequence)
Returns:a string associated with the sequence
getSize()[source]

Return the size of the alignment, or how many characters there are in each respective item in the alignment.

Returns:an integer
getStateModel()[source]

Get the state model associated with this alignment. See model module for more information.

Returns:a model.DiscreteStateModel object
getTaxa()[source]

Get a list of taxa names associated with the alignment.

Returns:a list of strings
toStrList()[source]

Get all sequences as a list of strings.

Returns:a list of strings
class pylogeny.alignment.phylipFriendlyAlignment(inal=None)[source]

Bases: pylogeny.alignment.alignment

An alignment object that renames all comprising taxa in order to be able to be written as a strict Phylip file.

__init__(inal=None)[source]
convertOriginalNewick(tr)[source]

Return a Newick string with (original) taxa names that are replaced with the shortened forms as they are defined in this object.

Parameters:tr (a string) – a Newick string
Returns:a Newick string with all replaced names
getPhylip()[source]

Get (and create if not already) a path to a temporary Phylip file. This will be deleted upon closure of the alignment instance.

Returns:a string associated with a path in the file system
getProperName(n)[source]

Return the actual name for an integer-based sequence name that was reassigned at initialization.

Parameters:n (a string) – a shortened taxon name from this object
Returns:a string (replaced with the original taxon name)
getTaxa()[source]

Return current taxa names in the alignment.

Returns:a list of shortened taxa names
recreateObject()[source]

Reintializes the object.

reinterpretNewick(tr)[source]

Revert the replacing of taxa names with shortened names by changing them back to their original form.

Parameters:tr (a string) – a Newick string
Returns:a Newick string with all replaced names
writeProperNexus(wri)[source]

Write a Nexus file with proper names.

Parameters:wri (a string) – a path to a (existent or unexistent) file to write to

Previous topic

pylogeny.JSONWriter module

Next topic

pylogeny.base module

This Page