import org.forester.io.parsers.util.ParserUtils;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
+import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Accession;
import org.forester.phylogeny.data.BranchColor;
if ( midpoint_reroot ) {
for( final Phylogeny phy : phys ) {
PhylogenyMethods.midpointRoot( phy );
+ PhylogenyMethods.orderAppearance( phy.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
}
}
return phys;
import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
+import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
import org.forester.phylogeny.data.SequenceRelation;
import org.forester.sdi.GSDI;
import org.forester.sdi.GSDIR;
result_gene_tree.setRerootable( false );
result_gene_tree.clearHashIdToNodeMap();
result_gene_tree.recalculateNumberOfExternalDescendants( true );
+ PhylogenyMethods.orderAppearance( result_gene_tree.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
_mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
getMainPanel().getControlPanel().setShowEvents( true );
showWhole();
public final static boolean __SYNTH_LF = false; // TODO remove me
public final static boolean ALLOW_DDBJ_BLAST = false;
public final static String PRG_NAME = "Archaeopteryx";
- final static String VERSION = "0.9807 A1ST";
- final static String PRG_DATE = "130311";
+ final static String VERSION = "0.9808 A1ST";
+ final static String PRG_DATE = "130312";
final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file";
final static String[] DEFAULT_FONT_CHOICES = { "Verdana", "Tahoma",
"Arial", "Helvetica", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" };
import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
+import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
import org.forester.phylogeny.data.Annotation;
result_gene_tree.setRerootable( false );
result_gene_tree.clearHashIdToNodeMap();
result_gene_tree.recalculateNumberOfExternalDescendants( true );
+ PhylogenyMethods.orderAppearance( result_gene_tree.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
_mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
getMainPanel().getControlPanel().setShowEvents( true );
showWhole();
}
/**
- * Places the root of this Phylogeny on Branch b. The new root is always
- * placed on the middle of the branch b.
- *
- */
- public void reRoot( final PhylogenyBranch b ) {
- final PhylogenyNode n1 = b.getFirstNode();
- final PhylogenyNode n2 = b.getSecondNode();
- if ( n1.isExternal() ) {
- reRoot( n1 );
- }
- else if ( n2.isExternal() ) {
- reRoot( n2 );
- }
- else if ( ( n2 == n1.getChildNode1() ) || ( n2 == n1.getChildNode2() ) ) {
- reRoot( n2 );
- }
- else if ( ( n1 == n2.getChildNode1() ) || ( n1 == n2.getChildNode2() ) ) {
- reRoot( n1 );
- }
- else if ( ( n1.getParent() != null ) && n1.getParent().isRoot()
- && ( ( n1.getParent().getChildNode1() == n2 ) || ( n1.getParent().getChildNode2() == n2 ) ) ) {
- reRoot( n1 );
- }
- else {
- throw new IllegalArgumentException( "reRoot( Branch b ): b is not a branch." );
- }
- }
-
- /**
* Places the root of this Phylogeny on the parent branch PhylogenyNode n.
* The new root is always placed on the middle of the branch.
* <p>
final List<PhylogenyBranch> gene_tree_branches_post_order = new ArrayList<PhylogenyBranch>();\r
for( final PhylogenyNodeIterator it = gene_tree.iteratorPostorder(); it.hasNext(); ) {\r
final PhylogenyNode n = it.next();\r
- if ( !n.isRoot() /*&& !( n.getParent().isRoot() && n.isFirstChildNode() )*/) {\r
+ if ( !n.isRoot() && !( n.getParent().isRoot() && ( gene_tree.getRoot().getNumberOfDescendants() == 2 ) ) ) {\r
gene_tree_branches_post_order.add( new PhylogenyBranch( n, n.getParent() ) );\r
}\r
}\r
+ if ( gene_tree.getRoot().getNumberOfDescendants() == 2 ) {\r
+ gene_tree_branches_post_order.add( new PhylogenyBranch( gene_tree.getRoot().getChildNode1(), gene_tree\r
+ .getRoot().getChildNode2() ) );\r
+ }\r
int min_duplications_sum = Integer.MAX_VALUE;\r
int speciations_sum = 0;\r
_duplications_sum_stats = new BasicDescriptiveStatistics();\r
for( final PhylogenyBranch branch : gene_tree_branches_post_order ) {\r
- gene_tree.reRoot( branch );\r
+ reRoot( branch, gene_tree );\r
PhylogenyMethods.preOrderReId( species_tree );\r
//TEST, remove later\r
// for( final PhylogenyNodeIterator it = gene_tree.iteratorPostorder(); it.hasNext(); ) {\r
}\r
return shortests;\r
}\r
+\r
+ /**\r
+ * Places the root of this Phylogeny on Branch b. The new root is always\r
+ * placed on the middle of the branch b.\r
+ * \r
+ */\r
+ static final void reRoot( final PhylogenyBranch b, final Phylogeny phy ) {\r
+ final PhylogenyNode n1 = b.getFirstNode();\r
+ final PhylogenyNode n2 = b.getSecondNode();\r
+ if ( n1.isExternal() ) {\r
+ phy.reRoot( n1 );\r
+ }\r
+ else if ( n2.isExternal() ) {\r
+ phy.reRoot( n2 );\r
+ }\r
+ else if ( ( n2 == n1.getChildNode1() ) || ( n2 == n1.getChildNode2() ) ) {\r
+ phy.reRoot( n2 );\r
+ }\r
+ else if ( ( n1 == n2.getChildNode1() ) || ( n1 == n2.getChildNode2() ) ) {\r
+ phy.reRoot( n1 );\r
+ }\r
+ // else if ( ( n1.getParent() != null ) && n1.getParent().isRoot()\r
+ // && ( ( n1.getParent().getChildNode1() == n2 ) || ( n1.getParent().getChildNode2() == n2 ) ) ) {\r
+ // phy.reRoot( n1 );\r
+ // \r
+ // }\r
+ else {\r
+ throw new IllegalArgumentException( "reRoot( Branch b ): b is not a branch." );\r
+ }\r
+ }\r
}\r
prev_root_c2 = prev_root.getChildNode2();
prev_root_was_dup = prev_root.isDuplication();
final PhylogenyBranch current_branch = branches.get( j );
- g.reRoot( current_branch );
+ GSDIR.reRoot( current_branch, g );
if ( minimize_mapping_cost || minimize_sum_of_dup ) {
duplications = sdise.updateM( prev_root_was_dup, prev_root_c1, prev_root_c2 );
}
if ( sdi4.getMinDuplicationsSum() != 0 ) {
return false;
}
+ //
+ final String s2str = "(((([&&NHX:S=HUMAN],([&&NHX:S=MOUSE],[&&NHX:S=RAT])),([&&NHX:S=CAEEL],[&&NHX:S=CAEBR])),[&&NHX:S=YEAST]),([&&NHX:S=ARATH],[&&NHX:S=SOYBN]))";
+ final Phylogeny s2 = ParserBasedPhylogenyFactory.getInstance().create( s2str, new NHXParser() )[ 0 ];
+ s2.setRooted( true );
+ final Phylogeny g5 = TestGSDI.createPhylogeny( s2str );
+ final GSDIR sdi5 = new GSDIR( g5, s2, false, false );
+ if ( sdi5.getMinDuplicationsSum() != 0 ) {
+ System.out.println( sdi5.getMinDuplicationsSum() );
+ return false;
+ }
}
catch ( final Exception e ) {
e.printStackTrace( System.out );