This package contains code necessary for running the quartet and projection
encodings from the paper

Koponen, L., Oikarinen, E., Janhunen, T., Säilä, L.:
'Optimizing Phylogenetic Supertrees Using Aswer Set Programming'
Theory and Practice of Logic Programming, 15(4-5):604-619.


This software package was originally published on
http://research.ics.aalto.fi/software/asp/



The package consists of the following parts

	1. sample trees
	2. download scripts for clasp and gringo
	3. files for the quartet encoding
	4. files for the projection encoding
	5. script to draw the supertrees in dot format.



1. Sample trees
---------------

Two files in Newick format:
	sample1.tree
	sample2.tree

These can be used as sample input for the scripts described below.



2. Download scripts
-------------------

Two .sh scripts:
	wget-clasp.sh
	wget-gringo.sh

When executed, these scripts will check if you already have the
clasp/gringo binary in the current folder, if not, they will try to
download it from SourceForge.

The scripts described below assume that clasp and gringo have been
installed in the current folder, but this can easily be changed in
execute_quartets.sh and execute_projections.sh.



3. Quartet encoding
-------------------

Quick execution:
	./execute_quartets.sh *.tree
where *.tree covers all of the tree files you wish to include.

The execution script is (sort of) self-documenting, but here's a summary.
There are two parts. The first part, generating the input quartets,
requires the following two files:
	newick_to_asp.py
	generate_quartets.lp

The Python script generates ASP rules out of the Newick trees. These and
the .lp file are then fed to gringo and clasp to get quartets (tagged with
the associated filename).

The second part requires the file supertree_from_quartets.lp and the input
quartets from the first part. These are simply fed to clasp and gringo. The
last answer is the optimum of the quartet encoding.



4. Projection encoding
----------------------

Quick-ish execution:
	./newick_to_projection.sh *.tree
where *.tree covers all of the tree files you wish to include. This part
generates new files containing the projections with ".lp" as the filename
extension.
	./execute_projections.sh sample1.lp sample2.lp
where the *.lp files are as generated by the previous script.

This script is less self-documenting, but basically the idea of it is that
the projections are transformed to the more general list format for
grounding.



5. Drawing script
-----------------

The output of either execute_quartets.sh or execute_projections.sh can be
piped into the draw.sh script. This script will output a graph in dot
notation (out of which an image file can then be generated).

The "filter" option tidies the tree up a bit (in terms of labels on the
inner nodes).

Example of use:
	./execute_projections.sh sample1.lp sample2.lp | ./draw.sh filter | dot -Tpng > proj-optimum.png
The above line would compute the optimal supertree for the given two input
trees and then generate a PNG picture depicting that tree.


