else if ( p instanceof PhyloXmlParser ) {
MainFrameApplication.warnIfNotPhyloXmlValidation( conf );
}
- phylogenies = Util.readPhylogenies( p, f );
+ phylogenies = ForesterUtil.readPhylogenies( p, f );
if ( nhx_or_nexus && conf.isInternalNumberAreConfidenceForNhParsing() ) {
for( final Phylogeny phy : phylogenies ) {
ForesterUtil.transferInternalNodeNamesToConfidence( phy );
try {
final NHXParser nhx = new NHXParser();
setSpecialOptionsForNhxParser( nhx );
- phys = Util.readPhylogenies( nhx, file );
+ phys = ForesterUtil.readPhylogenies( nhx, file );
nhx_or_nexus = true;
}
catch ( final Exception e ) {
warnIfNotPhyloXmlValidation( getConfiguration() );
try {
final PhyloXmlParser xml_parser = createPhyloXmlParser();
- phys = Util.readPhylogenies( xml_parser, file );
+ phys = ForesterUtil.readPhylogenies( xml_parser, file );
}
catch ( final Exception e ) {
exception = true;
}
else if ( _open_filechooser.getFileFilter() == MainFrameApplication.tolfilter ) {
try {
- phys = Util.readPhylogenies( new TolParser(), file );
+ phys = ForesterUtil.readPhylogenies( new TolParser(), file );
}
catch ( final Exception e ) {
exception = true;
try {
final NexusPhylogeniesParser nex = new NexusPhylogeniesParser();
setSpecialOptionsForNexParser( nex );
- phys = Util.readPhylogenies( nex, file );
+ phys = ForesterUtil.readPhylogenies( nex, file );
nhx_or_nexus = true;
}
catch ( final Exception e ) {
else if ( parser instanceof PhyloXmlParser ) {
warnIfNotPhyloXmlValidation( getConfiguration() );
}
- phys = Util.readPhylogenies( parser, file );
+ phys = ForesterUtil.readPhylogenies( parser, file );
}
catch ( final Exception e ) {
exception = true;
if ( ( file != null ) && ( result == JFileChooser.APPROVE_OPTION ) ) {
if ( _open_filechooser_for_species_tree.getFileFilter() == MainFrameApplication.xmlfilter ) {
try {
- final Phylogeny[] trees = Util.readPhylogenies( new PhyloXmlParser(), file );
+ final Phylogeny[] trees = ForesterUtil.readPhylogenies( new PhyloXmlParser(), file );
t = trees[ 0 ];
}
catch ( final Exception e ) {
}
else if ( _open_filechooser_for_species_tree.getFileFilter() == MainFrameApplication.tolfilter ) {
try {
- final Phylogeny[] trees = Util.readPhylogenies( new TolParser(), file );
+ final Phylogeny[] trees = ForesterUtil.readPhylogenies( new TolParser(), file );
t = trees[ 0 ];
}
catch ( final Exception e ) {
// "*.*":
else {
try {
- final Phylogeny[] trees = Util.readPhylogenies( new PhyloXmlParser(), file );
+ final Phylogeny[] trees = ForesterUtil.readPhylogenies( new PhyloXmlParser(), file );
t = trees[ 0 ];
}
catch ( final Exception e ) {
import org.forester.io.parsers.PhylogenyParser;
import org.forester.io.parsers.tol.TolParser;
-import org.forester.io.parsers.util.PhylogenyParserException;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyNode;
System.out.println( "[" + name + "] > " + message );
}
- final static Phylogeny[] readPhylogenies( final PhylogenyParser parser, final File file ) throws IOException {
- final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final Phylogeny[] trees = factory.create( file, parser );
- if ( ( trees == null ) || ( trees.length == 0 ) ) {
- throw new PhylogenyParserException( "Unable to parse phylogeny from file: " + file );
- }
- return trees;
- }
-
final static Phylogeny[] readPhylogeniesFromUrl( final URL url, final boolean phyloxml_validate_against_xsd )
throws FileNotFoundException, IOException {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
static final boolean SECONDARY_FEATURES_ARE_SCOP = true;
static final String SECONDARY_FEATURES_SCOP_LINK = "http://scop.mrc-lmb.cam.ac.uk/scop/search.cgi?key=";
public static final String NONE = "[none]";
- public static final String UNIPROT_LINK = "http://beta.uniprot.org/taxonomy/?query=";
+ public static final String UNIPROT_LINK = "http://www.uniprot.org/taxonomy/?query=";
public static final String GO_LINK = "http://amigo.geneontology.org/cgi-bin/amigo/go.cgi?view=details&search_constraint=terms&query=";
public static final String EOL_LINK = "http://www.eol.org/search?q=";
public static final String TOL_LINK = "http://www.googlesyndicatedsearch.com/u/TreeofLife?q=";
--- /dev/null
+// $Id:
+//
+// forester -- software libraries and applications
+// for evolutionary biology research and applications.
+//
+// Copyright (C) 2008-2011 Christian M. Zmasek
+// Copyright (C) 2008-2011 Burnham Institute for Medical Research
+// 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.test.examples;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.forester.archaeopteryx.Archaeopteryx;
+import org.forester.io.parsers.PhylogenyParser;
+import org.forester.phylogeny.Phylogeny;
+import org.forester.util.ForesterUtil;
+
+public class Example1 {
+
+ public static void main( final String[] args ) {
+ // Reads in (a) tree(s) from a file.
+ final File treefile = new File( "/home/czmasek/tol_117_TEST.xml" );
+ PhylogenyParser parser = null;
+ try {
+ parser = ForesterUtil.createParserDependingOnFileType( treefile, true );
+ }
+ catch ( final IOException e ) {
+ e.printStackTrace();
+ }
+ Phylogeny[] phys = null;
+ try {
+ phys = ForesterUtil.readPhylogenies( parser, treefile );
+ }
+ catch ( final IOException e ) {
+ e.printStackTrace();
+ }
+ // Display of the tree(s) with Archaeopteryx.
+ Archaeopteryx.createApplication( phys );
+ }
+}
import org.forester.io.parsers.phyloxml.PhyloXmlParser;
import org.forester.io.parsers.phyloxml.PhyloXmlUtil;
import org.forester.io.parsers.tol.TolParser;
+import org.forester.io.parsers.util.PhylogenyParserException;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Identifier;
import org.forester.phylogeny.data.Sequence;
import org.forester.phylogeny.data.Taxonomy;
+import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
+import org.forester.phylogeny.factories.PhylogenyFactory;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
public final class ForesterUtil {
private ForesterUtil() {
}
+ public final static Phylogeny[] readPhylogenies( final PhylogenyParser parser, final File file ) throws IOException {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny[] trees = factory.create( file, parser );
+ if ( ( trees == null ) || ( trees.length == 0 ) ) {
+ throw new PhylogenyParserException( "Unable to parse phylogeny from file: " + file );
+ }
+ return trees;
+ }
+
final public static void appendSeparatorIfNotEmpty( final StringBuffer sb, final char separator ) {
if ( sb.length() > 0 ) {
sb.append( separator );