- private void setArrowCursor() {
- try {
- _mainpanel.getCurrentTreePanel().setArrowCursor();
- }
- catch ( final Exception ex ) {
- // Do nothing.
- }
- }
-
- private void addExpressionValuesFromFile() {
- if ( ( getCurrentTreePanel() == null ) || ( getCurrentTreePanel().getPhylogeny() == null ) ) {
- JOptionPane.showMessageDialog( this,
- "Need to load evolutionary tree first",
- "Can Not Read Expression Values",
- JOptionPane.WARNING_MESSAGE );
- return;
- }
- final File my_dir = getCurrentDir();
- if ( my_dir != null ) {
- _values_filechooser.setCurrentDirectory( my_dir );
- }
- final int result = _values_filechooser.showOpenDialog( _contentpane );
- final File file = _values_filechooser.getSelectedFile();
- if ( ( file != null ) && ( file.length() > 0 ) && ( result == JFileChooser.APPROVE_OPTION ) ) {
- BasicTable<String> t = null;
- try {
- t = BasicTableParser.parse( file, "\t" );
- if ( t.getNumberOfColumns() < 2 ) {
- t = BasicTableParser.parse( file, "," );
- }
- if ( t.getNumberOfColumns() < 2 ) {
- t = BasicTableParser.parse( file, " " );
- }
- }
- catch ( final IOException e ) {
- JOptionPane.showMessageDialog( this,
- e.getMessage(),
- "Could Not Read Expression Value Table",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- if ( t.getNumberOfColumns() < 2 ) {
- JOptionPane.showMessageDialog( this,
- "Table contains " + t.getNumberOfColumns() + " column(s)",
- "Problem with Expression Value Table",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- if ( t.getNumberOfRows() < 1 ) {
- JOptionPane.showMessageDialog( this,
- "Table contains zero rows",
- "Problem with Expression Value Table",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
- if ( t.getNumberOfRows() != phy.getNumberOfExternalNodes() ) {
- JOptionPane.showMessageDialog( this,
- "Table contains " + t.getNumberOfRows() + " rows, but tree contains "
- + phy.getNumberOfExternalNodes() + " external nodes",
- "Warning",
- JOptionPane.WARNING_MESSAGE );
- }
- final DescriptiveStatistics stats = new BasicDescriptiveStatistics();
- int not_found = 0;
- for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
- final PhylogenyNode node = iter.next();
- final String node_name = node.getName();
- if ( !ForesterUtil.isEmpty( node_name ) ) {
- int row = -1;
- try {
- row = t.findRow( node_name );
- }
- catch ( final IllegalArgumentException e ) {
- JOptionPane
- .showMessageDialog( this,
- e.getMessage(),
- "Error Mapping Node Identifiers to Expression Value Identifiers",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- if ( row < 0 ) {
- if ( node.isExternal() ) {
- not_found++;
- }
- continue;
- }
- final List<Double> l = new ArrayList<Double>();
- for( int col = 1; col < t.getNumberOfColumns(); ++col ) {
- double d = -100;
- try {
- d = Double.parseDouble( t.getValueAsString( col, row ) );
- }
- catch ( final NumberFormatException e ) {
- JOptionPane.showMessageDialog( this,
- "Could not parse \"" + t.getValueAsString( col, row )
- + "\" into a decimal value",
- "Issue with Expression Value Table",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- stats.addValue( d );
- l.add( d );
- }
- if ( !l.isEmpty() ) {
- if ( node.getNodeData().getProperties() != null ) {
- node.getNodeData().getProperties()
- .removePropertiesWithGivenReferencePrefix( PhyloXmlUtil.VECTOR_PROPERTY_REF );
- }
- node.getNodeData().setVector( l );
- }
- }
- }
- if ( not_found > 0 ) {
- JOptionPane.showMessageDialog( this, "Could not fine expression values for " + not_found
- + " external node(s)", "Warning", JOptionPane.WARNING_MESSAGE );
- }
- getCurrentTreePanel().setStatisticsForExpressionValues( stats );
- }
- }
-