I am working on phylogenetic tree generation. I used BioPython and ClustalW 2.x.x for this purpose. I have generate the tree using BioPython but when I try to generate tree using "MegaSoftware GUI" tool my tree does not matched with the output of MegaSoftware.
When I use "No. of difference" model then results are matched with biopython tree Like below image shown.
But whenever I choose "p-distance" model my results are not matched.
Output MegaSoftware using p-distance
Output BioPython
Here is my code for generating phylogenetic tree:
def conversion_fasta_dnd(clustalw, filepath, type, clustering, output, pwmatrix):
"""
ClustalW tool to conversion the file format.
:param clustalw: path of the executable programm.
:param filepath: path of `fasta` extension file.
:param type: dna, protein
:param clustering: upgma, nj
:param output: clustal, phylip, fasta
:param pwmatrix: blosum, pam, id
:return: dnd, aln (files)
"""
# esblish the full path to the clustalW program
clustalw_exe = clustalw
# check to make sure the program is there
assert os.path.isfile(clustalw_exe), "Clustal W executable missing"
# create the appropriate command line
clustalw_cline = ClustalwCommandline(clustalw_exe,
infile=filepath,
type=type,
clustering=clustering,
output=output,
pwmatrix=pwmatrix)
# print the command line
print(clustalw_cline)
# execute the command
stdout, stderr = clustalw_cline()
# This function draw the tree on image file
def simple_tree(filepath):
"""
Generate the simple tree image.
:param filepath: path of dnd file format.
"""
def get_label(leaf):
return leaf.name
file = filepath
tree = Phylo.read(file, 'newick')
Phylo.draw(tree, label_func=get_label, do_show=False, branch_labels=lambda c: c.branch_length)
# axis management
pylab.axis('on')
pylab.savefig(OUTPUT_IMAGE, format='png', bbox_inches='tight', dpi=100, bbox_extra_artists=[])
In above code I have used two things first BioPhython lib and the other is Clustal W for align the sequences.
Could you please clarify what p-distances are?
I only have these reference for p-distance:
I need to add p-distance model in my code, someone please help me out How can I do that.