- total += counter;
- proteins_file_writer.close();
- }
- ForesterUtil.programMessage( "surfacing",
- "Wrote " + total + " individual " + b + " from a total of "
- + all_features.size() + " into: " + dir );
- }
- }
-
- public final static void calcNEW( final boolean use_domain_architectures,
- final Phylogeny tre,
- final int level,
- final SortedMap<Species, List<Protein>> protein_lists_per_species,
- final String separator,
- final double ie_cutoff,
- final String outfile_base,
- final boolean write_protein_files )
- throws IOException {
- final SortedMap<String, SortedSet<String>> species_to_features_map = new TreeMap<String, SortedSet<String>>();
- if ( protein_lists_per_species == null || tre == null ) {
- throw new IllegalArgumentException( "argument is null" );
- }
- if ( protein_lists_per_species.size() < 2 ) {
- throw new IllegalArgumentException( "not enough genomes" );
- }
- final String x;
- if ( use_domain_architectures ) {
- x = "DA";
- }
- else {
- x = "domain";
- }
- final File outfile = new File( outfile_base + "_minimal_" + x + "ome.tsv" );
- final File outfile_table = new File( outfile_base + "_minimal_" + x + "ome_matrix.tsv" );
- SurfacingUtil.checkForOutputFileWriteability( outfile );
- SurfacingUtil.checkForOutputFileWriteability( outfile_table );
- final BufferedWriter out = new BufferedWriter( new FileWriter( outfile ) );
- final BufferedWriter out_table = new BufferedWriter( new FileWriter( outfile_table ) );
- out.write( "SPECIES\tCOMMON NAME\tCODE\tRANK\t#EXT NODES\tEXT NODE CODES\t#" + x + "\t" + x + "" );
- out.write( ForesterUtil.LINE_SEPARATOR );
- ///////////
- //////////
- SortedMap<String, List<Protein>> protein_lists_per_quasi_species = null;
- if ( level >= 1 ) {
- protein_lists_per_quasi_species = makeProteinListsPerQuasiSpecies( tre, level, protein_lists_per_species );
- }
- /////////
- ///////////
- for( final PhylogenyNodeIterator iter = tre.iteratorPostorder(); iter.hasNext(); ) {
- final PhylogenyNode node = iter.next();
- final String species_name = node.getNodeData().isHasTaxonomy()
- ? node.getNodeData().getTaxonomy().getScientificName() : node.getName();
- final String common = node.getNodeData().isHasTaxonomy() ? node.getNodeData().getTaxonomy().getCommonName()
- : "";
- final String tcode = node.getNodeData().isHasTaxonomy() ? node.getNodeData().getTaxonomy().getTaxonomyCode()
- : "";
- final String rank = node.getNodeData().isHasTaxonomy() ? node.getNodeData().getTaxonomy().getRank() : "";
- out.write( species_name );
- if ( !ForesterUtil.isEmpty( common ) ) {
- out.write( "\t" + common );
- }
- else {
- out.write( "\t" );
- }
- if ( !ForesterUtil.isEmpty( tcode ) ) {
- out.write( "\t" + tcode );
- }
- else {
- out.write( "\t" );
- }
- if ( !ForesterUtil.isEmpty( rank ) ) {
- out.write( "\t" + rank );
- }
- else {
- out.write( "\t" );
- }
- final List<PhylogenyNode> external_descs = node.getAllExternalDescendants();
- if ( node.isInternal() ) {
- out.write( "\t" + external_descs.size() + "\t" );
- }
- else {
- out.write( "\t\t" );