X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fsurfacing%2FSurfacingUtil.java;h=0c1d60ec5836dbb6e289a40efd6b7838262b1765;hb=4b46b352b1a6aef96c2c09835335ef40f0b0d8fc;hp=1a0a07de3efa8eebf75b4be24dbb2aacbc7ee63f;hpb=764e1546f1bcc4f6b52be283bdd801372ed2ee54;p=jalview.git diff --git a/forester/java/src/org/forester/surfacing/SurfacingUtil.java b/forester/java/src/org/forester/surfacing/SurfacingUtil.java index 1a0a07d..0c1d60e 100644 --- a/forester/java/src/org/forester/surfacing/SurfacingUtil.java +++ b/forester/java/src/org/forester/surfacing/SurfacingUtil.java @@ -66,6 +66,7 @@ import org.forester.go.GoTerm; import org.forester.go.PfamToGoMapping; import org.forester.io.parsers.nexus.NexusConstants; import org.forester.io.writers.PhylogenyWriter; +import org.forester.msa.MsaCompactor.SORT_BY; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; import org.forester.phylogeny.PhylogenyNode; @@ -374,7 +375,7 @@ public final class SurfacingUtil { } for( int i = 0; i < nodes.size() - 1; ++i ) { for( int j = i + 1; j < nodes.size(); ++j ) { - final PhylogenyNode lca = PhylogenyMethods.getInstance().obtainLCA( nodes.get( i ), + final PhylogenyNode lca = PhylogenyMethods.obtainLCA( nodes.get( i ), nodes.get( j ) ); String rank = "unknown"; if ( lca.getNodeData().isHasTaxonomy() @@ -1185,12 +1186,17 @@ public final class SurfacingUtil { final DomainId domain_id, final Writer out, final String separator, - final String limit_to_species ) throws IOException { + final String limit_to_species, + final double domain_e_cutoff ) throws IOException { + System.out.println( "Per domain E-value: " + domain_e_cutoff ); + for( final Species species : protein_lists_per_species.keySet() ) { + System.out.println( species + ":" ); for( final Protein protein : protein_lists_per_species.get( species ) ) { if ( ForesterUtil.isEmpty( limit_to_species ) || protein.getSpecies().getSpeciesId().equalsIgnoreCase( limit_to_species ) ) { final List domains = protein.getProteinDomains( domain_id ); + if ( domains.size() > 0 ) { out.write( protein.getSpecies().getSpeciesId() ); out.write( separator ); @@ -1198,15 +1204,45 @@ public final class SurfacingUtil { out.write( separator ); out.write( domain_id.toString() ); out.write( separator ); + int prev_to = -1; + for( final Domain domain : domains ) { - out.write( "/" ); - out.write( domain.getFrom() + "-" + domain.getTo() ); + + if ( domain_e_cutoff < 0 || domain.getPerDomainEvalue() <= domain_e_cutoff ) { + out.write( "/" ); + out.write( domain.getFrom() + "-" + domain.getTo() ); + if ( prev_to >= 0) { + final int l = domain.getFrom() - prev_to; + System.out.println( l ); + } + prev_to = domain.getTo(); + } } + out.write( "/" ); out.write( separator ); + + + final List domain_list = new ArrayList(); + + for( final Domain domain : protein.getProteinDomains() ) { + if ( domain_e_cutoff < 0 || domain.getPerDomainEvalue() <= domain_e_cutoff ) { + domain_list.add( domain ); + } + } + + Domain domain_ary[] = new Domain[ domain_list.size() ]; + + for( int i = 0; i < domain_list.size(); ++i ) { + domain_ary[ i ] = domain_list.get( i ); + } + + Arrays.sort( domain_ary, new DomainComparator( true ) ); + out.write( "{" ); boolean first = true; - for( final Domain domain : protein.getProteinDomains() ) { + + for( final Domain domain : domain_ary ) { if ( first ) { first = false; } @@ -1214,6 +1250,8 @@ public final class SurfacingUtil { out.write( "," ); } out.write( domain.getDomainId().toString() ); + out.write( ":" + domain.getFrom() + "-" + domain.getTo() ); + out.write( ":" + domain.getPerDomainEvalue() ); } out.write( "}" ); if ( !( ForesterUtil.isEmpty( protein.getDescription() ) || protein.getDescription() @@ -1227,6 +1265,7 @@ public final class SurfacingUtil { } out.write( SurfacingConstants.NL ); } + } } } @@ -2606,4 +2645,32 @@ public final class SurfacingUtil { e.printStackTrace(); } } + + final static class DomainComparator implements Comparator { + + final private boolean _ascending; + + public DomainComparator( final boolean ascending ) { + _ascending = ascending; + } + + @Override + public final int compare( final Domain d0, final Domain d1 ) { + + if ( d0.getFrom() < d1.getFrom() ) { + return _ascending ? -1 : 1; + } + else if ( d0.getFrom() > d1.getFrom() ) { + return _ascending ? 1 : -1; + } + return 0; + + } + + } } + + + + +