in progress (special coloring is still true)
[jalview.git] / forester / java / src / org / forester / archaeopteryx / NodeEditPanel.java
index a485376..f593a78 100644 (file)
@@ -21,7 +21,7 @@
 // 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;
 
@@ -60,6 +60,7 @@ import org.forester.phylogeny.data.Event;
 import org.forester.phylogeny.data.Identifier;
 import org.forester.phylogeny.data.MultipleUris;
 import org.forester.phylogeny.data.PhylogenyData;
+import org.forester.phylogeny.data.PhylogenyDataUtil;
 import org.forester.phylogeny.data.Point;
 import org.forester.phylogeny.data.Reference;
 import org.forester.phylogeny.data.Sequence;
@@ -153,7 +154,7 @@ class NodeEditPanel extends JPanel {
         top.add( category );
         addSubelementEditable( category, NodePanel.NODE_NAME, phylogeny_node.getName(), PHYLOXML_TAG.NODE_NAME );
         String bl = "";
-        if ( phylogeny_node.getDistanceToParent() != PhylogenyNode.DISTANCE_DEFAULT ) {
+        if ( phylogeny_node.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
             bl = ForesterUtil.FORMATTER_6.format( phylogeny_node.getDistanceToParent() );
         }
         addSubelementEditable( category, NodePanel.NODE_BRANCH_LENGTH, bl, PHYLOXML_TAG.NODE_BRANCH_LENGTH );
@@ -185,14 +186,11 @@ class NodeEditPanel extends JPanel {
                                PHYLOXML_TAG.CONFIDENCE_TYPE,
                                counter );
         String bw = "1";
-        if ( phylogeny_node.getBranchData().getBranchWidth() != null
-                && phylogeny_node.getBranchData().getBranchWidth().getValue() != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE
-        )
-        {
+        if ( ( phylogeny_node.getBranchData().getBranchWidth() != null )
+                && ( phylogeny_node.getBranchData().getBranchWidth().getValue() != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) ) {
             bw = ForesterUtil.FORMATTER_3.format( phylogeny_node.getBranchData().getBranchWidth().getValue() );
         }
         addSubelementEditable( category, NodePanel.NODE_BRANCH_WIDTH, bw, PHYLOXML_TAG.NODE_BRANCH_WIDTH );
-        
     }
 
     //    private void addAnnotation( final DefaultMutableTreeNode top, final Annotation ann, final String name ) {
@@ -339,6 +337,7 @@ class NodeEditPanel extends JPanel {
         }
         addSubelementEditable( category, NodePanel.SEQ_NAME, seq.getName(), PHYLOXML_TAG.SEQ_NAME );
         addSubelementEditable( category, NodePanel.SEQ_SYMBOL, seq.getSymbol(), PHYLOXML_TAG.SEQ_SYMBOL );
+        addSubelementEditable( category, NodePanel.SEQ_GENE_NAME, seq.getGeneName(), PHYLOXML_TAG.SEQ_GENE_NAME );
         addSubelementEditable( category,
                                NodePanel.SEQ_ACCESSION,
                                acc.getValue(),
@@ -654,7 +653,7 @@ class NodeEditPanel extends JPanel {
                 break;
             case NODE_BRANCH_LENGTH:
                 if ( ForesterUtil.isEmpty( value ) ) {
-                    getMyNode().setDistanceToParent( PhylogenyNode.DISTANCE_DEFAULT );
+                    getMyNode().setDistanceToParent( PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT );
                 }
                 else {
                     try {
@@ -679,7 +678,7 @@ class NodeEditPanel extends JPanel {
                     try {
                         final double bw = ForesterUtil.parseDouble( value );
                         if ( bw >= 0 ) {
-                            getMyNode().getBranchData().setBranchWidth( new BranchWidth(bw ) );
+                            getMyNode().getBranchData().setBranchWidth( new BranchWidth( bw ) );
                         }
                     }
                     catch ( final ParseException e ) {
@@ -690,7 +689,7 @@ class NodeEditPanel extends JPanel {
                         mtn.setUserObject( "" );
                     }
                 }
-                break;    
+                break;
             case CONFIDENCE_VALUE:
                 double confidence = Confidence.CONFIDENCE_DEFAULT_VALUE;
                 if ( !ForesterUtil.isEmpty( value ) ) {
@@ -716,7 +715,8 @@ class NodeEditPanel extends JPanel {
                 }
                 else {
                     final String type = getMyNode().getBranchData().getConfidences().get( number ).getType();
-                    getMyNode().getBranchData().getConfidences().set( number, new Confidence( confidence, type ) );
+                    final double sd = getMyNode().getBranchData().getConfidences().get( number ).getStandardDeviation();
+                    getMyNode().getBranchData().getConfidences().set( number, new Confidence( confidence, type, sd ) );
                 }
                 break;
             case CONFIDENCE_TYPE:
@@ -730,7 +730,8 @@ class NodeEditPanel extends JPanel {
                 }
                 else {
                     final double v = getMyNode().getBranchData().getConfidences().get( number ).getValue();
-                    getMyNode().getBranchData().getConfidences().set( number, new Confidence( v, value ) );
+                    final double sd = getMyNode().getBranchData().getConfidences().get( number ).getStandardDeviation();
+                    getMyNode().getBranchData().getConfidences().set( number, new Confidence( v, value, sd ) );
                 }
                 break;
             case TAXONOMY_CODE:
@@ -825,7 +826,7 @@ class NodeEditPanel extends JPanel {
                 break;
             case SEQ_MOL_SEQ:
                 ForesterUtil.ensurePresenceOfSequence( getMyNode() );
-                getMyNode().getNodeData().getSequence().setMolecularSequence( value );
+                getMyNode().getNodeData().getSequence().setMolecularSequence( value.replaceAll( "[^a-zA-Z-]", "" ) );
                 break;
             case SEQ_NAME:
                 ForesterUtil.ensurePresenceOfSequence( getMyNode() );
@@ -841,6 +842,10 @@ class NodeEditPanel extends JPanel {
                     break;
                 }
                 break;
+            case SEQ_GENE_NAME:
+                ForesterUtil.ensurePresenceOfSequence( getMyNode() );
+                getMyNode().getNodeData().getSequence().setGeneName( value );
+                break;
             case SEQ_TYPE:
                 ForesterUtil.ensurePresenceOfSequence( getMyNode() );
                 try {
@@ -1062,6 +1067,7 @@ class NodeEditPanel extends JPanel {
         TAXONOMY_URI,
         SEQ_SYMBOL,
         SEQ_NAME,
+        SEQ_GENE_NAME,
         SEQ_LOCATION,
         SEQ_TYPE,
         SEQ_MOL_SEQ,