+ a = "_domain";
+ b = "domains";
+ protdirname = "_DOMAINS";
+ }
+ final File prot_dir = new File( outfile_base + protdirname );
+ final boolean success = prot_dir.mkdir();
+ if ( !success ) {
+ throw new IOException( "failed to create dir " + prot_dir );
+ }
+ int total = 0;
+ final String dir = outfile_base + protdirname + "/";
+ for( final String feat : all_features ) {
+ final File extract_outfile = new File( dir + feat + a + surfacing.SEQ_EXTRACT_SUFFIX );
+ SurfacingUtil.checkForOutputFileWriteability( extract_outfile );
+ final Writer proteins_file_writer = new BufferedWriter( new FileWriter( extract_outfile ) );
+ final int counter = extractProteinFeatures( use_domain_architectures,
+ protein_lists_per_species,
+ feat,
+ proteins_file_writer,
+ ie_cutoff,
+ separator );
+ if ( counter < 1 ) {
+ ForesterUtil.printWarningMessage( "surfacing", feat + " not present (in " + b + " extraction)" );
+ }
+ total += counter;
+ proteins_file_writer.close();
+ }
+ ForesterUtil.programMessage( "surfacing",
+ "Wrote " + total + " individual " + b + " from a total of "
+ + all_features.size() + " into: " + dir );
+ }
+ }
+
+ private final static SortedMap<String, List<Protein>> makeProteinListsPerQuasiSpecies( final Phylogeny tre,
+ final int level,
+ final SortedMap<Species, List<Protein>> protein_lists_per_species ) {
+ final SortedMap<String, List<Protein>> protein_lists_per_quasi_species = new TreeMap<String, List<Protein>>();
+ System.out.println( "---------------------------------" );
+ System.out.println( "level=" + level );
+ for( final PhylogenyNodeIterator iter = tre.iteratorPostorder(); iter.hasNext(); ) {
+ final PhylogenyNode node = iter.next();
+ final int node_level = PhylogenyMethods.calculateLevel( node );
+ if ( node_level == level ) {
+ System.out.println( "level=" + level );
+ final List<PhylogenyNode> external_descs = node.getAllExternalDescendants();
+ final List<Protein> protein_list_per_quasi_species = new ArrayList<Protein>();
+ for( final PhylogenyNode external_desc : external_descs ) {
+ final String code = external_desc.getNodeData().getTaxonomy().getTaxonomyCode();
+ final List<Protein> proteins_per_species = protein_lists_per_species
+ .get( new BasicSpecies( code ) );
+ //System.out.println( code );
+ for( Protein protein : proteins_per_species ) {
+ protein_list_per_quasi_species.add( protein );
+ }
+ }
+ final String species_name = node.getNodeData().isHasTaxonomy()
+ ? node.getNodeData().getTaxonomy().getScientificName() : node.getName();
+ System.out.println( "species_name=" + species_name );
+ protein_lists_per_quasi_species.put( species_name, protein_list_per_quasi_species );
+ System.out.println( ">>>>" + protein_list_per_quasi_species.size() );