File: remove_openchart_use

package info (click to toggle)
biojava4-live 4.2.12%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 107,344 kB
  • sloc: java: 246,196; xml: 27,590; sh: 95; makefile: 86; python: 64
file content (231 lines) | stat: -rw-r--r-- 11,640 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
Subject: forester needs openchart library
Description: biojava makes use of a limited set of forester
 As openchart is not available in Debian, remove openchart related calls
 to make forester compilation OK in biojava context
Author: Olivier Sallou <osallou@debian.org>
Last-Updated: 2016-12-09
Forwarded: no
--- a/biojava-forester/src/main/java/org/forester/msa_compactor/Chart.java
+++ b/biojava-forester/src/main/java/org/forester/msa_compactor/Chart.java
@@ -40,47 +40,22 @@
 
 import org.forester.util.ForesterUtil;
 
-import com.approximatrix.charting.coordsystem.BoxCoordSystem;
-import com.approximatrix.charting.model.MultiScatterDataModel;
-import com.approximatrix.charting.render.MultiScatterChartRenderer;
-import com.approximatrix.charting.swing.ChartPanel;
 
 public final class Chart extends JDialog implements ActionListener {
 
     final private static NumberFormat NF_1             = new DecimalFormat( "0.##" );
     private static final long         serialVersionUID = -5292420246132943515L;
-    private ChartPanel                _chart_panel     = null;
-    private final int                 _initial_number_of_seqs;
+    private final int                 _initial_number_of_seqs=0;
     private final JMenuItem           _m_exit          = new JMenuItem();
-    private final List<MsaProperties> _msa_props;
-    private final boolean             _show_msa_qual;
-    private final String              _title;
+    private final List<MsaProperties> _msa_props=null;
+    private final boolean             _show_msa_qual=false;
+    private final String              _title=null;
 
     private Chart( final List<MsaProperties> msa_props,
                    final int initial_number_of_seqs,
                    final boolean show_msa_qual,
                    final String title ) {
         super();
-        _msa_props = msa_props;
-        _title = title;
-        _initial_number_of_seqs = initial_number_of_seqs;
-        _show_msa_qual = show_msa_qual;
-        setTitle( "msa compactor" );
-        setSize( 600, 500 );
-        setResizable( true );
-        final JPanel content_pane = new JPanel();
-        content_pane.setLayout( new BorderLayout() );
-        setContentPane( content_pane );
-        final JMenuBar menu_bar = new JMenuBar();
-        final JMenu file_menu = new JMenu();
-        file_menu.setText( "File" );
-        _m_exit.setText( "Exit" );
-        file_menu.add( _m_exit );
-        menu_bar.add( file_menu );
-        setJMenuBar( menu_bar );
-        setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
-        _m_exit.addActionListener( this );
-        content_pane.add( obtainChartPanel(), BorderLayout.CENTER );
     }
 
     @Override
@@ -90,150 +65,4 @@
         }
     }
 
-    private ChartPanel obtainChartPanel() {
-        if ( _chart_panel == null ) {
-            final MultiScatterDataModel model = new MultiScatterDataModel();
-            final double[][] seqs_length = new double[ _msa_props.size() ][ 2 ];
-            int max_length = -1;
-            int min_length = Integer.MAX_VALUE;
-            double max_gap_ratio = -1;
-            double min_gap_ratio = Double.MAX_VALUE;
-            double max_avg_gap_count = -1;
-            double min_avg_gap_count = Double.MAX_VALUE;
-            for( int i = 0; i < _msa_props.size(); ++i ) {
-                seqs_length[ i ][ 0 ] = _initial_number_of_seqs - _msa_props.get( i ).getNumberOfSequences();
-                //
-                final int length = _msa_props.get( i ).getLength();
-                seqs_length[ i ][ 1 ] = length;
-                if ( length > max_length ) {
-                    max_length = length;
-                }
-                if ( length < min_length ) {
-                    min_length = length;
-                }
-                //
-                final double gap_ratio = _msa_props.get( i ).getGapRatio();
-                if ( gap_ratio > max_gap_ratio ) {
-                    max_gap_ratio = gap_ratio;
-                }
-                if ( gap_ratio < min_gap_ratio ) {
-                    min_gap_ratio = gap_ratio;
-                }
-                //
-                final double avg_gap_count = _msa_props.get( i ).getAvgNumberOfGaps();
-                if ( avg_gap_count > max_avg_gap_count ) {
-                    max_avg_gap_count = avg_gap_count;
-                }
-                if ( avg_gap_count < min_avg_gap_count ) {
-                    min_avg_gap_count = avg_gap_count;
-                }
-            }
-            model.addData( seqs_length, "Length" + " (" + minMaxToString( min_length, max_length ) + ")" );
-            model.setSeriesLine( "Series " + "Length", true );
-            model.setSeriesMarker( "Series " + "Length", false );
-            final double[][] seqs_gaps = new double[ _msa_props.size() ][ 2 ];
-            double max_ent7 = -1;
-            double max_ent21 = -1;
-            double min_ent7 = Double.MAX_VALUE;
-            double min_ent21 = Double.MAX_VALUE;
-            if ( _show_msa_qual ) {
-                for( int i = 0; i < _msa_props.size(); ++i ) {
-                    final double ent7 = _msa_props.get( i ).getEntropy7();
-                    if ( ent7 > max_ent7 ) {
-                        max_ent7 = ent7;
-                    }
-                    if ( ent7 < max_ent7 ) {
-                        min_ent7 = ent7;
-                    }
-                    final double ent21 = _msa_props.get( i ).getEntropy21();
-                    if ( ent21 > min_ent21 ) {
-                        max_ent21 = ent21;
-                    }
-                    if ( ent21 < min_ent21 ) {
-                        min_ent21 = ent21;
-                    }
-                }
-            }
-            final double gap_ratio_factor = ( max_length / 2.0 ) / max_gap_ratio;
-            final double avg_gaps_counts_factor = ( max_length / 2.0 ) / max_avg_gap_count;
-            final double ent7_factor = ( max_length / 2.0 ) / max_ent7;
-            final double ent21_factor = ( max_length / 2.0 ) / max_ent21;
-            for( int i = 0; i < _msa_props.size(); ++i ) {
-                seqs_gaps[ i ][ 0 ] = _initial_number_of_seqs - _msa_props.get( i ).getNumberOfSequences();
-                seqs_gaps[ i ][ 1 ] = ForesterUtil.roundToInt( _msa_props.get( i ).getGapRatio() * gap_ratio_factor );
-            }
-            model.addData( seqs_gaps, "Gap Ratio" + " (" + minMaxToString( min_gap_ratio, max_gap_ratio ) + ")" );
-            model.setSeriesLine( "Series " + "Gap Ratio", true );
-            model.setSeriesMarker( "Series " + "Gap Ratio", false );
-            final double[][] gap_counts = new double[ _msa_props.size() ][ 2 ];
-            for( int i = 0; i < _msa_props.size(); ++i ) {
-                gap_counts[ i ][ 0 ] = _initial_number_of_seqs - _msa_props.get( i ).getNumberOfSequences();
-                gap_counts[ i ][ 1 ] = ForesterUtil.roundToInt( _msa_props.get( i ).getAvgNumberOfGaps()
-                                                                * avg_gaps_counts_factor );
-            }
-            model.addData( gap_counts, "Mean Gap Count" + " (" + minMaxToString( min_avg_gap_count, max_avg_gap_count )
-                    + ")" );
-            model.setSeriesLine( "Series " + "Mean Gap Count", true );
-            model.setSeriesMarker( "Series " + "Mean Gap Count", false );
-            if ( _show_msa_qual ) {
-                final double[][] entropy7 = new double[ _msa_props.size() ][ 2 ];
-                for( int i = 0; i < _msa_props.size(); ++i ) {
-                    entropy7[ i ][ 0 ] = _initial_number_of_seqs - _msa_props.get( i ).getNumberOfSequences();
-                    entropy7[ i ][ 1 ] = ForesterUtil.roundToInt( _msa_props.get( i ).getEntropy7() * ent7_factor );
-                }
-                model.addData( entropy7, "Entropy norm 7" + " (" + minMaxToString( min_ent7, max_ent7 ) + ")" );
-                model.setSeriesLine( "Series " + "Entropy norm 7", true );
-                model.setSeriesMarker( "Series " + "Entropy norm 7", false );
-                //
-                final double[][] entropy21 = new double[ _msa_props.size() ][ 2 ];
-                for( int i = 0; i < _msa_props.size(); ++i ) {
-                    entropy21[ i ][ 0 ] = _initial_number_of_seqs - _msa_props.get( i ).getNumberOfSequences();
-                    entropy21[ i ][ 1 ] = ForesterUtil.roundToInt( _msa_props.get( i ).getEntropy21() * ent21_factor );
-                }
-                model.addData( entropy21, "Entropy norm 21" + " (" + minMaxToString( min_ent21, max_ent21 ) + ")" );
-                model.setSeriesLine( "Series " + "Entropy norm 21", true );
-                model.setSeriesMarker( "Series " + "Entropy norm 21", false );
-            }
-            final BoxCoordSystem coord = new BoxCoordSystem( model );
-            coord.setUnitFont( coord.getUnitFont().deriveFont( 16.0f ) );
-            coord.setXAxisUnit( "Number of Removed Sequences" );
-            coord.setPaintGrid( true );
-            coord.setYAxisUnit( "MSA Length" );
-            _chart_panel = new ChartPanel( model, _title );
-            _chart_panel.setCoordSystem( coord );
-            final MultiScatterChartRenderer renderer = new MultiScatterChartRenderer( coord, model );
-            renderer.setAllowBuffer( false );
-            _chart_panel.addChartRenderer( renderer, 0 );
-        }
-        return _chart_panel;
-    }
-
-    private final static String minMaxToString( final double min, final double max ) {
-        return NF_1.format( min ) + "-" + NF_1.format( max );
-    }
-
-    public static void display( final List<MsaProperties> msa_props,
-                                final int initial_number_of_seqs,
-                                final boolean show_msa_qual,
-                                final String title ) {
-        try {
-            UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
-        }
-        catch ( final Exception e ) {
-            e.printStackTrace();
-        }
-        final Chart chart = new Chart( msa_props, initial_number_of_seqs, show_msa_qual, title );
-        chart.setVisible( true );
-    }
-
-    public static void main( final String[] args ) {
-        try {
-            UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
-        }
-        catch ( final Exception e ) {
-            e.printStackTrace();
-        }
-        final Chart temp = new Chart( null, 0, true, "title" );
-        temp.setVisible( true );
-    }
 }
--- a/biojava-forester/src/main/java/org/forester/application/msa_compactor.java
+++ b/biojava-forester/src/main/java/org/forester/application/msa_compactor.java
@@ -39,7 +39,6 @@
 import org.forester.msa.Msa.MSA_FORMAT;
 import org.forester.msa.MsaInferrer;
 import org.forester.msa.MsaMethods;
-import org.forester.msa_compactor.Chart;
 import org.forester.msa_compactor.MsaCompactor;
 import org.forester.msa_compactor.MsaProperties;
 import org.forester.util.CommandLineArguments;
@@ -396,7 +395,7 @@
                 else {
                     msa_props = mc.chart( step, realign, normalize_for_effective_seq_length );
                 }
-                Chart.display( msa_props, initial_number_of_seqs, report_entropy, in.getName() );
+                //Chart.display( msa_props, initial_number_of_seqs, report_entropy, in.getName() );
                 System.out.println();
                 System.out.println( "Final MSA properties" );
                 printMsaInfo( msa,  MsaMethods.calculateEffectiveLengthStatistics( msa ));