2 package org.forester.archaeopteryx;
5 import java.awt.Component;
6 import java.io.UnsupportedEncodingException;
7 import java.net.URLEncoder;
8 import java.util.ArrayList;
9 import java.util.Collections;
10 import java.util.HashMap;
11 import java.util.HashSet;
12 import java.util.List;
14 import java.util.Map.Entry;
16 import java.util.SortedMap;
17 import java.util.SortedSet;
18 import java.util.TreeMap;
20 import javax.swing.JOptionPane;
22 import org.forester.analysis.TaxonomyDataManager;
23 import org.forester.phylogeny.Phylogeny;
24 import org.forester.phylogeny.PhylogenyMethods;
25 import org.forester.phylogeny.PhylogenyNode;
26 import org.forester.phylogeny.data.Accession;
27 import org.forester.phylogeny.data.Annotation;
28 import org.forester.phylogeny.data.BranchColor;
29 import org.forester.phylogeny.data.NodeDataField;
30 import org.forester.phylogeny.data.Sequence;
31 import org.forester.phylogeny.data.Taxonomy;
32 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
33 import org.forester.phylogeny.iterators.PreorderTreeIterator;
34 import org.forester.util.ForesterConstants;
35 import org.forester.util.ForesterUtil;
36 import org.forester.util.SequenceAccessionTools;
37 import org.forester.util.StringInt;
38 import org.forester.ws.seqdb.UniProtTaxonomy;
40 public class TreePanelUtil {
42 public final static String createUriForSeqWeb( final PhylogenyNode node,
43 final Configuration conf,
44 final TreePanel tp ) {
45 String uri_str = null;
46 final String upkb = SequenceAccessionTools.obtainUniProtAccessorFromDataFields( node );
47 if ( !ForesterUtil.isEmpty( upkb ) ) {
49 uri_str = ForesterUtil.UNIPROT_KB + URLEncoder.encode( upkb, ForesterConstants.UTF_8 );
51 catch ( final UnsupportedEncodingException e ) {
52 AptxUtil.showErrorMessage( tp, e.toString() );
56 if ( ForesterUtil.isEmpty( uri_str ) ) {
57 final String v = SequenceAccessionTools.obtainGenbankAccessorFromDataFields( node );
58 if ( !ForesterUtil.isEmpty( v ) ) {
60 if ( SequenceAccessionTools.isProteinDbQuery( v ) ) {
61 uri_str = ForesterUtil.NCBI_PROTEIN + URLEncoder.encode( v, ForesterConstants.UTF_8 );
64 uri_str = ForesterUtil.NCBI_NUCCORE + URLEncoder.encode( v, ForesterConstants.UTF_8 );
67 catch ( final UnsupportedEncodingException e ) {
68 AptxUtil.showErrorMessage( tp, e.toString() );
73 if ( ForesterUtil.isEmpty( uri_str ) ) {
74 final String v = SequenceAccessionTools.obtainRefSeqAccessorFromDataFields( node );
75 if ( !ForesterUtil.isEmpty( v ) ) {
77 if ( SequenceAccessionTools.isProteinDbQuery( v ) ) {
78 uri_str = ForesterUtil.NCBI_PROTEIN + URLEncoder.encode( v, ForesterConstants.UTF_8 );
81 uri_str = ForesterUtil.NCBI_NUCCORE + URLEncoder.encode( v, ForesterConstants.UTF_8 );
84 catch ( final UnsupportedEncodingException e ) {
85 AptxUtil.showErrorMessage( tp, e.toString() );
90 if ( ForesterUtil.isEmpty( uri_str ) ) {
91 final String v = SequenceAccessionTools.obtainGiNumberFromDataFields( node );
92 if ( !ForesterUtil.isEmpty( v ) ) {
94 uri_str = ForesterUtil.NCBI_GI + URLEncoder.encode( v, ForesterConstants.UTF_8 );
96 catch ( final UnsupportedEncodingException e ) {
97 AptxUtil.showErrorMessage( tp, e.toString() );
105 public static List<String> createUrisForPdbWeb( final PhylogenyNode node,
106 final List<Accession> pdb_accs,
107 final Configuration configuration,
108 final TreePanel treePanel ) {
109 final List<String> uris = new ArrayList<String>();
110 if ( !ForesterUtil.isEmpty( pdb_accs ) ) {
111 for( final Accession pdb_acc : pdb_accs ) {
112 if ( !ForesterUtil.isEmpty( pdb_acc.getValue() ) ) {
113 uris.add( ForesterUtil.PDB + pdb_acc.getValue() );
121 * Returns the set of distinct taxonomies of
122 * all external nodes of node.
123 * If at least one the external nodes has no taxonomy,
127 public static Set<Taxonomy> obtainDistinctTaxonomies( final PhylogenyNode node ) {
128 final List<PhylogenyNode> descs = node.getAllExternalDescendants();
129 final Set<Taxonomy> tax_set = new HashSet<Taxonomy>();
130 for( final PhylogenyNode n : descs ) {
131 if ( !n.getNodeData().isHasTaxonomy() || n.getNodeData().getTaxonomy().isEmpty() ) {
134 tax_set.add( n.getNodeData().getTaxonomy() );
139 public final static void showExtDescNodeDataUserSelectedHelper( final ControlPanel cp,
140 final PhylogenyNode node,
141 final List<String> data ) {
142 final StringBuilder sb = new StringBuilder();
143 if ( cp.isShowNodeNames() && !ForesterUtil.isEmpty( node.getName() ) ) {
144 TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getName(), sb );
146 if ( cp.isShowSeqNames() && node.getNodeData().isHasSequence()
147 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) ) {
148 TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getName(), sb );
150 if ( cp.isShowSeqSymbols() && node.getNodeData().isHasSequence()
151 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) ) {
152 TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getSymbol(),
155 if ( cp.isShowGeneNames() && node.getNodeData().isHasSequence()
156 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getGeneName() ) ) {
157 TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getGeneName(),
160 if ( cp.isShowSequenceAcc() && node.getNodeData().isHasSequence()
161 && ( node.getNodeData().getSequence().getAccession() != null )
162 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().toString() ) ) {
163 TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence().getAccession()
166 if ( cp.isShowTaxonomyCode() && node.getNodeData().isHasTaxonomy()
167 && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
169 .showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getTaxonomyCode(),
172 if ( cp.isShowTaxonomyScientificNames() && node.getNodeData().isHasTaxonomy()
173 && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) ) {
175 .showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getScientificName(),
178 if ( cp.isShowTaxonomyCommonNames() && node.getNodeData().isHasTaxonomy()
179 && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getCommonName() ) ) {
180 TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getCommonName(),
183 // if ( ( cp.isShowSeqNames() || cp.isShowSeqSymbols() || cp.isShowSequenceAcc() )
184 // && node.getNodeData().isHasSequence()
185 // && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
186 // TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence()
187 // .getMolecularSequence(), sb );
189 final String s = sb.toString().trim();
190 if ( !ForesterUtil.isEmpty( s ) ) {
195 public final static void showExtDescNodeDataUserSelectedHelperHelper( final String s, final StringBuilder sb ) {
196 if ( sb.length() > 0 ) {
202 final public static void showInformationMessage( final Component parent, final String title, final String msg ) {
203 JOptionPane.showMessageDialog( parent, msg, title, JOptionPane.INFORMATION_MESSAGE );
206 final static void collapseSpeciesSpecificSubtrees( final Phylogeny phy ) {
207 boolean inferred = false;
208 for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
209 iter.next().setCollapse( false );
211 for( final PhylogenyNodeIterator it = phy.iteratorPreorder(); it.hasNext(); ) {
212 final PhylogenyNode n = it.next();
213 if ( !n.isExternal() && !n.isCollapse() && ( n.getNumberOfDescendants() > 1 ) ) {
214 final Set<Taxonomy> taxs = TreePanelUtil.obtainDistinctTaxonomies( n );
215 if ( ( taxs != null ) && ( taxs.size() == 1 ) ) {
216 TreePanelUtil.collapseSubtree( n, true );
217 if ( !n.getNodeData().isHasTaxonomy() ) {
218 n.getNodeData().setTaxonomy( ( Taxonomy ) n.getAllExternalDescendants().get( 0 ).getNodeData()
219 .getTaxonomy().copy() );
224 n.setCollapse( false );
229 phy.setRerootable( false );
233 final static void collapseSubtree( final PhylogenyNode node, final boolean collapse ) {
234 node.setCollapse( collapse );
235 if ( node.isExternal() ) {
238 final PhylogenyNodeIterator it = new PreorderTreeIterator( node );
239 while ( it.hasNext() ) {
240 it.next().setCollapse( collapse );
244 final static void uncollapseSubtree( final PhylogenyNode node ) {
245 node.setCollapse( false );
246 if ( node.isExternal() ) {
249 final PhylogenyNodeIterator it = new PreorderTreeIterator( node );
250 while ( it.hasNext() ) {
251 it.next().setCollapse( false );
255 public static void colorizeSubtree( final PhylogenyNode node, final BranchColor c ) {
256 node.getBranchData().setBranchColor( c );
257 final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( node );
258 for( final PhylogenyNode desc : descs ) {
259 desc.getBranchData().setBranchColor( c );
263 final static void colorPhylogenyAccordingToConfidenceValues( final Phylogeny tree, final TreePanel tree_panel ) {
264 double max_conf = 0.0;
265 for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) {
266 final PhylogenyNode n = it.next();
267 n.getBranchData().setBranchColor( null );
268 if ( n.getBranchData().isHasConfidences() ) {
269 final double conf = PhylogenyMethods.getConfidenceValue( n );
270 if ( conf > max_conf ) {
275 if ( max_conf > 0.0 ) {
276 final Color bg = tree_panel.getTreeColorSet().getBackgroundColor();
277 final Color br = tree_panel.getTreeColorSet().getBranchColor();
278 for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) {
279 final PhylogenyNode n = it.next();
280 if ( n.getBranchData().isHasConfidences() ) {
281 final double conf = PhylogenyMethods.getConfidenceValue( n );
282 final BranchColor c = new BranchColor( ForesterUtil.calcColor( conf, 0.0, max_conf, bg, br ) );
283 TreePanelUtil.colorizeSubtree( n, c );
289 final static void colorPhylogenyAccordingToExternalTaxonomy( final Phylogeny tree, final TreePanel tree_panel ) {
290 for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) {
291 it.next().getBranchData().setBranchColor( null );
293 for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) {
294 final PhylogenyNode n = it.next();
295 if ( !n.getBranchData().isHasBranchColor() ) {
296 final Taxonomy tax = PhylogenyMethods.getExternalDescendantsTaxonomy( n );
299 .setBranchColor( new BranchColor( tree_panel.calculateTaxonomyBasedColor( tax ) ) );
300 final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( n );
301 for( final PhylogenyNode desc : descs ) {
303 .setBranchColor( new BranchColor( tree_panel.calculateTaxonomyBasedColor( tax ) ) );
310 // final static int collapseByTaxonomicRank( final Phylogeny tree, final String rank, final TreePanel tree_panel ) {
311 // final Set<String> true_lineage_set = new HashSet<String>();
312 // for( final PhylogenyNodeIterator iter = tree.iteratorPreorder(); iter.hasNext(); ) {
313 // iter.next().setCollapse( false );
315 // int collapsed = 0;
316 // for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
317 // final PhylogenyNode n = it.next();
318 // if ( !n.isExternal() && n.getNodeData().isHasTaxonomy() && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() )
319 // && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) /*&& !n.isRoot()*/ ) {
320 // TreePanelUtil.collapseSubtree( n, true );
322 // if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
323 // true_lineage_set.add( n.getNodeData().getTaxonomy().getScientificName() );
327 // for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
328 // final PhylogenyNode node = it.next();
329 // if ( ( !node.isExternal() && !node.isCollapse() ) && node.getNodeData().isHasTaxonomy()
330 // && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getLineage() ) /* && !node.isRoot()*/ ) {
331 // boolean success = false;
332 // if ( !true_lineage_set.isEmpty() ) {
333 // for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
334 // if ( true_lineage_set.contains( lin ) ) {
335 // TreePanelUtil.collapseSubtree( node, true );
343 // final Map<String, String> lineage_to_rank_map = MainPanel.getLineageToRankMap();
344 // for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
345 // final Taxonomy temp_tax = new Taxonomy();
346 // temp_tax.setScientificName( lin );
347 // if ( lineage_to_rank_map.containsKey( lin )
348 // && !ForesterUtil.isEmpty( lineage_to_rank_map.get( lin ) )
349 // && lineage_to_rank_map.get( lin ).equalsIgnoreCase( rank ) ) {
350 // TreePanelUtil.collapseSubtree( node, true );
352 // true_lineage_set.add( lin );
356 // UniProtTaxonomy up = null;
358 // up = TaxonomyDataManager.obtainUniProtTaxonomy( temp_tax, null, null );
360 // catch ( final Exception e ) {
361 // e.printStackTrace();
363 // if ( ( up != null ) && !ForesterUtil.isEmpty( up.getRank() ) ) {
364 // lineage_to_rank_map.put( lin, up.getRank() );
365 // System.out.println( lin + "->" + up.getRank() );
366 // if ( up.getRank().equalsIgnoreCase( rank ) ) {
367 // TreePanelUtil.collapseSubtree( node, true );
369 // true_lineage_set.add( lin );
381 final static int colorPhylogenyAccordingToRanks( final Phylogeny tree,
383 final TreePanel tree_panel ) {
384 final Map<String, Color> true_lineage_to_color_map = new HashMap<String, Color>();
385 int colorizations = 0;
386 for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
387 final PhylogenyNode n = it.next();
388 if ( n.getNodeData().isHasTaxonomy()
389 && ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() )
390 || !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() )
391 || !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) {
392 if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() )
393 && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) ) {
394 final BranchColor c = new BranchColor( tree_panel
395 .calculateTaxonomyBasedColor( n.getNodeData().getTaxonomy() ) );
396 TreePanelUtil.colorizeSubtree( n, c );
398 if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
399 true_lineage_to_color_map.put( n.getNodeData().getTaxonomy().getScientificName(),
405 for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
406 final PhylogenyNode node = it.next();
407 if ( ( node.getBranchData().getBranchColor() == null ) && node.getNodeData().isHasTaxonomy()
408 && !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getLineage() ) ) {
409 boolean success = false;
410 if ( !true_lineage_to_color_map.isEmpty() ) {
411 for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
412 if ( true_lineage_to_color_map.containsKey( lin ) ) {
413 TreePanelUtil.colorizeSubtree( node,
414 new BranchColor( true_lineage_to_color_map.get( lin ) ) );
422 final Map<String, String> lineage_to_rank_map = MainPanel.getLineageToRankMap();
423 for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
424 final Taxonomy temp_tax = new Taxonomy();
425 temp_tax.setScientificName( lin );
426 if ( lineage_to_rank_map.containsKey( lin )
427 && !ForesterUtil.isEmpty( lineage_to_rank_map.get( lin ) )
428 && lineage_to_rank_map.get( lin ).equalsIgnoreCase( rank ) ) {
429 final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( temp_tax ) );
430 TreePanelUtil.colorizeSubtree( node, c );
432 true_lineage_to_color_map.put( lin, c.getValue() );
436 UniProtTaxonomy up = null;
438 up = TaxonomyDataManager.obtainUniProtTaxonomy( temp_tax, null, null );
440 catch ( final Exception e ) {
443 if ( ( up != null ) && !ForesterUtil.isEmpty( up.getRank() ) ) {
444 lineage_to_rank_map.put( lin, up.getRank() );
445 System.out.println( lin + "->" + up.getRank() );
446 if ( up.getRank().equalsIgnoreCase( rank ) ) {
447 final BranchColor c = new BranchColor( tree_panel
448 .calculateTaxonomyBasedColor( temp_tax ) );
449 TreePanelUtil.colorizeSubtree( node, c );
451 true_lineage_to_color_map.put( lin, c.getValue() );
460 return colorizations;
463 final static String createAnnotationString( final SortedSet<Annotation> annotations,
464 final boolean show_ref_sources ) {
465 final SortedMap<String, List<Annotation>> m = new TreeMap<String, List<Annotation>>();
466 for( final Annotation an : annotations ) {
467 final String ref_source = ForesterUtil.isEmpty( an.getRefSource() ) ? "?" : an.getRefSource();
468 if ( !m.containsKey( ref_source ) ) {
469 m.put( ref_source, new ArrayList<Annotation>() );
471 m.get( ref_source ).add( an );
473 final StringBuilder sb = new StringBuilder();
474 for( final Entry<String, List<Annotation>> e : m.entrySet() ) {
475 final String ref_source = e.getKey();
476 final List<Annotation> ans = e.getValue();
477 if ( m.size() > 1 ) {
480 if ( show_ref_sources && !ref_source.equals( "?" ) ) {
481 sb.append( ref_source );
484 for( int i = 0; i < ans.size(); ++i ) {
485 final Annotation an = ans.get( i );
486 if ( !ForesterUtil.isEmpty( an.getRefValue() ) ) {
487 sb.append( an.getRefValue() );
490 if ( !ForesterUtil.isEmpty( an.getDesc() ) ) {
491 sb.append( an.getDesc() );
493 if ( sb.charAt( sb.length() - 1 ) == ' ' ) {
494 sb.deleteCharAt( sb.length() - 1 );
496 if ( i < ( ans.size() - 1 ) ) {
500 if ( m.size() > 1 ) {
504 return sb.toString();
507 final static String getPartAfterColon( final String s ) {
508 final int i = s.indexOf( ':' );
509 if ( ( i < 1 ) || ( i == ( s.length() - 1 ) ) ) {
512 return s.substring( i + 1, s.length() );
515 final static boolean isHasAssignedEvent( final PhylogenyNode node ) {
516 if ( !node.getNodeData().isHasEvent() ) {
519 if ( ( node.getNodeData().getEvent() ).isUnassigned() ) {
525 final static boolean isSequenceEmpty( final Sequence seq ) {
526 return ( seq.getAccession() == null ) && ForesterUtil.isEmpty( seq.getName() )
527 && ForesterUtil.isEmpty( seq.getGeneName() ) && ForesterUtil.isEmpty( seq.getSymbol() );
530 final static boolean isTaxonomyEmpty( final Taxonomy tax ) {
531 return ( ( tax.getIdentifier() == null ) && ForesterUtil.isEmpty( tax.getTaxonomyCode() )
532 && ForesterUtil.isEmpty( tax.getCommonName() ) && ForesterUtil.isEmpty( tax.getScientificName() )
533 && tax.getSynonyms().isEmpty() );
536 static final int nodeDataIntoStringBuffer( final List<String> data, final Options optz, final StringBuilder sb ) {
537 final SortedMap<String, Integer> map = new TreeMap<String, Integer>();
539 if ( ( optz.getExtDescNodeDataToReturn() != NodeDataField.SEQUENCE_MOL_SEQ_FASTA )
540 && ( optz.getExtDescNodeDataToReturn() != NodeDataField.GO_TERM_IDS ) ) {
541 for( final String d : data ) {
542 if ( !ForesterUtil.isEmpty( d ) ) {
543 if ( map.containsKey( d ) ) {
544 map.put( d, map.get( d ) + 1 );
551 if ( ( optz.getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_ALL )
552 || ( optz.getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN )
553 || ( optz.getExtDescNodeDataToReturn() == NodeDataField.SEQ_ANNOTATIONS ) ) {
554 final ArrayList<StringInt> sis = new ArrayList<StringInt>();
555 for( final Entry<String, Integer> e : map.entrySet() ) {
556 sis.add( new StringInt( e.getKey(), e.getValue() ) );
558 Collections.sort( sis, new StringInt.DescendingIntComparator() );
559 for( final StringInt si : sis ) {
560 sb.append( si.getString() );
562 sb.append( si.getInt() );
563 sb.append( ForesterUtil.LINE_SEPARATOR );
567 for( final Entry<String, Integer> e : map.entrySet() ) {
568 final String v = e.getKey();
569 final Object c = e.getValue();
573 sb.append( ForesterUtil.LINE_SEPARATOR );
579 for( final String d : data ) {
580 if ( !ForesterUtil.isEmpty( d ) ) {
582 sb.append( ForesterUtil.LINE_SEPARATOR );
590 final static String pdbAccToString( final List<Accession> accs, final int i ) {
591 if ( ForesterUtil.isEmpty( accs.get( i ).getComment() ) ) {
592 return accs.get( i ).getValue();
594 return accs.get( i ).getValue() + " (" + accs.get( i ).getComment().toLowerCase() + ")";
597 final static Phylogeny subTree( final PhylogenyNode new_root, final Phylogeny source_phy ) {
598 final Phylogeny new_phy = new Phylogeny();
599 new_phy.setRooted( true );
600 new_phy.setName( source_phy.getName() );
601 new_phy.setDescription( source_phy.getDescription() );
602 new_phy.setType( source_phy.getType() );
603 new_phy.setDistanceUnit( source_phy.getDistanceUnit() );
604 new_phy.setConfidence( source_phy.getConfidence() );
605 new_phy.setIdentifier( source_phy.getIdentifier() );
606 new_phy.setRoot( new_root.copyNodeDataShallow() );
608 for( final PhylogenyNode n : new_root.getDescendants() ) {
609 new_phy.getRoot().setChildNode( i++, n );