From 94fab44b4568a8c49d9766c7f49eefac2d8f22ff Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Mon, 15 Jul 2013 23:56:47 +0000 Subject: [PATCH] inprogress --- .../src/org/forester/application/surfacing.java | 8 ++- .../surfacing/PairwiseGenomeComparator.java | 1 + .../surfacing/PrintableDomainSimilarity.java | 12 +++- .../surfacing/PrintableSpeciesSpecificDcData.java | 70 ++++++++++++-------- .../src/org/forester/surfacing/SurfacingUtil.java | 6 ++ 5 files changed, 65 insertions(+), 32 deletions(-) diff --git a/forester/java/src/org/forester/application/surfacing.java b/forester/java/src/org/forester/application/surfacing.java index 6f22a3a..095f730 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.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() ) + "" + nl ); html_desc.append( "" + 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 ) + "\"" ); } diff --git a/forester/java/src/org/forester/surfacing/PairwiseGenomeComparator.java b/forester/java/src/org/forester/surfacing/PairwiseGenomeComparator.java index c020d82..eba55ae 100644 --- a/forester/java/src/org/forester/surfacing/PairwiseGenomeComparator.java +++ b/forester/java/src/org/forester/surfacing/PairwiseGenomeComparator.java @@ -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, diff --git a/forester/java/src/org/forester/surfacing/PrintableDomainSimilarity.java b/forester/java/src/org/forester/surfacing/PrintableDomainSimilarity.java index f9a13ef..905e928 100644 --- a/forester/java/src/org/forester/surfacing/PrintableDomainSimilarity.java +++ b/forester/java/src/org/forester/surfacing/PrintableDomainSimilarity.java @@ -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( "
" ); } 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; } diff --git a/forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDcData.java b/forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDcData.java index e54142f..2cfbf0b 100644 --- a/forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDcData.java +++ b/forester/java/src/org/forester/surfacing/PrintableSpeciesSpecificDcData.java @@ -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 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( "" + domain_id - + "" ); + 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 ids = getCombinableDomainIdToCountsMap().keySet(); + int i = 0; + for( final String domain_id : ids ) { + ++i; + sb.append( " " ); + if ( html ) { + sb.append( "" + domain_id + + "" ); + } + 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; } diff --git a/forester/java/src/org/forester/surfacing/SurfacingUtil.java b/forester/java/src/org/forester/surfacing/SurfacingUtil.java index 8c0c8b4..ecb0839 100644 --- a/forester/java/src/org/forester/surfacing/SurfacingUtil.java +++ b/forester/java/src/org/forester/surfacing/SurfacingUtil.java @@ -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 split_writers, final SortedSet 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 ); -- 1.7.10.2