The Maximum Agreement SubTree (MAST) metrics between two phylogenetic trees is the number of leaf(ves) to be pruned to obtain a maximum shared subtree (e.g. Goddard et al. 1994).
Given two NEWICK-formatted files $treefile1
and $treefile2
, each containing one unrooted phylogenetic tree on identical leaf set, the program _PAUP*_ could be used to compute the MAST distance between them. The following command lines write the required NEXUS-formatted input file $nexfile
and returns the MAST distance:
taxa=$(tr '(,' '\n' < $treefile1 | grep -o '^[^:)]*' | xargs echo);
echo -e "#NEXUS\nbegin taxa;dimensions ntax=$(echo $taxa | awk '{print NF}');taxlabels $taxa;end;\nbegin trees;tree 1=[&U]$(cat $treefile1)tree 2=[&U]$(cat $treefile2)end;\nbegin paup;treedist metric=agd1 fd=no;end" > $nexfile ;
paup -n $nexfile | grep "^2 .* -$" | awk '{print $2}' && rm $nexfile ;
When the two phylogenetic trees are rooted, the following command lines should be used:
taxa=$(tr '(,' '\n' < $treefile1 | grep -o '^[^:)]*' | xargs echo);
echo -e "#NEXUS\nbegin taxa;dimensions ntax=$(echo $taxa | awk '{print NF}');taxlabels $taxa;end;\nbegin trees;tree 1=[&R]$(cat $treefile1)tree 2=[&R]$(cat $treefile2)end;\nbegin paup;treedist metric=agd1 fd=no;end" > $nexfile ;
paup -n $nexfile | grep "^2 .* -$" | awk '{print $2}' && rm $nexfile ;