# DistanceMatrix¶

class DistanceMatrix

A container for distances between sequences (usually).

The numbers are in self.matrix, a self.dim * self.dim list of lists.

There is also a self.names attribute, which is usually for sequence names.

bionj()

Use bionj to make a neighbor-joining tree, which is returned.

The resulting tree is read in by p4, and is returned.

We interact with bionj by writing files, but care is taken that existing files are not overwritten, because new file names are made to be unique.

If the branch lengths are less than zero, they are made to be zero.

fastme()

Use fastme to make a minimum-evolution tree, which is returned.

The resulting tree is read in by p4, and is returned.

We interact with fastme by writing files, but care is taken that existing files are not overwritten, because new file names are made to be unique.

If the branch lengths are less than zero, they are made to be zero.

njUsingPaup(paupPath='paup')

Use paup to make a neighbor-joining tree, which is returned.

The resulting tree is read in by p4, and is returned.

We interact with paup by writing files, but care is taken that existing files are not overwritten, because new file names are made to be unique.

If this does not work well, try setting the paupPath arg.

readPhylipFile(theFileName)

Read a distance matrix in phylip format.

setDim(dim)
writeNexus(fName=None, writeTaxaBlock=1, append=0, digitsAfterDecimal=6)

Write out self in Nexus format.

If writeTaxaBlock=1, then a Taxa block is written before the Distances block. Append, if 0, writes #NEXUS first. If 1, does not write #NEXUS.

writeNexusToOpenFile(flob, writeTaxaBlock, append, digitsAfterDecimal)
writePhylip(fName=None, append=0, digitsAfterDecimal=6)

Write out self in Phylip format

writePhylipToOpenFile(flob, digitsAfterDecimal)