X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fsurfacing%2FDomainCountsDifferenceUtil.java;h=8f9a2496a4747c02b4e5bb858bc66f739347b424;hb=1556760e353eae5745f1ae9471a64f0089554639;hp=2a18c9ccd226c223c9ad595561f95b6f62c6718b;hpb=08a92c65e8b969a3ce2a4b511055cd6029357831;p=jalview.git diff --git a/forester/java/src/org/forester/surfacing/DomainCountsDifferenceUtil.java b/forester/java/src/org/forester/surfacing/DomainCountsDifferenceUtil.java index 2a18c9c..8f9a249 100644 --- a/forester/java/src/org/forester/surfacing/DomainCountsDifferenceUtil.java +++ b/forester/java/src/org/forester/surfacing/DomainCountsDifferenceUtil.java @@ -58,77 +58,11 @@ import org.forester.util.ForesterUtil; */ public final class DomainCountsDifferenceUtil { - private static final COPY_CALCULATION_MODE COPY_CALC_MODE_FOR_HIGH_COPY_TARGET_SPECIES = COPY_CALCULATION_MODE.MIN; private static final COPY_CALCULATION_MODE COPY_CALC_MODE_FOR_HIGH_COPY_BASE_SPECIES = COPY_CALCULATION_MODE.MIN; + private static final COPY_CALCULATION_MODE COPY_CALC_MODE_FOR_HIGH_COPY_TARGET_SPECIES = COPY_CALCULATION_MODE.MIN; private static final COPY_CALCULATION_MODE COPY_CALC_MODE_FOR_LOW_COPY_SPECIES = COPY_CALCULATION_MODE.MAX; private static final String PLUS_MINUS_PROTEINS_FILE_DOM_SUFFIX = ".prot"; - //FIXME really needs to be tested! - private static void addCounts( final SortedMap> copy_counts, - final BinaryDomainCombination dc, - final GenomeWideCombinableDomains genome, - final Set bdc ) { - if ( !copy_counts.containsKey( dc ) ) { - copy_counts.put( dc, new ArrayList() ); - } - if ( bdc.contains( dc ) - && ( ( ( BasicCombinableDomains ) genome.get( dc.getId0() ) ).getCombiningDomains().get( dc.getId1() ) != null ) ) { - final int count = ( ( BasicCombinableDomains ) genome.get( dc.getId0() ) ).getCombiningDomains() - .get( dc.getId1() ); - copy_counts.get( dc ).add( count ); - } - else { - copy_counts.get( dc ).add( 0 ); - } - } - - private static void addCounts( final SortedMap> copy_counts, - final String domain, - final GenomeWideCombinableDomains genome ) { - if ( !copy_counts.containsKey( domain ) ) { - copy_counts.put( domain, new ArrayList() ); - } - if ( genome.contains( domain ) ) { - copy_counts.get( domain ).add( genome.get( domain ).getKeyDomainProteinsCount() ); - } - else { - copy_counts.get( domain ).add( 0 ); - } - } - - private static StringBuilder addGoInformation( final String d, - final Map> domain_id_to_go_ids_map, - final Map go_id_to_term_map ) { - final StringBuilder sb = new StringBuilder(); - if ( ( domain_id_to_go_ids_map == null ) || domain_id_to_go_ids_map.isEmpty() - || !domain_id_to_go_ids_map.containsKey( d ) ) { - return sb; - } - final List go_ids = domain_id_to_go_ids_map.get( d ); - for( int i = 0; i < go_ids.size(); ++i ) { - final GoId go_id = go_ids.get( i ); - if ( go_id_to_term_map.containsKey( go_id ) ) { - appendGoTerm( sb, go_id_to_term_map.get( go_id ) ); - sb.append( "
" ); - } - else { - sb.append( "go id \"" + go_id + "\" not found [" + d + "]" ); - } - } - return sb; - } - - private static void appendGoTerm( final StringBuilder sb, final GoTerm go_term ) { - final GoId go_id = go_term.getGoId(); - sb.append( "" + go_id - + "" ); - sb.append( ":" ); - sb.append( go_term.getName() ); - sb.append( " [" ); - sb.append( go_term.getGoNameSpace().toShortString() ); - sb.append( "]" ); - } - public static void calculateCopyNumberDifferences( final List genomes, final SortedMap> protein_lists_per_species, final List high_copy_base_species, @@ -301,6 +235,72 @@ public final class DomainCountsDifferenceUtil { writeGoIdsToFile( passing_gos_writer, go_ids_of_passing_domains ); } + //FIXME really needs to be tested! + private static void addCounts( final SortedMap> copy_counts, + final BinaryDomainCombination dc, + final GenomeWideCombinableDomains genome, + final Set bdc ) { + if ( !copy_counts.containsKey( dc ) ) { + copy_counts.put( dc, new ArrayList() ); + } + if ( bdc.contains( dc ) + && ( ( ( BasicCombinableDomains ) genome.get( dc.getId0() ) ).getCombiningDomains().get( dc.getId1() ) != null ) ) { + final int count = ( ( BasicCombinableDomains ) genome.get( dc.getId0() ) ).getCombiningDomains() + .get( dc.getId1() ); + copy_counts.get( dc ).add( count ); + } + else { + copy_counts.get( dc ).add( 0 ); + } + } + + private static void addCounts( final SortedMap> copy_counts, + final String domain, + final GenomeWideCombinableDomains genome ) { + if ( !copy_counts.containsKey( domain ) ) { + copy_counts.put( domain, new ArrayList() ); + } + if ( genome.contains( domain ) ) { + copy_counts.get( domain ).add( genome.get( domain ).getKeyDomainProteinsCount() ); + } + else { + copy_counts.get( domain ).add( 0 ); + } + } + + private static StringBuilder addGoInformation( final String d, + final Map> domain_id_to_go_ids_map, + final Map go_id_to_term_map ) { + final StringBuilder sb = new StringBuilder(); + if ( ( domain_id_to_go_ids_map == null ) || domain_id_to_go_ids_map.isEmpty() + || !domain_id_to_go_ids_map.containsKey( d ) ) { + return sb; + } + final List go_ids = domain_id_to_go_ids_map.get( d ); + for( int i = 0; i < go_ids.size(); ++i ) { + final GoId go_id = go_ids.get( i ); + if ( go_id_to_term_map.containsKey( go_id ) ) { + appendGoTerm( sb, go_id_to_term_map.get( go_id ) ); + sb.append( "
" ); + } + else { + sb.append( "go id \"" + go_id + "\" not found [" + d + "]" ); + } + } + return sb; + } + + private static void appendGoTerm( final StringBuilder sb, final GoTerm go_term ) { + final GoId go_id = go_term.getGoId(); + sb.append( "" + go_id + + "" ); + sb.append( ":" ); + sb.append( go_term.getName() ); + sb.append( " [" ); + sb.append( go_term.getGoNameSpace().toShortString() ); + sb.append( "]" ); + } + private static void calculateDomainCountsBasedValue( final SortedMap copy_values, final SortedMap> copy_counts, final BinaryDomainCombination bdc, @@ -542,7 +542,7 @@ public final class DomainCountsDifferenceUtil { int counter = 0; int total_absense_counter = 0; int not_total_absense_counter = 0; - SurfacingUtil.addHtmlHead( html_writer, "Binary Domain Combination Copy Differences" ); + SurfacingUtil.writeHtmlHead( html_writer, "Binary Domain Combination Copy Differences" ); html_writer.write( "" ); for( final BinaryDomainCombination bdc : all_bdcs ) { if ( ( high_copy_base_values.get( bdc ) > 0 ) && ( high_copy_target_values.get( bdc ) > 0 ) @@ -666,7 +666,7 @@ public final class DomainCountsDifferenceUtil { int counter = 0; int total_absense_counter = 0; int not_total_absense_counter = 0; - SurfacingUtil.addHtmlHead( html_writer, "Domain Copy Differences" ); + SurfacingUtil.writeHtmlHead( html_writer, "Domain Copy Differences" ); html_writer.write( "
" ); for( final String domain_id : all_domains ) { if ( ( high_copy_base_values.get( domain_id ) > 0 ) && ( high_copy_target_values.get( domain_id ) > 0 ) @@ -827,6 +827,6 @@ public final class DomainCountsDifferenceUtil { } public static enum COPY_CALCULATION_MODE { - MEAN, MEDIAN, MAX, MIN + MAX, MEAN, MEDIAN, MIN } }