clean up
[jalview.git] / forester / java / src / org / forester / surfacing / PrintableSpeciesSpecificDcData.java
index e54142f..be2fcc7 100644 (file)
@@ -34,7 +34,7 @@ import java.util.TreeMap;
 import java.util.TreeSet;
 
 import org.forester.util.ForesterUtil;
-import org.forester.util.SequenceIdParser;
+import org.forester.util.SequenceAccessionTools;
 
 class PrintableSpeciesSpecificDcData implements SpeciesSpecificDcData {
 
@@ -97,46 +97,63 @@ class PrintableSpeciesSpecificDcData implements SpeciesSpecificDcData {
     public StringBuffer toStringBuffer( final DomainSimilarityCalculator.Detailedness detailedness, final boolean html ) {
         final StringBuffer sb = new StringBuffer();
         if ( detailedness == DomainSimilarityCalculator.Detailedness.PUNCTILIOUS ) {
-            sb.append( " " );
+            if ( html ) {
+                //sb.append( " " );
+                sb.append( "<td>" );
+            }
             sb.append( getKeyDomainDomainsCount() );
-            sb.append( ", " );
-            sb.append( getKeyDomainProteinsCount() );
-            sb.append( ", " );
-            sb.append( getCombinableDomainsCount() );
-            if ( !getCombinableDomainIdToCountsMap().isEmpty() ) {
-                sb.append( ":" );
+            if ( html ) {
+                //sb.append( ", " );
+                sb.append( "</td><td>" );
             }
-        }
-        final Set<String> ids = getCombinableDomainIdToCountsMap().keySet();
-        int i = 0;
-        for( final String domain_id : ids ) {
-            ++i;
-            sb.append( " " );
+            else {
+                sb.append( "\t" );
+            }
+            sb.append( getKeyDomainProteinsCount() );
             if ( html ) {
-                sb.append( "<a href=\"" + SurfacingConstants.PFAM_FAMILY_ID_LINK + domain_id + "\">" + domain_id
-                        + "</a>" );
+                // sb.append( ", " );
+                sb.append( "</td><td>" );
             }
             else {
-                sb.append( domain_id );
+                sb.append( "\t" );
             }
-            if ( detailedness == DomainSimilarityCalculator.Detailedness.PUNCTILIOUS ) {
-                sb.append( ":" );
-                sb.append( getCombinableDomainIdToCountsMap().get( domain_id ) );
+            sb.append( getCombinableDomainsCount() );
+            if ( html /*&& !getCombinableDomainIdToCountsMap().isEmpty()*/) {
+                // sb.append( ":" );
+                sb.append( "</td><td>" );
             }
         }
-        sb.append( " [" );
-        boolean first = true;
-        for( final String p : getKeyDomainProteins() ) {
-            final String link = obtainSeqLink( p );
-            if ( first ) {
-                first = false;
+        if ( html ) {
+            final Set<String> ids = getCombinableDomainIdToCountsMap().keySet();
+            for( final String domain_id : ids ) {
+                sb.append( " " );
+                if ( html ) {
+                    sb.append( "<a href=\"" + SurfacingConstants.PFAM_FAMILY_ID_LINK + domain_id + "\">" + domain_id
+                            + "</a>" );
+                }
+                else {
+                    sb.append( domain_id );
+                }
+                if ( detailedness == DomainSimilarityCalculator.Detailedness.PUNCTILIOUS ) {
+                    sb.append( ":" );
+                    sb.append( getCombinableDomainIdToCountsMap().get( domain_id ) );
+                }
             }
-            else {
-                sb.append( ", " );
+            sb.append( " [" );
+            boolean first = true;
+            for( final String p : getKeyDomainProteins() ) {
+                final String link = obtainSeqLink( p );
+                if ( first ) {
+                    first = false;
+                }
+                else {
+                    sb.append( ", " );
+                }
+                sb.append( link );
             }
-            sb.append( link );
+            sb.append( "]" );
+            sb.append( "</td>" );
         }
-        sb.append( "]" );
         return sb;
     }
 
@@ -154,19 +171,19 @@ class PrintableSpeciesSpecificDcData implements SpeciesSpecificDcData {
 
     private static String obtainSeqLink( final String p ) {
         String link;
-        final String up_id = ForesterUtil.extractUniProtKbProteinSeqIdentifier( p );
+        final String up_id = SequenceAccessionTools.parseUniProtAccessorFromString( p );
         if ( !ForesterUtil.isEmpty( up_id ) ) {
             link = "<a class=\"pl\" href=\"" + ForesterUtil.UNIPROT_KB + up_id + "\" target=\"_up_window\">" + up_id
                     + "</a>";
         }
         else {
-            final String gb_id = SequenceIdParser.parseGenbankProteinAccessor( p );
+            final String gb_id = SequenceAccessionTools.parseGenbankProteinAccessorFromString( p );
             if ( !ForesterUtil.isEmpty( gb_id ) ) {
                 link = "<a class=\"pl\" href=\"" + ForesterUtil.NCBI_PROTEIN + gb_id + "\" target=\"_up_window\">"
                         + gb_id + "</a>";
             }
             else {
-                final String gi = SequenceIdParser.parseGInumber( p );
+                final String gi = SequenceAccessionTools.parseGInumberFromString( p );
                 if ( !ForesterUtil.isEmpty( gi ) ) {
                     link = "<a class=\"pl\" href=\"" + ForesterUtil.NCBI_GI + gi + "\" target=\"_up_window\">gi|" + gi
                             + "</a>";