import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
return nodes;
}
+ public static final HashMap<String, PhylogenyNode> createNameToExtNodeMap( final Phylogeny phy ) {
+ final HashMap<String, PhylogenyNode> nodes = new HashMap<String, PhylogenyNode>();
+ for( final PhylogenyNodeIterator iter = phy.iteratorExternalForward(); iter.hasNext(); ) {
+ final PhylogenyNode n = iter.next();
+ nodes.put( n.getName(), n );
+ }
+ return nodes;
+ }
+
public final static Phylogeny[] readPhylogenies( final PhylogenyParser parser, final File file ) throws IOException {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
final Phylogeny[] trees = factory.create( file, parser );
reset();
}
- public IntMatrix calculateOrthologTable( final Phylogeny[] gene_trees ) {
+ public static IntMatrix calculateOrthologTable( final Phylogeny[] gene_trees ) {
final List<String> labels = new ArrayList<String>();
final Set<String> labels_set = new HashSet<String>();
String label;
System.out.println( counter );
counter++;
PhylogenyMethods.preOrderReId( gt );
+ final HashMap<String, PhylogenyNode> map = PhylogenyMethods.createNameToExtNodeMap( gt );
for( int x = 0; x < m.size(); ++x ) {
- final PhylogenyNode nx = gt.getNode( m.getLabel( x ) );
+ final PhylogenyNode nx = map.get( m.getLabel( x ) );
for( int y = 0; y < m.size(); ++y ) {
- final PhylogenyNode ny = gt.getNode( m.getLabel( y ) );
- if ( !PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( nx, ny ).isDuplication() ) {
- m.set( x, y, m.get( x, y ) + 1 );
- //System.out.println( x + " " + y );
+ if ( !PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( nx, map.get( m.getLabel( y ) ) ).isDuplication() ) {
+ m.inreaseByOne( x, y );
}
}
}
import java.util.Set;
import org.forester.application.support_transfer;
+import org.forester.datastructures.IntMatrix;
import org.forester.development.DevelopmentTools;
import org.forester.evoinference.TestPhylogenyReconstruction;
import org.forester.evoinference.matrix.character.CharacterStateMatrix;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyBranch;
import org.forester.phylogeny.PhylogenyMethods;
+import org.forester.phylogeny.PhylogenyMethods.TAXONOMY_EXTRACTION;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.PhylogenyNodeI.NH_CONVERSION_SUPPORT_VALUE_STYLE;
import org.forester.phylogeny.data.BinaryCharacters;
import org.forester.phylogeny.factories.PhylogenyFactory;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
import org.forester.protein.Protein;
+import org.forester.sdi.GSDI;
+import org.forester.sdi.RIO;
import org.forester.sdi.SDI;
import org.forester.sdi.SDIR;
import org.forester.sdi.SDIse;
System.out.println( "failed." );
failed++;
}
+ System.out.print( "Ortholog table: " );
+ if ( Test.testOrthologTable() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
System.out.print( "Descriptive statistics: " );
if ( Test.testDescriptiveStatistics() ) {
System.out.println( "OK." );
.create( "((A,C),X);((A,X),C);(A,C);((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
new NHXParser() );
ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
- // Archaeopteryx.createApplication( t_b ); //TODO use me again me working here...
if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
return false;
}
return true;
}
+ private static boolean testOrthologTable() {
+ try {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny s1 = factory.create( Test.PATH_TO_TEST_DATA + "rio_species.xml", new PhyloXmlParser() )[ 0 ];
+ final NHXParser p = new NHXParser();
+ p.setTaxonomyExtraction( TAXONOMY_EXTRACTION.YES );
+ final Phylogeny g1[] = factory.create( new File( Test.PATH_TO_TEST_DATA
+ + "rio_Bcl-2_e1_20_mafft_05_40_fme.mlt" ), p );
+ for( final Phylogeny gt : g1 ) {
+ gt.setRooted( true );
+ final GSDI sdi = new GSDI( gt, s1, true, true, true );
+ }
+ final IntMatrix m = RIO.calculateOrthologTable( g1 );
+ System.out.println( m.toString() );
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
private static boolean testSplit() {
try {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();