inprogress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Mon, 15 Jul 2013 23:56:47 +0000 (23:56 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Mon, 15 Jul 2013 23:56:47 +0000 (23:56 +0000)
forester/java/src/org/forester/application/surfacing.java
forester/java/src/org/forester/surfacing/PairwiseGenomeComparator.java
forester/java/src/org/forester/surfacing/PrintableDomainSimilarity.java
forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDcData.java
forester/java/src/org/forester/surfacing/SurfacingUtil.java

index 6f22a3a..095f730 100644 (file)
@@ -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.301";
-    final static private String                               PRG_DATE                                                                      = "130712";
+    final static private String                               PRG_VERSION                                                                   = "2.302";
+    final static private String                               PRG_DATE                                                                      = "130715";
     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;
@@ -2071,8 +2071,11 @@ public class surfacing {
                     + new java.text.SimpleDateFormat( "yyyy.MM.dd HH:mm:ss" ).format( new java.util.Date() )
                     + "</td></tr>" + nl );
             html_desc.append( "</table>" + nl );
+            final Writer simple_tab_writer = new BufferedWriter( new FileWriter( out_dir + ForesterUtil.FILE_SEPARATOR
+                    + my_outfile + ".tsv" ) );
             SurfacingUtil.writeDomainSimilaritiesToFile( html_desc,
                                                          new StringBuilder( number_of_genomes + " genomes" ),
+                                                         simple_tab_writer,
                                                          writer,
                                                          split_writers,
                                                          similarities,
@@ -2082,6 +2085,7 @@ public class surfacing {
                                                          scoring,
                                                          true,
                                                          tax_code_to_id_map );
+            simple_tab_writer.close();
             ForesterUtil.programMessage( surfacing.PRG_NAME, "Wrote main output (includes domain similarities) to: \""
                     + ( out_dir == null ? my_outfile : out_dir + ForesterUtil.FILE_SEPARATOR + my_outfile ) + "\"" );
         }
index c020d82..eba55ae 100644 (file)
@@ -206,6 +206,7 @@ public class PairwiseGenomeComparator {
                                 : out_dir + ForesterUtil.FILE_SEPARATOR + pairwise_similarities_output_file_str ) );
                         SurfacingUtil.writeDomainSimilaritiesToFile( html_desc,
                                                                      new StringBuilder( species_i + "-" + species_j ),
+                                                                     null,
                                                                      writer,
                                                                      null,
                                                                      similarities,
index f9a13ef..905e928 100644 (file)
@@ -162,14 +162,19 @@ public class PrintableDomainSimilarity implements DomainSimilarity {
             sb.append( species.getSpeciesId() );
         }
         if ( getDetaildness() != DomainSimilarityCalculator.Detailedness.BASIC ) {
-            sb.append( ":" );
+            if ( html ) {
+                sb.append( ":" );
+            }
+            else {
+                sb.append( "\t" );
+            }
             sb.append( getSpeciesData().get( species ).toStringBuffer( getDetaildness(), html ) );
         }
         if ( html ) {
             sb.append( "<br>" );
         }
         else {
-            sb.append( PrintableDomainSimilarity.SPECIES_SEPARATOR );
+            sb.append( "\n\t" );
         }
     }
 
@@ -435,6 +440,9 @@ public class PrintableDomainSimilarity implements DomainSimilarity {
     private StringBuffer toStringBufferSimpleTabDelimited() {
         final StringBuffer sb = new StringBuffer();
         sb.append( getDomainId() );
+        sb.append( "\t" );
+        sb.append( getSpeciesDataInAlphabeticalOrder( false, null ) );
+        sb.append( "\n" );
         return sb;
     }
 
index e54142f..2cfbf0b 100644 (file)
@@ -97,46 +97,60 @@ 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( getKeyDomainDomainsCount() );
-            sb.append( ", " );
-            sb.append( getKeyDomainProteinsCount() );
-            sb.append( ", " );
-            sb.append( getCombinableDomainsCount() );
-            if ( !getCombinableDomainIdToCountsMap().isEmpty() ) {
-                sb.append( ":" );
+            if ( html ) {
+                sb.append( ", " );
             }
-        }
-        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( ", " );
             }
             else {
-                sb.append( domain_id );
+                sb.append( "\t" );
             }
-            if ( detailedness == DomainSimilarityCalculator.Detailedness.PUNCTILIOUS ) {
+            sb.append( getCombinableDomainsCount() );
+            if ( html && !getCombinableDomainIdToCountsMap().isEmpty() ) {
                 sb.append( ":" );
-                sb.append( getCombinableDomainIdToCountsMap().get( domain_id ) );
             }
         }
-        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();
+            int i = 0;
+            for( final String domain_id : ids ) {
+                ++i;
+                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( "]" );
         return sb;
     }
 
index 8c0c8b4..ecb0839 100644 (file)
@@ -83,6 +83,7 @@ import org.forester.protein.Protein;
 import org.forester.species.Species;
 import org.forester.surfacing.DomainSimilarityCalculator.Detailedness;
 import org.forester.surfacing.GenomeWideCombinableDomains.GenomeWideCombinableDomainsSortOrder;
+import org.forester.surfacing.PrintableDomainSimilarity.PRINT_OPTION;
 import org.forester.util.AsciiHistogram;
 import org.forester.util.BasicDescriptiveStatistics;
 import org.forester.util.BasicTable;
@@ -1667,6 +1668,7 @@ public final class SurfacingUtil {
 
     public static void writeDomainSimilaritiesToFile( final StringBuilder html_desc,
                                                       final StringBuilder html_title,
+                                                      final Writer simple_tab_writer,
                                                       final Writer single_writer,
                                                       Map<Character, Writer> split_writers,
                                                       final SortedSet<DomainSimilarity> similarities,
@@ -1745,6 +1747,10 @@ public final class SurfacingUtil {
             if ( ( species_order != null ) && !species_order.isEmpty() ) {
                 ( ( PrintableDomainSimilarity ) similarity ).setSpeciesOrder( species_order );
             }
+            if ( simple_tab_writer != null ) {
+                simple_tab_writer.write( similarity.toStringBuffer( PRINT_OPTION.SIMPLE_TAB_DELIMITED,
+                                                                    tax_code_to_id_map ).toString() );
+            }
             if ( single_writer != null ) {
                 single_writer.write( similarity.toStringBuffer( print_option, tax_code_to_id_map ).toString() );
                 single_writer.write( SurfacingConstants.NL );