import java.math.BigDecimal;
import java.net.URL;
import java.net.URLConnection;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.forester.archaeopteryx.Constants;
+import org.forester.archaeopteryx.AptxConstants;
+import org.forester.io.parsers.PhylogenyParser;
+import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Distribution;
import org.forester.phylogeny.data.Sequence;
import org.forester.phylogeny.data.Taxonomy;
+import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
import org.forester.protein.BasicProtein;
import org.forester.protein.Domain;
import org.forester.protein.Protein;
* This calculates a color. If value is equal to min the returned color is
* minColor, if value is equal to max the returned color is maxColor,
* otherwise a color 'proportional' to value is returned.
- *
+ *
* @param value
- * the value
+ * the value
* @param min
- * the smallest value
+ * the smallest value
* @param max
- * the largest value
+ * the largest value
* @param minColor
* the color for min
* @param maxColor
* value is equal to mean the returned color is meanColor, otherwise a color
* 'proportional' to value is returned -- either between min-mean or
* mean-max
- *
+ *
* @param value
* the value
* @param min
* the smallest value
* @param max
- * the largest value
+ * the largest value
* @param mean
- * the mean/median value
+ * the mean/median value
* @param minColor
* the color for min
* @param maxColor
/**
* Helper method for calcColor methods.
- *
+ *
* @param smallercolor_component_x
* color component the smaller color
* @param largercolor_component_x
/**
* Helper method for calcColor methods.
- *
- *
+ *
+ *
* @param value
* the value
* @param larger
/**
* Returns true is Domain domain falls in an uninterrupted stretch of
* covered positions.
- *
+ *
* @param domain
* @param covered_positions
* @return
* This determines whether String[] a and String[] b have at least one
* String in common (intersect). Returns false if at least one String[] is
* null or empty.
- *
+ *
* @param a
* a String[] b a String[]
* @return true if both a and b or not empty or null and contain at least
return OS_NAME.toLowerCase().startsWith( "mac" );
}
catch ( final Exception e ) {
- ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e );
+ ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "minor error: " + e );
return false;
}
}
return OS_NAME.toLowerCase().indexOf( "win" ) > -1;
}
catch ( final Exception e ) {
- ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e );
+ ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "minor error: " + e );
return false;
}
}
else if ( tax_group.equals( TaxonomyGroups.BACTERIA ) ) {
return TaxonomyColors.BACTERIA_COLOR;
}
+ else if ( tax_group.equals( TaxonomyGroups.VIRUSES ) ) {
+ return TaxonomyColors.VIRUSES_COLOR;
+ }
+ else if ( tax_group.equals( TaxonomyGroups.ALPHAHERPESVIRINAE ) ) {
+ return TaxonomyColors.ALPHAHERPESVIRINAE_COLOR;
+ }
+ else if ( tax_group.equals( TaxonomyGroups.BETAHERPESVIRINAE ) ) {
+ return TaxonomyColors.BETAHERPESVIRINAE_COLOR;
+ }
+ else if ( tax_group.equals( TaxonomyGroups.GAMMAHERPESVIRINAE ) ) {
+ return TaxonomyColors.GAMMAHERPESVIRINAE_COLOR;
+ }
+ else if ( tax_group.equals( TaxonomyGroups.OTHER ) ) {
+ return TaxonomyColors.OTHER_COLOR;
+ }
}
return null;
}
else if ( tax.equalsIgnoreCase( TaxonomyGroups.BACTERIA ) ) {
return TaxonomyGroups.BACTERIA;
}
+ else if ( tax.equalsIgnoreCase( TaxonomyGroups.BACTERIA ) ) {
+ return TaxonomyGroups.BACTERIA;
+ }
+ else if ( tax.equalsIgnoreCase( TaxonomyGroups.VIRUSES ) ) {
+ return TaxonomyGroups.VIRUSES;
+ }
+ else if ( tax.equalsIgnoreCase( TaxonomyGroups.ALPHAHERPESVIRINAE ) ) {
+ return TaxonomyGroups.ALPHAHERPESVIRINAE;
+ }
+ else if ( tax.equalsIgnoreCase( TaxonomyGroups.BETAHERPESVIRINAE ) ) {
+ return TaxonomyGroups.BETAHERPESVIRINAE ;
+ }
+ else if ( tax.equalsIgnoreCase( TaxonomyGroups.GAMMAHERPESVIRINAE ) ) {
+ return TaxonomyGroups.GAMMAHERPESVIRINAE;
+ }
return null;
}
}
else {
throw new IllegalArgumentException( "attempt to parse object of type [" + source.getClass()
- + "] (can only parse objects of type File, InputStream, String, or StringBuffer)" );
+ + "] (can only parse objects of type File, InputStream, String, or StringBuffer)" );
}
return reader;
}
}
/**
- *
+ *
* Example regarding engulfment: ------------0.1 ----------0.2 --0.3 =>
* domain with 0.3 is ignored
- *
+ *
* -----------0.1 ----------0.2 --0.3 => domain with 0.3 is ignored
- *
- *
+ *
+ *
* ------------0.1 ----------0.3 --0.2 => domains with 0.3 and 0.2 are _not_
* ignored
- *
+ *
* @param max_allowed_overlap
* maximal allowed overlap (inclusive) to be still considered not
* overlapping (zero or negative value to allow any overlap)
final boolean remove_engulfed_domains,
final Protein protein ) {
final Protein pruned_protein = new BasicProtein( protein.getProteinId().getId(), protein.getSpecies()
- .getSpeciesId(), protein.getLength() );
+ .getSpeciesId(), protein.getLength() );
final List<Domain> sorted = SurfacingUtil.sortDomainsWithAscendingConfidenceValues( protein );
final List<Boolean> covered_positions = new ArrayList<Boolean>();
for( final Domain domain : sorted ) {
/**
* Removes all white space from String s.
- *
+ *
* @return String s with white space removed
*/
final public static String removeWhiteSpace( String s ) {
final public static void unexpectedFatalError( final String prg_name, final Exception e ) {
System.err.println();
System.err.println( "[" + prg_name
- + "] > unexpected error; should not have occured! Please contact program author(s)." );
+ + "] > unexpected error; should not have occured! Please contact program author(s)." );
e.printStackTrace( System.err );
System.err.println();
System.exit( -1 );
final public static void unexpectedFatalError( final String prg_name, final String message ) {
System.err.println();
System.err.println( "[" + prg_name
- + "] > unexpected error: should not have occured! Please contact program author(s)." );
+ + "] > unexpected error: should not have occured! Please contact program author(s)." );
System.err.println( message );
System.err.println();
System.exit( -1 );
final public static void unexpectedFatalError( final String prg_name, final String message, final Exception e ) {
System.err.println();
System.err.println( "[" + prg_name
- + "] > unexpected error: should not have occured! Please contact program author(s)." );
+ + "] > unexpected error: should not have occured! Please contact program author(s)." );
System.err.println( message );
e.printStackTrace( System.err );
System.err.println();
return sb.toString();
}
+
+ public final static Phylogeny[] readPhylogeniesFromUrl( final URL url,
+ final PhylogenyParser parser )
+ throws NoSuchAlgorithmException, IOException, KeyManagementException {
+ if ( url == null ) {
+ throw new IllegalArgumentException( "URL to read from must not be null" );
+ }
+ else if ( parser == null ) {
+ throw new IllegalArgumentException( "parser to use to read from URL must not be null" );
+ }
+ final URLConnection con;
+ if ( url.toString().startsWith( "https:" ) ) {
+ con = TrustManager.makeHttpsURLConnection( url );
+ }
+ else if ( url.toString().startsWith( "http:" ) ) {
+ con = url.openConnection();
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot deal with URL: " + url );
+ }
+ if ( con == null ) {
+ throw new IOException( "could not create connection from " + url );
+ }
+ con.setDefaultUseCaches( false );
+ final InputStream is = con.getInputStream();
+ if ( is == null ) {
+ throw new IOException( "could not create input stream from " + url );
+ }
+ final Phylogeny[] trees = ParserBasedPhylogenyFactory.getInstance().create( is, parser );
+ try {
+ is.close();
+ }
+ catch ( final Exception e ) {
+ // ignore
+ }
+ return trees;
+ }
+
private ForesterUtil() {
}
}