// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
package org.forester.archaeopteryx;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Accession;
import org.forester.phylogeny.data.Annotation;
import org.forester.phylogeny.data.BinaryCharacters;
import org.forester.phylogeny.data.BranchWidth;
import org.forester.phylogeny.data.Distribution;
import org.forester.phylogeny.data.Event;
import org.forester.phylogeny.data.PhylogenyData;
+import org.forester.phylogeny.data.PhylogenyDataUtil;
import org.forester.phylogeny.data.Point;
import org.forester.phylogeny.data.PropertiesMap;
import org.forester.phylogeny.data.Property;
class NodePanel extends JPanel implements TreeSelectionListener {
- static final String DIST_ALTITUDE = "Altitude";
- static final String DIST_ALT_UNIT = "Altitude unit";
- static final String DIST_LONGITUDE = "Longitude";
- static final String DIST_LATITUDE = "Latitude";
- static final String DIST_GEODETIC_DATUM = "Geodetic datum";
- static final String DIST_DESCRIPTION = "Description";
- static final String DATE_UNIT = "Unit";
+ static final String BASIC = "Basic";
+ static final String BINARY_CHARACTERS = "Binary characters";
+ static final String CONFIDENCE = "Confidence";
+ static final String CONFIDENCE_TYPE = "type";
+ static final String DATE = "Date";
+ static final String DATE_DESCRIPTION = "Description";
static final String DATE_MAX = "Max";
static final String DATE_MIN = "Min";
+ static final String DATE_UNIT = "Unit";
static final String DATE_VALUE = "Value";
- static final String DATE_DESCRIPTION = "Description";
- static final String TAXONOMY_IDENTIFIER = "Identifier";
- static final String SEQ_ACCESSION = "Accession";
- static final String CONFIDENCE = "Confidence";
- static final String PROP = "Properties";
- static final String BINARY_CHARACTERS = "Binary characters";
- static final String REFERENCE = "Reference";
+ static final String DIST_ALT_UNIT = "Altitude unit";
+ static final String DIST_ALTITUDE = "Altitude";
+ static final String DIST_DESCRIPTION = "Description";
+ static final String DIST_GEODETIC_DATUM = "Geodetic datum";
+ static final String DIST_LATITUDE = "Latitude";
+ static final String DIST_LONGITUDE = "Longitude";
+ static final String DISTRIBUTION = "Distribution";
+ static final String EVENTS = "Events";
+ static final String EVENTS_DUPLICATIONS = "Duplications";
+ static final String EVENTS_GENE_LOSSES = "Gene losses";
+ static final String EVENTS_SPECIATIONS = "Speciations";
static final String LIT_REFERENCE = "Reference";
static final String LIT_REFERENCE_DESC = "Description";
static final String LIT_REFERENCE_DOI = "DOI";
- static final String DISTRIBUTION = "Distribution";
- static final String DATE = "Date";
- static final String EVENTS = "Events";
- static final String SEQUENCE = "Sequence";
- static final String TAXONOMY = "Taxonomy";
- static final String BASIC = "Basic";
- static final String TAXONOMY_SCIENTIFIC_NAME = "Scientific name";
- static final String SEQ_MOL_SEQ = "Mol seq";
- static final String SEQ_TYPE = "Type";
- static final String SEQ_LOCATION = "Location";
- static final String SEQ_SYMBOL = "Symbol";
- static final String SEQ_URI = "URI";
+ static final String NODE_BRANCH_COLOR = "Branch color";
static final String NODE_BRANCH_LENGTH = "Branch length";
static final String NODE_BRANCH_WIDTH = "Branch width";
- static final String NODE_BRANCH_COLOR = "Branch color";
static final String NODE_NAME = "Name";
- static final String TAXONOMY_URI = "URI";
- static final String TAXONOMY_RANK = "Rank";
- static final String TAXONOMY_SYNONYM = "Synonym";
- static final String TAXONOMY_COMMON_NAME = "Common name";
+ static final String PROP = "Properties";
+ static final String REFERENCE = "Reference";
+ static final String SEQ_ACCESSION = "Accession";
+ static final String SEQ_LOCATION = "Location";
+ static final String SEQ_MOL_SEQ = "Mol seq";
+ static final String SEQ_NAME = "Name";
+ static final String SEQ_SYMBOL = "Symbol";
+ static final String SEQ_GENE_NAME = "Gene name";
+ static final String SEQ_TYPE = "Type";
+ static final String SEQ_URI = "URI";
+ static final String SEQUENCE = "Sequence";
+ static final String TAXONOMY = "Taxonomy";
static final String TAXONOMY_AUTHORITY = "Authority";
static final String TAXONOMY_CODE = "Code";
- static final String SEQ_NAME = "Name";
- static final String EVENTS_GENE_LOSSES = "Gene losses";
- static final String EVENTS_SPECIATIONS = "Speciations";
- static final String EVENTS_DUPLICATIONS = "Duplications";
+ static final String TAXONOMY_COMMON_NAME = "Common name";
+ static final String TAXONOMY_IDENTIFIER = "Identifier";
+ static final String TAXONOMY_RANK = "Rank";
+ static final String TAXONOMY_SCIENTIFIC_NAME = "Scientific name";
+ static final String TAXONOMY_SYNONYM = "Synonym";
+ static final String TAXONOMY_URI = "URI";
private static final long serialVersionUID = 5120159904388100771L;
- static final String CONFIDENCE_TYPE = "type";
- private final JTree _tree;
private final JEditorPane _pane;
+ private final JTree _tree;
public NodePanel( final PhylogenyNode phylogeny_node ) {
String node_name = "";
add( split_pane );
}
+ @Override
+ public void valueChanged( final TreeSelectionEvent e ) {
+ // Do nothing.
+ }
+
private void expandPath( final String name ) {
final TreePath tp = getJTree().getNextMatch( name, 0, Position.Bias.Forward );
if ( tp != null ) {
return _tree;
}
- @Override
- public void valueChanged( final TreeSelectionEvent e ) {
- // Do nothing.
- }
-
private static void addAnnotation( final DefaultMutableTreeNode top, final Annotation ann, final String name ) {
DefaultMutableTreeNode category;
category = new DefaultMutableTreeNode( name );
top.add( category );
- addSubelement( category, REFERENCE, ann.getRef() );
- addSubelement( category, "Description", ann.getDesc() );
addSubelement( category, "Source", ann.getSource() );
addSubelement( category, "Type", ann.getType() );
addSubelement( category, "Evidence", ann.getEvidence() );
}
}
- private static void addUri( final DefaultMutableTreeNode top, final Uri uri, final String name ) {
- DefaultMutableTreeNode category;
- category = new DefaultMutableTreeNode( name );
- top.add( category );
- addSubelement( category, "Description", uri.getDescription() );
- addSubelement( category, "Type", uri.getType() );
- addSubelement( category, "URI", uri.getValue().toString() );
- }
-
private static void addAnnotations( final DefaultMutableTreeNode top,
final SortedSet<Annotation> annotations,
final DefaultMutableTreeNode category ) {
if ( ( annotations != null ) && ( annotations.size() > 0 ) ) {
category.add( new DefaultMutableTreeNode( "Annotations" ) );
final DefaultMutableTreeNode last = top.getLastLeaf();
- int i = 0;
- for( final PhylogenyData ann : annotations ) {
- addAnnotation( last, ( Annotation ) ann, "Annotation " + ( i++ ) );
- }
- }
- }
-
- private static void addUris( final DefaultMutableTreeNode top,
- final List<Uri> uris,
- final DefaultMutableTreeNode category ) {
- if ( ( uris != null ) && ( uris.size() > 0 ) ) {
- category.add( new DefaultMutableTreeNode( "URIs" ) );
- final DefaultMutableTreeNode last = top.getLastLeaf();
- int i = 0;
- for( final Uri uri : uris ) {
- if ( uri != null ) {
- addUri( last, uri, "URI " + ( i++ ) );
- }
+ for( final Annotation ann : annotations ) {
+ addAnnotation( last, ann, ann.asText().toString() );
}
}
}
final DefaultMutableTreeNode category = new DefaultMutableTreeNode( name );
top.add( category );
addSubelement( category, NODE_NAME, phylogeny_node.getName() );
- if ( phylogeny_node.getDistanceToParent() != PhylogenyNode.DISTANCE_DEFAULT ) {
+ if ( phylogeny_node.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
addSubelement( category,
NODE_BRANCH_LENGTH,
ForesterUtil.FORMATTER_6.format( phylogeny_node.getDistanceToParent() ) );
addSubelement( category, CONFIDENCE, conf.asText().toString() );
}
}
- if ( ( phylogeny_node.getBranchData().getBranchWidth() != null )
- && ( phylogeny_node.getBranchData().getBranchWidth().getValue() != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) ) {
- addSubelement( category,
- NODE_BRANCH_WIDTH,
- ForesterUtil.FORMATTER_3.format( phylogeny_node.getBranchData().getBranchWidth().getValue() ) );
- }
- if ( ( phylogeny_node.getBranchData().getBranchColor() != null ) ) {
- Color c = phylogeny_node.getBranchData().getBranchColor().getValue();
- addSubelement( category,
- NODE_BRANCH_COLOR,
- c.getRed() + ", " + c.getGreen() + ", "+ c.getBlue() );
- }
if ( !phylogeny_node.isExternal() ) {
addSubelement( category, "Children", String.valueOf( phylogeny_node.getNumberOfDescendants() ) );
addSubelement( category,
if ( no_tax > 0 ) {
addSubelement( category, "External nodes without taxonomy", String.valueOf( no_tax ) );
}
- //TODO remove me...
- for( final Taxonomy taxonomy : distinct_tax.keySet() ) {
- System.out.println( taxonomy + ": " + distinct_tax.get( taxonomy ) );
- }
}
}
if ( !phylogeny_node.isRoot() ) {
- addSubelement( category, "Depth", String.valueOf( PhylogenyMethods.calculateDepth( phylogeny_node ) ) );
- final double d = PhylogenyMethods.calculateDistanceToRoot( phylogeny_node );
+ addSubelement( category, "Depth", String.valueOf( phylogeny_node.calculateDepth() ) );
+ final double d = phylogeny_node.calculateDistanceToRoot();
if ( d > 0 ) {
addSubelement( category, "Distance to root", String.valueOf( ForesterUtil.FORMATTER_6.format( d ) ) );
}
}
+ if ( ( phylogeny_node.getBranchData().getBranchWidth() != null )
+ && ( phylogeny_node.getBranchData().getBranchWidth().getValue() != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) ) {
+ addSubelement( category,
+ NODE_BRANCH_WIDTH,
+ ForesterUtil.FORMATTER_3.format( phylogeny_node.getBranchData().getBranchWidth().getValue() ) );
+ }
+ if ( ( phylogeny_node.getBranchData().getBranchColor() != null ) ) {
+ final Color c = phylogeny_node.getBranchData().getBranchColor().getValue();
+ addSubelement( category, NODE_BRANCH_COLOR, c.getRed() + ", " + c.getGreen() + ", " + c.getBlue() );
+ }
}
private static void addBinaryCharacters( final DefaultMutableTreeNode top,
addSubelement( chars, "Present", bc.getPresentCharactersAsStringBuffer().toString() );
}
+ private static void addCrossReference( final DefaultMutableTreeNode top, final Accession x, final String name ) {
+ DefaultMutableTreeNode category;
+ category = new DefaultMutableTreeNode( name );
+ top.add( category );
+ }
+
+ private static void addCrossReferences( final DefaultMutableTreeNode top,
+ final SortedSet<Accession> xs,
+ final DefaultMutableTreeNode category ) {
+ if ( ( xs != null ) && ( xs.size() > 0 ) ) {
+ category.add( new DefaultMutableTreeNode( "Cross references" ) );
+ final DefaultMutableTreeNode last = top.getLastLeaf();
+ for( final Accession x : xs ) {
+ addCrossReference( last, x, x.asText().toString() );
+ }
+ }
+ }
+
private static void addDate( final DefaultMutableTreeNode top, final Date date, final String name ) {
DefaultMutableTreeNode category;
category = new DefaultMutableTreeNode( name );
addSubelement( category, DIST_DESCRIPTION, dist.getDesc() );
if ( ( dist.getPoints() != null ) && ( dist.getPoints().size() > 0 ) ) {
final Point p0 = dist.getPoints().get( 0 );
- if ( p0 != null ) {
+ if ( ( p0 != null ) && !Point.isSeemsEmpty( p0 ) ) {
addSubelement( category, DIST_GEODETIC_DATUM, p0.getGeodeticDatum() );
addSubelement( category, DIST_LATITUDE, String.valueOf( p0.getLatitude() ) );
addSubelement( category, DIST_LONGITUDE, String.valueOf( p0.getLongitude() ) );
}
}
+ private static void addLineage( final DefaultMutableTreeNode top,
+ final List<String> lineage,
+ final DefaultMutableTreeNode category ) {
+ if ( ( lineage != null ) && ( lineage.size() > 0 ) ) {
+ final StringBuilder sb = new StringBuilder();
+ for( final String lin : lineage ) {
+ if ( !ForesterUtil.isEmpty( lin ) ) {
+ sb.append( lin );
+ sb.append( " > " );
+ }
+ }
+ String str = null;
+ if ( sb.length() > 1 ) {
+ str = sb.substring( 0, sb.length() - 3 );
+ }
+ if ( !ForesterUtil.isEmpty( str ) ) {
+ addSubelement( category, "Lineage", str );
+ }
+ }
+ }
+
private static void addProperties( final DefaultMutableTreeNode top,
final PropertiesMap properties,
final String string ) {
top.add( category );
for( final String key : properties_map.keySet() ) {
final Property prop = properties_map.get( key );
- category.add( new DefaultMutableTreeNode( prop.getRef() + " " + prop.getValue() + " " + prop.getUnit()
+ category.add( new DefaultMutableTreeNode( prop.getRef() + "=" + prop.getValue() + " " + prop.getUnit()
+ " [" + prop.getAppliesTo().toString() + "]" ) );
}
}
top.add( category );
addSubelement( category, SEQ_NAME, seq.getName() );
addSubelement( category, SEQ_SYMBOL, seq.getSymbol() );
+ addSubelement( category, SEQ_GENE_NAME, seq.getGeneName() );
if ( seq.getAccession() != null ) {
addSubelement( category, SEQ_ACCESSION, seq.getAccession().asText().toString() );
}
addSubelement( category, SEQ_LOCATION, seq.getLocation() );
addSubelement( category, SEQ_TYPE, seq.getType() );
addSubelement( category, SEQ_MOL_SEQ, seq.getMolecularSequence() );
+ if ( ( seq.getAnnotations() != null ) && !seq.getAnnotations().isEmpty() ) {
+ addAnnotations( top, seq.getAnnotations(), category );
+ }
+ if ( ( seq.getCrossReferences() != null ) && !seq.getCrossReferences().isEmpty() ) {
+ addCrossReferences( top, seq.getCrossReferences(), category );
+ }
if ( ( seq.getUris() != null ) && !seq.getUris().isEmpty() ) {
addUris( top, seq.getUris(), category );
}
- addAnnotations( top, seq.getAnnotations(), category );
}
private static void addSubelement( final DefaultMutableTreeNode node, final String name, final String value ) {
if ( ( tax.getUris() != null ) && !tax.getUris().isEmpty() ) {
addUris( top, tax.getUris(), category );
}
+ if ( ( tax.getLineage() != null ) && !tax.getLineage().isEmpty() ) {
+ addLineage( top, tax.getLineage(), category );
+ }
+ }
+
+ private static void addUri( final DefaultMutableTreeNode top, final Uri uri, final String name ) {
+ DefaultMutableTreeNode category;
+ category = new DefaultMutableTreeNode( name );
+ top.add( category );
+ addSubelement( category, "Description", uri.getDescription() );
+ addSubelement( category, "Type", uri.getType() );
+ addSubelement( category, "URI", uri.getValue().toString() );
+ }
+
+ private static void addUris( final DefaultMutableTreeNode top,
+ final List<Uri> uris,
+ final DefaultMutableTreeNode category ) {
+ if ( ( uris != null ) && ( uris.size() > 0 ) ) {
+ category.add( new DefaultMutableTreeNode( "URIs" ) );
+ final DefaultMutableTreeNode last = top.getLastLeaf();
+ int i = 0;
+ for( final Uri uri : uris ) {
+ if ( uri != null ) {
+ addUri( last, uri, "URI " + ( i++ ) );
+ }
+ }
+ }
}
private static void createNodes( final DefaultMutableTreeNode top, final PhylogenyNode phylogeny_node ) {