+ public SortedMap<Species, SpeciesSpecificDcData> getSpeciesData() {
+ return _species_data;
+ }
+
+ public double getStandardDeviationOfSimilarityScore() {
+ return _sd;
+ }
+
+ public void setDetailedness( final Detailedness detailedness ) {
+ _detailedness = detailedness;
+ }
+
+ public void setSpeciesOrder( final List<Species> species_order ) {
+ if ( !species_order.containsAll( getSpeciesData().keySet() ) ) {
+ throw new IllegalArgumentException( "list to order species must contain all species of multiple combinable domains similarity" );
+ }
+ _species_order = species_order;
+ }
+
+ public StringBuffer toStringBuffer( final DomainSimilarity.PRINT_OPTION print_option,
+ final Map<String, Integer> tax_code_to_id_map,
+ final Phylogeny phy ) {
+ switch ( print_option ) {
+ case SIMPLE_TAB_DELIMITED:
+ return toStringBufferSimpleTabDelimited();
+ case HTML:
+ return toStringBufferDetailedHTML( tax_code_to_id_map, phy, OUTPUT_TAXCODES_PER_DOMAIN );
+ default:
+ throw new AssertionError( "Unknown print option: " + print_option );
+ }
+ }
+
+ private void addSpeciesSpecificDomainData( final StringBuffer sb,
+ final Species species,
+ final boolean html,
+ final Map<String, Integer> tax_code_to_id_map,
+ final Phylogeny phy ) {
+ if ( html ) {
+ sb.append( "<tr>" );
+ sb.append( "<td>" );
+ addTaxWithLink( sb, species.getSpeciesId(), tax_code_to_id_map, phy );
+ sb.append( "</td>" );
+ }
+ else {
+ sb.append( species.getSpeciesId() );
+ }
+ if ( getDetaildness() != DomainSimilarityCalculator.Detailedness.BASIC ) {
+ if ( html ) {
+ //sb.append( ":" );
+ }
+ else {
+ sb.append( "\t" );
+ }
+ sb.append( getSpeciesData().get( species ).toStringBuffer( getDetaildness(), html ) );
+ }
+ if ( html ) {
+ //sb.append( "<br>" );
+ sb.append( "</tr>" );
+ }
+ else {
+ sb.append( "\n\t" );
+ }
+ }
+
+ private void addTaxWithLink( final StringBuffer sb,
+ final String tax_code,
+ final Map<String, Integer> tax_code_to_id_map,
+ final Phylogeny phy ) {
+ String hex = null;
+ if ( ( phy != null ) && !phy.isEmpty() ) {
+ hex = SurfacingUtil.obtainHexColorStringDependingOnTaxonomyGroup( tax_code, phy );
+ }
+ sb.append( "<b>" );
+ if ( !ForesterUtil.isEmpty( tax_code )
+ && ( ( tax_code_to_id_map != null ) && tax_code_to_id_map.containsKey( tax_code ) ) ) {
+ if ( !ForesterUtil.isEmpty( hex ) ) {
+ sb.append( "<a href=\"" );
+ sb.append( SurfacingConstants.UNIPROT_TAXONOMY_ID_LINK );
+ sb.append( tax_code_to_id_map.get( tax_code ) );
+ sb.append( "\" target=\"tw\"><span style=\"color:" );
+ sb.append( hex );
+ sb.append( "\">" );
+ sb.append( tax_code );
+ sb.append( "</span></a>" );
+ }
+ else {
+ sb.append( "<a href=\"" );
+ sb.append( SurfacingConstants.UNIPROT_TAXONOMY_ID_LINK );
+ sb.append( tax_code_to_id_map.get( tax_code ) );
+ sb.append( "\" target=\"tw\">" );
+ sb.append( tax_code );
+ sb.append( "</a>" );
+ }
+ }
+ else {
+ sb.append( tax_code );
+ }
+ sb.append( "</b>" );
+ }
+
+ private int compareByDomainId( final DomainSimilarity other ) {
+ return getDomainId().compareToIgnoreCase( other.getDomainId() );
+ }
+
+ private CombinableDomains getCombinableDomains() {
+ return _combinable_domains;
+ }
+
+ private DomainSimilarityCalculator.Detailedness getDetaildness() {
+ return _detailedness;
+ }
+
+ private StringBuffer getDomainDataInAlphabeticalOrder() {
+ final SortedMap<String, SortedSet<String>> m = new TreeMap<String, SortedSet<String>>();
+ final StringBuffer sb = new StringBuffer();
+ for( final Species species : getSpeciesData().keySet() ) {
+ for( final String combable_dom : getCombinableDomainIds( species ) ) {
+ if ( !m.containsKey( combable_dom ) ) {
+ m.put( combable_dom, new TreeSet<String>() );
+ }
+ m.get( combable_dom ).add( species.getSpeciesId() );
+ }
+ }
+ for( final Map.Entry<String, SortedSet<String>> e : m.entrySet() ) {
+ sb.append( "<a href=\"" + SurfacingConstants.PFAM_FAMILY_ID_LINK + e.getKey() + "\">" + e.getKey() + "</a>" );
+ sb.append( " " );
+ sb.append( "<span style=\"font-size:7px\">" );
+ for( final String tax : e.getValue() ) {
+ final String hex = SurfacingUtil.obtainHexColorStringDependingOnTaxonomyGroup( tax, null );
+ if ( !ForesterUtil.isEmpty( hex ) ) {
+ sb.append( "<span style=\"color:" );
+ sb.append( hex );
+ sb.append( "\">" );
+ sb.append( tax );
+ sb.append( "</span>" );
+ }
+ else {
+ sb.append( tax );
+ }
+ sb.append( " " );
+ }
+ sb.append( "</span>" );
+ sb.append( "<br>\n" );
+ }
+ return sb;
+ }
+
+ private StringBuffer getSpeciesDataInAlphabeticalOrder( final boolean html,
+ final Map<String, Integer> tax_code_to_id_map,
+ final Phylogeny phy ) {
+ final StringBuffer sb = new StringBuffer();
+ sb.append( "<table>" );
+ for( final Species species : getSpeciesData().keySet() ) {
+ addSpeciesSpecificDomainData( sb, species, html, tax_code_to_id_map, phy );
+ }
+ sb.append( "</table>" );
+ return sb;
+ }
+
+ private StringBuffer getSpeciesDataInCustomOrder( final boolean html,
+ final Map<String, Integer> tax_code_to_id_map,
+ final Phylogeny phy ) {
+ final StringBuffer sb = new StringBuffer();
+ for( final Species order_species : getSpeciesCustomOrder() ) {
+ if ( getSpeciesData().keySet().contains( order_species ) ) {
+ addSpeciesSpecificDomainData( sb, order_species, html, tax_code_to_id_map, phy );
+ }
+ else {
+ sb.append( DomainSimilarity.NO_SPECIES );
+ sb.append( DomainSimilarity.SPECIES_SEPARATOR );
+ }
+ }
+ return sb;
+ }