// $Id:
// FORESTER -- software libraries and applications
// for evolutionary biology research and applications.
//
// Copyright (C) 2008-2009 Christian M. Zmasek
// Copyright (C) 2008-2009 Burnham Institute for Medical Research
// Copyright (C) 2000-2001 Washington University School of Medicine
// and Howard Hughes Medical Institute
// All rights reserved
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
// WWW: www.phylosoft.org/forester
package org.forester.application;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import org.forester.io.parsers.phyloxml.PhyloXmlParser;
import org.forester.io.writers.PhylogenyWriter;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
import org.forester.phylogeny.factories.PhylogenyFactory;
import org.forester.sdi.SDIException;
import org.forester.sdi.SDIR;
import org.forester.sdi.SDIse;
import org.forester.util.ForesterUtil;
/*
* Allows to infer duplications - speciations on all (rooted or unrooted) gene
* trees in a directory by using method "infer" of class SDIunrooted.
The
* output of this is a (re)rooted tree with speciation - duplication assigned
* for each tree (in "gene tree directory" with suffix "suffix for gene trees"),
* as well as a summary list ("outputfile name").
The summary list contains
* the following. The number in brackets indicates how many external nodes of
* the gene tree had to be removed since the associated species was not found in
* the species tree. "en" indicates the number of external nodes in the
* resulting (analyzed and returned) gene tree. "d" are the number of
* duplications, "L=" the mapping cost, "h=" the height, "d=" the minimal
* difference in tree heights (of the two subtrees at the root; this number is
* 0.0 for a midpoint rooted tree) of the resulting, analyzed and rooted gene
* tree(s).
The output file ending with "_Sdist" is a file which lists the
* distribution of trees sizes, "_Ddist" lists the distribution of the sums of
* duplications (up to a certain maximal size, set with final variables
* MAX_EXT_NODE_DIST and MAX_DUP_DIST).
*
* @see SDIunrooted
*
* @author Christian M. Zmasek
*/
public class sdi_dir {
final static private String E_MAIL = "czmasek@burnham.org";
final static private String WWW = "www.phylosoft.org";
final static private String PRG_NAME = "sdi_dir";
final static private String PRG_VERSION = "2.00";
final static private String PRG_DATE = "2010.04.26";
private static void errorInCommandLine() {
System.out.println( "\nsdi_dir: Error in command line.\n" );
System.out.print( "Usage: % sdi_dir [-options] " );
System.out.println( "