import java.util.TreeSet;
import org.forester.util.ForesterUtil;
+import org.forester.util.SequenceAccessionTools;
class PrintableSpeciesSpecificDcData implements SpeciesSpecificDcData {
final SortedMap<String, Integer> _combinable_domain_id_to_count_map;
final SortedSet<String> _key_domain_proteins;
- final private int _key_domain_domains_count;
final private int _combinable_domains_count;
+ final private int _key_domain_domains_count;
public PrintableSpeciesSpecificDcData( final int key_domain_domains_count, final int combinable_domains ) {
_key_domain_proteins = new TreeSet<String>();
}
@Override
+ public void addKeyDomainProtein( final String protein ) {
+ if ( ForesterUtil.isEmpty( protein ) ) {
+ throw new IllegalArgumentException( "attempt to add null or empty protein" );
+ }
+ if ( getKeyDomainProteins().contains( protein ) ) {
+ throw new IllegalArgumentException( "protein \"" + protein + "\" is not unique" );
+ }
+ getKeyDomainProteins().add( protein );
+ }
+
+ @Override
public void addProteinsExhibitingCombinationCount( final String domain_id, final int count ) {
if ( getCombinableDomainIdToCountsMap().containsKey( domain_id ) ) {
throw new IllegalArgumentException( "Domain with id " + domain_id + " already exists" );
return _combinable_domain_id_to_count_map;
}
- private int getCombinableDomainsCount() {
- return _combinable_domains_count;
- }
-
- private int getKeyDomainDomainsCount() {
- return _key_domain_domains_count;
- }
-
- private int getKeyDomainProteinsCount() {
- return _key_domain_proteins.size();
+ @Override
+ public SortedSet<String> getKeyDomainProteins() {
+ return _key_domain_proteins;
}
@Override
}
@Override
- public void addKeyDomainProtein( final String protein ) {
- if ( ForesterUtil.isEmpty( protein ) ) {
- throw new IllegalArgumentException( "attempt to add null or empty protein" );
- }
- if ( getKeyDomainProteins().contains( protein ) ) {
- throw new IllegalArgumentException( "protein \"" + protein + "\" is not unique" );
- }
- getKeyDomainProteins().add( protein );
- }
-
- @Override
- public SortedSet<String> getKeyDomainProteins() {
- return _key_domain_proteins;
- }
-
- @Override
public String toString() {
return toStringBuffer( DomainSimilarityCalculator.Detailedness.LIST_COMBINING_DOMAIN_FOR_EACH_SPECIES, false )
.toString();
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() ) {
- String link = null;
- final String up_id = ForesterUtil.extractUniProtKbProteinSeqIdentifier( p );
- if ( !ForesterUtil.isEmpty( up_id ) ) {
- link = "<a href=\"" + ForesterUtil.UNIPROT_KB + up_id + "\" target=\"_up_window\">" + up_id + "</a>";
+ 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 {
- link = "<a href=\"" + "http://www.google.com/search?q=" + p + "\" target=\"_g_window\">" + p + "</a>";
+ 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 );
}
- if ( first ) {
- first = false;
+ sb.append( "]" );
+ sb.append( "</td>" );
+ }
+ return sb;
+ }
+
+ private int getCombinableDomainsCount() {
+ return _combinable_domains_count;
+ }
+
+ private int getKeyDomainDomainsCount() {
+ return _key_domain_domains_count;
+ }
+
+ private int getKeyDomainProteinsCount() {
+ return _key_domain_proteins.size();
+ }
+
+ private static String obtainSeqLink( final String p ) {
+ String link;
+ 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 = 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 {
- sb.append( ", " );
+ 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>";
+ }
+ else {
+ link = "<a class=\"ps\" href=\"" + "http://www.google.com/search?q=" + p
+ + "\" target=\"_g_window\">" + p + "</a>";
+ }
}
- sb.append( p );
}
- sb.append( "]" );
- return sb;
+ return link;
}
}