import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
final static private String INPUT_SPECIES_TREE_OPTION = "species_tree";
final static private String SEQ_EXTRACT_OPTION = "prot_extract";
final static private char SEPARATOR_FOR_INPUT_VALUES = '#';
- final static private String PRG_VERSION = "2.100";
- final static private String PRG_DATE = "2011.06.17";
+ final static private String PRG_VERSION = "2.200";
+ final static private String PRG_DATE = "2011.10.18";
final static private String E_MAIL = "czmasek@burnham.org";
final static private String WWW = "www.phylosoft.org/forester/applications/surfacing";
final static private boolean IGNORE_DUFS_DEFAULT = true;
final SortedSet<String> domains_which_are_always_single = new TreeSet<String>();
final SortedSet<String> domains_which_are_sometimes_single_sometimes_not = new TreeSet<String>();
final SortedSet<String> domains_which_never_single = new TreeSet<String>();
- final BufferedWriter domains_which_are_always_single_writer = null;
- final BufferedWriter domains_which_are_sometimes_single_sometimes_not_writer = null;
- final BufferedWriter domains_which_never_single_writer = null;
- BufferedWriter all_genomes_domains_per_potein_histo_writer = null;
BufferedWriter domains_per_potein_stats_writer = null;
try {
- all_genomes_domains_per_potein_histo_writer = new BufferedWriter( new FileWriter( out_dir
- + ForesterUtil.FILE_SEPARATOR + output_file + "__all_genomes_domains_per_potein_histo.txt" ) );
domains_per_potein_stats_writer = new BufferedWriter( new FileWriter( out_dir + ForesterUtil.FILE_SEPARATOR
+ output_file + "__domains_per_potein_stats.txt" ) );
domains_per_potein_stats_writer.write( "Genome" );
domains_per_potein_stats_writer.write( "\n" );
domains_per_potein_stats_writer.flush();
domains_per_potein_stats_writer.close();
- for( final Entry<Integer, Integer> entry : all_genomes_domains_per_potein_histo.entrySet() ) {
- all_genomes_domains_per_potein_histo_writer.write( entry.getKey() + "\t" + entry.getValue() + "\n" );
- }
- all_genomes_domains_per_potein_histo_writer.flush();
- all_genomes_domains_per_potein_histo_writer.close();
+ ForesterUtil.map2file( new File( out_dir + ForesterUtil.FILE_SEPARATOR + output_file
+ + "__all_genomes_domains_per_potein_histo.txt" ), all_genomes_domains_per_potein_histo, "\t", "\n" );
+ ForesterUtil.collection2file( new File( out_dir + ForesterUtil.FILE_SEPARATOR + output_file
+ + "__domains_always_single_.txt" ), domains_which_are_always_single, "\n" );
+ ForesterUtil.collection2file( new File( out_dir + ForesterUtil.FILE_SEPARATOR + output_file
+ + "__domains_single_or_combined.txt" ), domains_which_are_sometimes_single_sometimes_not, "\n" );
+ ForesterUtil.collection2file( new File( out_dir + ForesterUtil.FILE_SEPARATOR + output_file
+ + "__domains_always_combined.txt" ), domains_which_never_single, "\n" );
}
catch ( final IOException e2 ) {
ForesterUtil.fatalError( surfacing.PRG_NAME, e2.getLocalizedMessage() );
}
- //
if ( query_domains_writer_ary != null ) {
for( int j = 0; j < query_domain_ids_array.length; j++ ) {
try {
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
+import java.io.Writer;
import java.math.BigDecimal;
import java.net.URL;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
return s.replaceAll( "[\\s]+", " " );
}
+ final public static void collection2file( final File file, final Collection<?> data, final String separator )
+ throws IOException {
+ final Writer writer = new BufferedWriter( new FileWriter( file ) );
+ collection2writer( writer, data, separator );
+ writer.close();
+ }
+
+ final public static void collection2writer( final Writer writer, final Collection<?> data, final String separator )
+ throws IOException {
+ boolean first = true;
+ for( final Object object : data ) {
+ if ( !first ) {
+ writer.write( separator );
+ }
+ else {
+ first = false;
+ }
+ writer.write( object.toString() );
+ }
+ }
+
final public static String colorToHex( final Color color ) {
final String rgb = Integer.toHexString( color.getRGB() );
return rgb.substring( 2, rgb.length() );
return map;
}
+ final public static void map2file( final File file,
+ final Map<?, ?> data,
+ final String entry_separator,
+ final String data_separator ) throws IOException {
+ final Writer writer = new BufferedWriter( new FileWriter( file ) );
+ map2writer( writer, data, entry_separator, data_separator );
+ writer.close();
+ }
+
+ final public static void map2writer( final Writer writer,
+ final Map<?, ?> data,
+ final String entry_separator,
+ final String data_separator ) throws IOException {
+ for( final Entry<?, ?> entry : data.entrySet() ) {
+ boolean first = true;
+ if ( !first ) {
+ writer.write( data_separator );
+ }
+ else {
+ first = false;
+ }
+ writer.write( entry.getKey().toString() );
+ writer.write( entry_separator );
+ writer.write( entry.getValue().toString() );
+ }
+ }
+
final public static StringBuffer mapToStringBuffer( final Map map, final String key_value_separator ) {
final StringBuffer sb = new StringBuffer();
for( final Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
return str.split( regex );
}
+ final public static String stringArrayToString( final String[] a ) {
+ return stringArrayToString( a, ", " );
+ }
+
final public static String stringArrayToString( final String[] a, final String separator ) {
final StringBuilder sb = new StringBuilder();
if ( ( a != null ) && ( a.length > 0 ) ) {
return sb.toString();
}
+ final public static String[] stringListToArray( final List<String> list ) {
+ if ( list != null ) {
+ final String[] str = new String[ list.size() ];
+ int i = 0;
+ for( final String l : list ) {
+ str[ i++ ] = l;
+ }
+ return str;
+ }
+ return null;
+ }
+
final public static String stringListToString( final List<String> l, final String separator ) {
final StringBuilder sb = new StringBuilder();
if ( ( l != null ) && ( l.size() > 0 ) ) {
return sb.toString();
}
- final public static String stringArrayToString( final String[] a ) {
- return stringArrayToString( a, ", " );
- }
-
final public static String[] stringSetToArray( final Set<String> strings ) {
final String[] str_array = new String[ strings.size() ];
int i = 0;
return str_array;
}
- final public static String[] stringListToArray( final List<String> list ) {
- if ( list != null ) {
- final String[] str = new String[ list.size() ];
- int i = 0;
- for( final String l : list ) {
- str[ i++ ] = l;
- }
- return str;
- }
- return null;
- }
-
final public static void unexpectedFatalError( final String prg_name, final Exception e ) {
System.err.println();
System.err.println( "[" + prg_name