From 744ab7983b8a0f44836b97c63d18ed618ed6b28e Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Thu, 11 Jul 2013 20:14:56 +0000 Subject: [PATCH] inprogress --- .../src/org/forester/application/surfacing.java | 4 +- .../surfacing/PrintableSpeciesSpecificDcData.java | 94 ++++++++++++-------- .../src/org/forester/surfacing/SurfacingUtil.java | 19 ++++ .../src/org/forester/util/SequenceIdParser.java | 10 +++ 4 files changed, 89 insertions(+), 38 deletions(-) diff --git a/forester/java/src/org/forester/application/surfacing.java b/forester/java/src/org/forester/application/surfacing.java index 0c548af..71020c5 100644 --- a/forester/java/src/org/forester/application/surfacing.java +++ b/forester/java/src/org/forester/application/surfacing.java @@ -225,8 +225,8 @@ public class surfacing { final static private String INPUT_GENOMES_FILE_OPTION = "genomes"; final static private String INPUT_SPECIES_TREE_OPTION = "species_tree"; final static private String SEQ_EXTRACT_OPTION = "prot_extract"; - final static private String PRG_VERSION = "2.290"; - final static private String PRG_DATE = "130709"; + final static private String PRG_VERSION = "2.300"; + final static private String PRG_DATE = "130711"; final static private String E_MAIL = "czmasek@burnham.org"; final static private String WWW = "https://sites.google.com/site/cmzmasek/home/software/forester/surfacing"; final static private boolean IGNORE_DUFS_DEFAULT = true; diff --git a/forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDcData.java b/forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDcData.java index 79dcb37..e54142f 100644 --- a/forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDcData.java +++ b/forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDcData.java @@ -34,13 +34,14 @@ import java.util.TreeMap; import java.util.TreeSet; import org.forester.util.ForesterUtil; +import org.forester.util.SequenceIdParser; class PrintableSpeciesSpecificDcData implements SpeciesSpecificDcData { final SortedMap _combinable_domain_id_to_count_map; final SortedSet _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(); @@ -50,6 +51,17 @@ class PrintableSpeciesSpecificDcData implements SpeciesSpecificDcData { } @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" ); @@ -62,16 +74,9 @@ class PrintableSpeciesSpecificDcData implements SpeciesSpecificDcData { 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 getKeyDomainProteins() { + return _key_domain_proteins; } @Override @@ -83,22 +88,6 @@ class PrintableSpeciesSpecificDcData implements SpeciesSpecificDcData { } @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 getKeyDomainProteins() { - return _key_domain_proteins; - } - - @Override public String toString() { return toStringBuffer( DomainSimilarityCalculator.Detailedness.LIST_COMBINING_DOMAIN_FOR_EACH_SPECIES, false ) .toString(); @@ -138,23 +127,56 @@ class PrintableSpeciesSpecificDcData implements SpeciesSpecificDcData { 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 = "" + up_id + ""; - } - else { - link = "" + p + ""; - } + final String link = obtainSeqLink( p ); if ( first ) { first = false; } else { sb.append( ", " ); } - sb.append( p ); + sb.append( link ); } sb.append( "]" ); 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 = ForesterUtil.extractUniProtKbProteinSeqIdentifier( p ); + if ( !ForesterUtil.isEmpty( up_id ) ) { + link = "" + up_id + + ""; + } + else { + final String gb_id = SequenceIdParser.parseGenbankProteinAccessor( p ); + if ( !ForesterUtil.isEmpty( gb_id ) ) { + link = "" + + gb_id + ""; + } + else { + final String gi = SequenceIdParser.parseGInumber( p ); + if ( !ForesterUtil.isEmpty( gi ) ) { + link = "gi|" + gi + + ""; + } + else { + link = "" + p + ""; + } + } + } + return link; + } } diff --git a/forester/java/src/org/forester/surfacing/SurfacingUtil.java b/forester/java/src/org/forester/surfacing/SurfacingUtil.java index 9dfc40f..70d5654 100644 --- a/forester/java/src/org/forester/surfacing/SurfacingUtil.java +++ b/forester/java/src/org/forester/surfacing/SurfacingUtil.java @@ -151,6 +151,25 @@ public final class SurfacingUtil { w.write( SurfacingConstants.NL ); w.write( "a:hover { color : #FFFFFF; background-color : #99FF00; text-decoration : none; }" ); w.write( SurfacingConstants.NL ); + // + w.write( "a.pl:visited { color : #505050; text-decoration : none; font-size: 7pt;}" ); + w.write( SurfacingConstants.NL ); + w.write( "a.pl:link { color : #505050; text-decoration : none; font-size: 7pt;}" ); + w.write( SurfacingConstants.NL ); + w.write( "a.pl:active { color : #505050; text-decoration : none; font-size: 7pt;}" ); + w.write( SurfacingConstants.NL ); + w.write( "a.pl:hover { color : #FFFFFF; background-color : #99FF00; text-decoration : none; font-size: 7pt;}" ); + w.write( SurfacingConstants.NL ); + // + w.write( "a.ps:visited { color : #707070; text-decoration : none; font-size: 7pt;}" ); + w.write( SurfacingConstants.NL ); + w.write( "a.ps:link { color : #707070; text-decoration : none; font-size: 7pt;}" ); + w.write( SurfacingConstants.NL ); + w.write( "a.ps:active { color : #707070; text-decoration : none; font-size: 7pt;}" ); + w.write( SurfacingConstants.NL ); + w.write( "a.ps:hover { color : #FFFFFF; background-color : #99FF00; text-decoration : none; font-size: 7pt;}" ); + w.write( SurfacingConstants.NL ); + // w.write( "td { text-align: left; vertical-align: top; font-family: Verdana, Arial, Helvetica; font-size: 8pt}" ); w.write( SurfacingConstants.NL ); w.write( "h1 { color : #0000FF; font-family: Verdana, Arial, Helvetica; font-size: 18pt; font-weight: bold }" ); diff --git a/forester/java/src/org/forester/util/SequenceIdParser.java b/forester/java/src/org/forester/util/SequenceIdParser.java index d828a6a..7b400d2 100644 --- a/forester/java/src/org/forester/util/SequenceIdParser.java +++ b/forester/java/src/org/forester/util/SequenceIdParser.java @@ -123,6 +123,16 @@ public final class SequenceIdParser { } } + public static String parseGenbankProteinAccessor( final String query ) { + final Matcher m = GENBANK_PROTEIN_AC_PATTERN.matcher( query ); + if ( m.lookingAt() ) { + return m.group( 1 ); + } + else { + return null; + } + } + /** * Returns null if no match. * -- 1.7.10.2