- /**
- * Returns a String containg the names of orthologs of the PhylogenyNode
- * with seq name query_name. The String also contains how many times a
- * particular ortholog has been observed.
- * <p>
- * <ul>
- * The output order is (per line): Name, Ortholog, Subtree neighbor, Super
- * ortholog, Distance
- * </ul>
- * <p>
- * The sort priority of this is determined by sort in the following manner:
- * <ul>
- * <li>0 : Ortholog
- * <li>1 : Ortholog, Super ortholog
- * <li>2 : Super ortholog, Ortholog
- * </ul>
- * <p>
- * Returns "-" if no putative orthologs have been found (given
- * threshold_orthologs).
- * <p>
- * Orthologs are to be inferred by method "inferOrthologs".
- * <p>
- * (Last modified: 05/08/01)
- *
- * @param query_name
- * sequence name of a external node of the gene trees
- * @param sort
- * order and sort priority
- * @param threshold_orthologs
- * the minimal number of observations for a a sequence to be
- * reported as orthologous, in percents (0.0-100.0%)
- * @param threshold_subtreeneighborings
- * the minimal number of observations for a a sequence to be
- * reported as orthologous, in percents (0.0-100.0%)
- * @return String containing the inferred orthologs, String containing "-"
- * if no orthologs have been found null in case of error
- */
- public final StringBuffer inferredOrthologsToString( final String query_name, int sort, double threshold_orthologs ) {
- HashMap<String, Integer> o_hashmap = null;
- HashMap<String, Integer> s_hashmap = null;
- String name = "";
- double o = 0.0; // Orthologs.
- double s = 0.0; // Super orthologs.
- double value1 = 0.0;
- double value2 = 0.0;
- final ArrayList<ResultLine> nv = new ArrayList<ResultLine>();
- if ( ( _o_maps == null ) || ( _so_maps == null ) ) {
- throw new RuntimeException( "orthologs have not been calculated (successfully)" );
- }
- if ( ( sort < 0 ) || ( sort > 2 ) ) {
- sort = 1;
- }
- if ( threshold_orthologs < 0.0 ) {
- threshold_orthologs = 0.0;
- }
- else if ( threshold_orthologs > 100.0 ) {
- threshold_orthologs = 100.0;
- }
- o_hashmap = getInferredOrthologs( query_name );
- s_hashmap = getInferredSuperOrthologs( query_name );
- if ( ( o_hashmap == null ) || ( s_hashmap == null ) ) {
- throw new RuntimeException( "Orthologs for " + query_name + " were not established" );
- }
- final StringBuffer orthologs = new StringBuffer();
- if ( _seq_names.size() > 0 ) {
- I: for( int i = 0; i < _seq_names.size(); ++i ) {
- name = _seq_names.get( i );
- if ( name.equals( query_name ) ) {
- continue I;
- }
- o = getBootstrapValueFromHash( o_hashmap, name );
- if ( o < threshold_orthologs ) {
- continue I;
- }
- s = getBootstrapValueFromHash( s_hashmap, name );
- switch ( sort ) {
- case 0:
- nv.add( new ResultLine( name, o, 5 ) );
- break;
- case 1:
- nv.add( new ResultLine( name, o, s, 5 ) );
- break;
- case 2:
- nv.add( new ResultLine( name, s, o, 5 ) );
- break;
- default:
- nv.add( new ResultLine( name, o, 5 ) );
- }
- } // End of I for loop.
- if ( ( nv != null ) && ( nv.size() > 0 ) ) {
- orthologs.append( "seq name\t\tortho\ts-ortho" + ForesterUtil.LINE_SEPARATOR );
- final ResultLine[] nv_array = new ResultLine[ nv.size() ];
- for( int j = 0; j < nv.size(); ++j ) {
- nv_array[ j ] = nv.get( j );
- }
- Arrays.sort( nv_array );
- for( final ResultLine element : nv_array ) {
- name = element.getKey();
- value1 = element.getValue1();
- value2 = element.getValue2();
- orthologs.append( addNameAndValues( name, value1, value2, sort ) );
- }
- }
- }
- // No orthologs found.
- if ( ( orthologs == null ) || ( orthologs.length() < 1 ) ) {
- orthologs.append( "-" );
- }
- return orthologs;