import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Accession;
import org.forester.phylogeny.data.BranchColor;
import org.forester.phylogeny.data.Distribution;
import org.forester.phylogeny.data.Sequence;
public final class AptxUtil {
+ private final static Pattern seq_identifier_pattern_1 = Pattern
+ .compile( "^([A-Za-z]{2,5})[|=:]([0-9A-Za-z_\\.]{5,40})\\s*$" );
+ private final static Pattern seq_identifier_pattern_2 = Pattern
+ .compile( "^([A-Za-z]{2,5})[|=:]([0-9A-Za-z_\\.]{5,40})[|,; ].*$" );
private final static String[] AVAILABLE_FONT_FAMILIES_SORTED = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getAvailableFontFamilyNames();
static {
Arrays.sort( AVAILABLE_FONT_FAMILIES_SORTED );
}
+ public final static Accession obtainSequenceAccessionFromName( final String sequence_name ) {
+ final String n = sequence_name.trim();
+ final Matcher matcher1 = seq_identifier_pattern_1.matcher( n );
+ String group1 = "";
+ String group2 = "";
+ if ( matcher1.matches() ) {
+ group1 = matcher1.group( 1 );
+ group2 = matcher1.group( 2 );
+ }
+ else {
+ final Matcher matcher2 = seq_identifier_pattern_2.matcher( n );
+ if ( matcher2.matches() ) {
+ group1 = matcher2.group( 1 );
+ group2 = matcher2.group( 2 );
+ }
+ }
+ if ( ForesterUtil.isEmpty( group1 ) || ForesterUtil.isEmpty( group2 ) ) {
+ return null;
+ }
+ return new Accession( group2, group1 );
+ }
+
public static void ensurePresenceOfTaxonomy( final PhylogenyNode node ) {
if ( !node.getNodeData().isHasTaxonomy() ) {
node.getNodeData().setTaxonomy( new Taxonomy() );
final PhylogenyParser parser = ParserUtils.createParserDependingOnFileType( intree, true );
Phylogeny[] phys = null;
phys = PhylogenyMethods.readPhylogenies( parser, intree );
+ writePhylogenyToGraphicsFile( phys[ 0 ], outfile, width, height, type, config );
+ }
+
+ public static void writePhylogenyToGraphicsFile( final Phylogeny phy,
+ final File outfile,
+ final int width,
+ final int height,
+ final GraphicsExportType type,
+ final Configuration config ) throws IOException {
+ final Phylogeny[] phys = new Phylogeny[ 1 ];
+ phys[ 0 ] = phy;
final MainFrameApplication mf = MainFrameApplication.createInstance( phys, config );
AptxUtil.writePhylogenyToGraphicsFileNonInteractive( outfile, width, height, mf.getMainPanel()
.getCurrentTreePanel(), mf.getMainPanel().getControlPanel(), type, mf.getOptions() );
}
}
- final static void launchWebBrowser( final URI uri,
- final boolean is_applet,
- final JApplet applet,
- final String frame_name ) throws IOException {
+ final public static void launchWebBrowser( final URI uri,
+ final boolean is_applet,
+ final JApplet applet,
+ final String frame_name ) throws IOException {
if ( is_applet ) {
applet.getAppletContext().showDocument( uri.toURL(), frame_name );
}
}
}
- final static void showErrorMessage( final Component parent, final String error_msg ) {
+ final public static void showErrorMessage( final Component parent, final String error_msg ) {
printAppletMessage( Constants.PRG_NAME, error_msg );
JOptionPane.showMessageDialog( parent, error_msg, "[" + Constants.PRG_NAME + " " + Constants.VERSION
+ "] Error", JOptionPane.ERROR_MESSAGE );