final static boolean __ALLOW_PHYLOGENETIC_INFERENCE = true;
public final static String PRG_NAME = "Archaeopteryx";
- final static String VERSION = "0.9914 test";
- final static String PRG_DATE = "160714";
+ final static String VERSION = "0.9915 test";
+ final static String PRG_DATE = "160727";
final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file";
final static String[] DEFAULT_FONT_CHOICES = {
"Arial Unicode MS", "Dialog", "SansSerif", "Sans", "Arial", "Helvetica" };
static final int MAX_TREES_TO_LOAD = 100;
final static float PDF_LINE_WIDTH_DEFAULT = 0.5f;
final static String APTX_WEB_SITE = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx";
+ final static String APTX_MAILING_LIST = "https://groups.google.com/forum/?fromgroups#!forum/archaeopteryx";
final static String APTX_DOC_SITE = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/documentation";
final static String PHYLOXML_WEB_SITE = ForesterConstants.PHYLO_XML_LOCATION;
final static String PHYLOXML_REFERENCE_URL = "http://www.biomedcentral.com/1471-2105/10/356/";
}
return false;
}
+
+ final static public boolean isHasNoBranchLengthSmallerThanZero( final Phylogeny phy ) {
+ final PhylogenyNodeIterator it = phy.iteratorPostorder();
+ while ( it.hasNext() ) {
+ final PhylogenyNode n = it.next();
+ if ( n.getDistanceToParent() < 0.0 && !n.isRoot() ) {
+ return false;
+ }
+ }
+ return true;
+ }
final static public boolean isHasAtLeastOneBranchWithSupportSD( final Phylogeny phy ) {
final PhylogenyNodeIterator it = phy.iteratorPostorder();
final ControlPanel cp ) {
if ( ( t != null ) && !t.isEmpty() ) {
final boolean has_bl = AptxUtil.isHasAtLeastOneBranchLengthLargerThanZero( t );
+
if ( !has_bl ) {
cp.setDrawPhylogram( false );
cp.setDrawPhylogramEnabled( false );
}
- else if ( cp.getDisplayAsPhylogramCb() != null ) {
- cp.setDrawPhylogramEnabled( true );
+ else {
+ final boolean has_all_bl = AptxUtil.isHasNoBranchLengthSmallerThanZero( t );
+ cp.setDrawPhylogram( has_all_bl );
+ if ( cp.getDisplayAsPhylogramCb() != null ) {
+ cp.setDrawPhylogramEnabled( true );
+ }
}
}
}
atv_control.setDrawPhylogram( false );
atv_control.setDrawPhylogramEnabled( false );
}
-
if ( t.getFirstExternalNode().getBranchData().getBranchColor() != null
&& atv_control.getUseVisualStylesCb() != null ) {
atv_control.getUseVisualStylesCb().setSelected( true );
if ( configuration.doGuessCheckOption( Configuration.display_as_phylogram ) ) {
if ( atv_control.getDisplayAsPhylogramCb() != null ) {
if ( has_bl ) {
- atv_control.setDrawPhylogram( true );
+ final boolean has_all_bl = AptxUtil.isHasNoBranchLengthSmallerThanZero( t );
+
+ atv_control.setDrawPhylogram( has_all_bl );
atv_control.setDrawPhylogramEnabled( true );
}
else {
updateOptions( getOptions() );
}
else if ( o == _about_item ) {
- MainFrame.about();
+ getMainPanel().getMainFrame().about();
}
else if ( o == _help_item ) {
try {
private boolean _line_up_renderable_node_data = true;
private boolean _right_align_domains = false;
private boolean _allow_thick_strokes = false;
+ private boolean _could_read_config_file = false;
static {
for( final String font_name : AptxConstants.DEFAULT_FONT_CHOICES ) {
if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
else {
config_filename = cf;
}
+ _could_read_config_file = false;
setDisplayColors( new TreeMap<String, Color>() );
config_filename = config_filename.trim();
URL u = null;
bf.close();
ForesterUtil.programMessage( AptxConstants.PRG_NAME, "successfully read from configuration url ["
+ config_filename + "]" );
+ _could_read_config_file = true;
}
catch ( final Exception e ) {
ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "failed to read configuration from ["
final BufferedReader bf = new BufferedReader( new FileReader( f ) );
readConfig( bf );
bf.close();
+ _could_read_config_file = true;
}
catch ( final Exception e ) {
if ( verbose ) {
static String getDefaultFontFamilyName() {
return DEFAULT_FONT_FAMILY;
}
+
+ public boolean isCouldReadConfigFile() {
+ return _could_read_config_file;
+ }
+
+
}
}
final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
for( final Sequence seq : sequenceRelationQueries ) {
- if ( seq.hasSequenceRelations() ) {
+ if ( seq.isHasSequenceRelations() ) {
boolean fFoundForCurrentType = false;
for( final SequenceRelation sq : seq.getSequenceRelations() ) {
if ( sq.getType().equals( relationType ) ) {
JMenuItem _about_item;
JMenuItem _help_item;
JMenuItem _website_item;
+ JMenuItem _mailing_list_item;
JMenuItem _phyloxml_website_item;
JMenuItem _phyloxml_ref_item;
JMenuItem _aptx_ref_item;
ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
}
}
+ else if ( o == _mailing_list_item ) {
+ try {
+ AptxUtil.openWebsite( AptxConstants.APTX_MAILING_LIST, is_applet, applet );
+ }
+ catch ( final IOException e1 ) {
+ ForesterUtil.printErrorMessage( AptxConstants.PRG_NAME, e1.toString() );
+ }
+ }
else if ( o == _phyloxml_website_item ) {
try {
AptxUtil.openWebsite( AptxConstants.PHYLOXML_WEB_SITE, is_applet, applet );
_help_jmenu.add( _help_item = new JMenuItem( "Documentation" ) );
_help_jmenu.addSeparator();
_help_jmenu.add( _website_item = new JMenuItem( "Archaeopteryx Home" ) );
+ _help_jmenu.add( _mailing_list_item = new JMenuItem( "Mailing List" ) );
_aptx_ref_item = new JMenuItem( "Archaeopteryx Reference" ); //TODO need to add this...
_help_jmenu.add( _phyloxml_website_item = new JMenuItem( "phyloXML Home" ) );
_help_jmenu.add( _phyloxml_ref_item = new JMenuItem( "phyloXML Reference" ) );
_help_jmenu.add( _about_item = new JMenuItem( "About" ) );
customizeJMenuItem( _help_item );
customizeJMenuItem( _website_item );
+ customizeJMenuItem( _mailing_list_item );
customizeJMenuItem( _phyloxml_website_item );
customizeJMenuItem( _aptx_ref_item );
customizeJMenuItem( _phyloxml_ref_item );
/**
* Display the about box.
*/
- static void about() {
+ void about() {
final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + AptxConstants.VERSION + "\n" );
about.append( "Copyright (C) 2016 Christian M Zmasek\n" );
about.append( "All Rights Reserved\n" );
about.append( "License: GNU Lesser General Public License (LGPL)\n" );
about.append( "Last modified: " + AptxConstants.PRG_DATE + "\n" );
about.append( "Based on: " + ForesterUtil.getForesterLibraryInformation() + "\n" );
+
+ if ( _configuration.isCouldReadConfigFile() ) {
+ about.append( "Using configuration file: " + _configuration.config_filename + "\n" );
+ }
+ else {
+ about.append( "Not using a configuration file\n" );
+ }
+
about.append( "phyloXML version : " + ForesterConstants.PHYLO_XML_VERSION + "\n" );
about.append( "phyloXML location: " + ForesterConstants.PHYLO_XML_LOCATION + "\n" );
if ( !ForesterUtil.isEmpty( ForesterUtil.JAVA_VERSION ) && !ForesterUtil.isEmpty( ForesterUtil.JAVA_VENDOR ) ) {
&& !node.getNodeData().getTaxonomy().getUris().isEmpty() ) {
final List<Uri> us = new ArrayList<Uri>();
for( final Taxonomy t : node.getNodeData().getTaxonomies() ) {
- for( final Uri uri : t.getUris() ) {
- us.add( uri );
+ if ( t.getUris() != null ) {
+ for( final Uri uri : t.getUris() ) {
+ us.add( uri );
+ }
}
}
for( final Uri uri : us ) {
color.setValue( new Color( red, green, blue ) );
}
else {
- color.setValue( new Color( red, green, blue ) );
+ color.setValue( new Color( red, green, blue, alpha ) );
}
return color;
}
public final PhylogenyNode getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() {
//TODO work on me ~~
- if ( isInternal() && !isCollapse() ) {
- throw new UnsupportedOperationException( "attempt to get next external node of an uncollapsed internal node" );
- }
if ( isRoot() ) {
return null;
}
+ if ( isInternal() && !isCollapse() ) {
+ throw new UnsupportedOperationException( "attempt to get next external node of an uncollapsed internal node" );
+ }
if ( getParent().isCollapse() ) {
throw new UnsupportedOperationException( "attempt to get next external node of node with a collapsed parent" );
}
/**
* Returns whether this PhylogenyNode should be drawn as collapsed.
+ * Root can not be collapsed.
*/
final public boolean isCollapse() {
- return _collapse;
+ return _collapse && _parent != null;
}
/**
public class Confidence implements PhylogenyData, Comparable<Confidence> {
- public final static int CONFIDENCE_DEFAULT_VALUE = -9999;
+ public final static int CONFIDENCE_DEFAULT_VALUE = -Integer.MAX_VALUE;
private double _value;
private double _sd;
private String _type;
public final class PhylogenyDataUtil {
- /** Value of -99.0 is used as default value. */
+ /** Value of -1024.0 is used as default value. */
public final static double BRANCH_LENGTH_DEFAULT = -1024.0;
public static void appendClose( final Writer w, final String element_name ) throws IOException {
return result;
}
- public boolean hasSequenceRelations() {
- return _seq_relations.size() > 0;
+ public boolean isHasSequenceRelations() {
+ return _seq_relations != null && _seq_relations.size() > 0;
}
public void init() {
System.out.println( "failed." );
failed++;
}
+ System.out.print( "phyloXML parsing (validating against schema): " );
+ if ( testPhyloXMLparsingValidating() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
System.out.println( "OK." );
}
return true;
}
+
+ private static boolean testPhyloXMLparsingValidating() {
+ try {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ PhyloXmlParser xml_parser = null;
+ try {
+ xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
+ }
+ catch ( final Exception e ) {
+ // Do nothing -- means were not running from jar.
+ }
+ if ( xml_parser == null ) {
+ xml_parser = PhyloXmlParser.createPhyloXmlParser();
+ if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
+ xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
+ }
+ else {
+ xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
+ }
+ }
+ final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_1.xml" ),
+ xml_parser );
+ if ( xml_parser.getErrorCount() > 0 ) {
+ System.out.println( xml_parser.getErrorMessages().toString() );
+ return false;
+ }
+ if ( phylogenies_0.length != 3 ) {
+ return false;
+ }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
private static boolean testBasicProtein() {
try {
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<phyloxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.phyloxml.org http://www.phyloxml.org/1.20/phyloxml.xsd"
+ xmlns="http://www.phyloxml.org">
+ <phylogeny branch_length_unit="c" rooted="true" rerootable="true" type="gene_tree">
+ <name>tree 0</name>
+ <id provider="treebank">1-1</id>
+ <description>test phylogeny</description>
+ <date>2002-05-30T09:00:00</date>
+ <confidence type="ml">0.999</confidence>
+ <confidence type="pp">0.955</confidence>
+ <clade branch_length="0.1" id_source="id111" collapse="true">
+ <name>root node</name>
+ <confidence type="bootstrap">90</confidence>
+ <confidence type="ml" stddev="1.1E-10">1e-3</confidence>
+ <confidence type="decay">2</confidence>
+ <width>10.5</width>
+ <color>
+ <red>2</red>
+ <green>22</green>
+ <blue>33</blue>
+ <alpha>123</alpha>
+ </color>
+ <taxonomy id_source="qwerty1">
+ <id provider="ncbi">1</id>
+ <code>ECDYS</code>
+ <scientific_name>ecdysozoa</scientific_name>
+ <authority>authority, 1999</authority>
+ <common_name>molting animals</common_name>
+ <synonym>Ecdy</synonym>
+ <synonym>The Ecdysozoa</synonym>
+ <rank>phylum</rank>
+ <uri type="img">http://www.molting.org/m.jpg</uri>
+ <uri type="source" desc="original source">http://www.ecdysozoa.org/</uri>
+ </taxonomy>
+ <taxonomy>
+ <id provider="ncbi">123</id>
+ <synonym>Æ Ä ä, ö and ü>– —</synonym>
+ <synonym>한글</synonym>
+ <synonym>日本語ひらがなカタカナ</synonym>
+ <synonym>русский алфавит</synonym>
+ <synonym>繁體字</synonym>
+ <synonym>ภาษาไทย</synonym>
+ <synonym>Tiếng Việt</synonym>
+ </taxonomy>
+ <sequence type="protein" id_source="idsource">
+ <symbol>BCL2L14</symbol>
+ <accession source="UniProtKB" comment="outdated">Q9BZR8</accession>
+ <name>Apoptosis facilitator Bcl-2-like 14 protein</name>
+ <gene_name>bcl2l14</gene_name>
+ <location>12p13-p12</location>
+ <mol_seq is_aligned="true">MCSTSGCDLEEIPLDDDDLNTIEFKILAYY</mol_seq>
+ <uri type="source" desc="UniProt link">http://www.pir.uniprot.org/cgi-bin/upEntry?id=B2L14_HUMAN</uri>
+ <annotation>
+ <desc>intracellular organelle</desc>
+ </annotation>
+ <annotation ref="GO:0005829"/>
+ <annotation ref="GO:0006915" source="UniProtKB" evidence="experimental" type="function">
+ <desc>apoptosis</desc>
+ <confidence type="ml" stddev="0.3">1</confidence>
+ <property datatype="xsd:double" applies_to="annotation" ref="AFFY:expression" unit="AFFY:x">0.2
+ </property>
+ <property datatype="xsd:string" applies_to="annotation" ref="MED:disease">lymphoma</property>
+ <uri type="source" desc="google">http://www.google.com</uri>
+ <uri type="source2" desc="bing">http://www.bing.com</uri>
+ </annotation>
+ <cross_references>
+ <accession source="UNIPROTKB">383</accession>
+ <accession source="PDB">1G5M</accession>
+ <accession source="KEGG">hsa:596</accession>
+ <accession source="PDB" comment="?">2G5M</accession>
+ </cross_references>
+ </sequence>
+ <sequence type="protein">
+ <symbol>BCL2</symbol>
+ </sequence>
+ <events>
+ <type>mixed</type>
+ <duplications>1</duplications>
+ <confidence type="bs">99</confidence>
+ </events>
+ <distribution>
+ <desc>irgendwo</desc>
+ <point geodetic_datum="WGS84" alt_unit="m">
+ <lat>35.9296730123456789</lat>
+ <long>-78.9482370123456789</long>
+ <alt>1303</alt>
+ </point>
+ <point geodetic_datum="WGS84" alt_unit="m">
+ <lat>129.549495485834893</lat>
+ <long>-78.00000000000000</long>
+ <alt>1400</alt>
+ </point>
+ </distribution>
+ <distribution>
+ <desc>anderswo</desc>
+ </distribution>
+ <date unit="MYA">
+ <desc>Silurian</desc>
+ </date>
+ <reference doi="10.1038/387489a0">
+ <desc>
+ Aguinaldo, A. M. A.; J. M. Turbeville, L. S. Linford, M. C. Rivera, J. R. Garey, R. A. Raff, &
+ J. A. Lake (1997). "Evidence for a clade of nematodes, arthropods and other moulting animals".
+ Nature 387 (6632): 489–493.
+ </desc>
+ </reference>
+ <reference doi="10.1036/59494">
+ </reference>
+ <property ref="F:foo" datatype="xsd:int" applies_to="clade">2</property>
+ <property ref="F:bar" datatype="xsd:int" applies_to="clade">33</property>
+ <clade>
+ <name>node a</name>
+ <branch_length>0.2</branch_length>
+ <color>
+ <red>12</red>
+ <green>14</green>
+ <blue>16</blue>
+ </color>
+ <taxonomy>
+ <id provider="ncbi">123</id>
+ <code>CAEEL</code>
+ <scientific_name>C elegans</scientific_name>
+ <common_name>elegant nematode worm</common_name>
+ <rank>species</rank>
+ <uri>http://www.wormbase.org/</uri>
+ </taxonomy>
+ <sequence id_source="xyz">
+ <name>CAEEL_XYZ</name>
+ </sequence>
+ <sequence id_source="abc">
+ <name>CAEEL_ABC</name>
+ </sequence>
+ <events>
+ <type>other</type>
+ <duplications>58</duplications>
+ <speciations>59403</speciations>
+ <losses>58485</losses>
+ <confidence type="p">0.9901</confidence>
+ </events>
+ </clade>
+ <clade>
+ <name>node b</name>
+ <events>
+ <duplications>1</duplications>
+ <confidence type="">80</confidence>
+ </events>
+ <binary_characters type="characters" present_count="2" lost_count="3" gained_count="1">
+ <gained>
+ <bc>c</bc>
+ </gained>
+ <lost>
+ <bc>d</bc>
+ <bc>e</bc>
+ <bc>f</bc>
+ </lost>
+ <present>
+ <bc>a</bc>
+ <bc>b</bc>
+ </present>
+ </binary_characters>
+ <clade>
+ <name>node ba</name>
+ <distribution>
+ <desc>Africa</desc>
+ </distribution>
+ <date unit="mya">
+ <desc>Silurian</desc>
+ <value>435</value>
+ <minimum>416</minimum>
+ <maximum>443.7</maximum>
+ </date>
+ </clade>
+ <clade collapse="false">
+ <name>node bb</name>
+ <taxonomy>
+ <id provider="EOL">704294</id>
+ <code>NEMVE</code>
+ <scientific_name>Nematostella vectensis</scientific_name>
+ <authority>Stephenson, 1935</authority>
+ <common_name>starlet sea anemone</common_name>
+ <synonym>Nematostella vectensis Stephenson1935</synonym>
+ <synonym>See
+ Anemone
+ </synonym>
+ <synonym></synonym>
+ <rank>species</rank>
+ <uri desc="EOL" type="linkout">http://www.eol.org/pages/704294</uri>
+ </taxonomy>
+ <binary_characters type="domains">
+ <gained>
+ <bc>A</bc>
+ <bc>B</bc>
+ <bc>C</bc>
+ </gained>
+ <lost>
+ <bc>D</bc>
+ </lost>
+ <present>
+ <bc>X</bc>
+ <bc>M</bc>
+ </present>
+ </binary_characters>
+ <date>
+ <desc>Triassic</desc>
+ </date>
+ </clade>
+ <clade>
+ <name>node bc</name>
+ <sequence>
+ <name>bc seq</name>
+ <domain_architecture length="124">
+ <domain from="120" to="130" confidence="0.9">A</domain>
+ <domain from="21" to="44" confidence="0" id="pfam">B</domain>
+ <domain to="43" confidence="1.0E-89" from="34" id="">C</domain>
+ <domain id="123" from="34" to="43" confidence="1.3e-34">D</domain>
+ </domain_architecture>
+ </sequence>
+ <events>
+ <speciations>1</speciations>
+ </events>
+ <date>
+ <value>433</value>
+ </date>
+ </clade>
+ </clade>
+ </clade>
+ <sequence_relation id_ref_0="abc" id_ref_1="xyz" distance="0.34" type="ultra_paralogy">
+ <confidence type="pp" stddev="1.1E-10">1e-3</confidence>
+ </sequence_relation>
+ <sequence_relation id_ref_0="xyz" id_ref_1="abc" distance="2" type="unknown">
+ <confidence type="pp" stddev="1.245836">99.0000001</confidence>
+ </sequence_relation>
+ <property datatype="xsd:double" applies_to="phylogeny" ref="TIME:time" unit="TIME:MYA">2</property>
+ <property datatype="xsd:string" applies_to="phylogeny" ref="GO:function">cell death</property>
+ </phylogeny>
+ <phylogeny rooted="true" rerootable="true">
+ <name>phylogeny2</name>
+ <clade>
+ <clade>
+ <name>A</name>
+ </clade>
+ <clade>
+ <name>B</name>
+ </clade>
+ </clade>
+ </phylogeny>
+ <phylogeny rooted="true" rerootable="true">
+ <name>phylogeny3</name>
+ <clade>
+ <clade id_source="i0">
+ <name>C</name>
+ </clade>
+ <clade id_source="i1">
+ <name>D</name>
+ </clade>
+ </clade>
+ <clade_relation id_ref_0="i0" id_ref_1="i1" distance="0.34" type="parent">
+ <confidence type="pp" stddev="1.1E-10">1e-3</confidence>
+ </clade_relation>
+ <clade_relation id_ref_0="i1" id_ref_1="i0" distance="2" type="child">
+ <confidence type="pp" stddev="1.1E-20">1e-4</confidence>
+ </clade_relation>
+ </phylogeny>
+</phyloxml>
\ No newline at end of file