clean up
[jalview.git] / forester / java / src / org / forester / archaeopteryx / PhylogeneticInferenceOptions.java
1 // $Id:
2 // $
3 // FORESTER -- software libraries and applications
4 // for evolutionary biology research and applications.
5 //
6 // Copyright (C) 2008-2009 Christian M. Zmasek
7 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
8 // All rights reserved
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 //
24 // Contact: phylosoft @ gmail . com
25 // WWW: www.phylosoft.org/forester
26
27 package org.forester.archaeopteryx;
28
29 import java.io.File;
30
31 import org.forester.evoinference.distance.PairwiseDistanceCalculator.PWD_DISTANCE_METHOD;
32 import org.forester.msa.Mafft;
33
34 public final class PhylogeneticInferenceOptions {
35
36     private static final int                 BOOTSTRAP_RESAMPLES_DEFAULT                  = 100;
37     private static final PWD_DISTANCE_METHOD PWD_DISTANCE_METHOD_DEFAULT                  = PWD_DISTANCE_METHOD.KIMURA_DISTANCE;
38     public static final long                 RANDOM_NUMBER_SEED_DEFAULT                   = 42L;
39     private static final boolean             PERFORM_BOOTSTRAP_RESAMPLING_DEFAULT         = false;
40     private static final double              msa_processing_max_allowed_gap_ratio_default = 0.5;
41     private static final int                 msa_processing_min_allowed_length_default    = 50;
42     private int                              _bootstrap_samples;
43     private PWD_DISTANCE_METHOD              _pwd_distance_method;
44     private long                             _random_number_generator_seed;
45     private boolean                          _perform_bootstrap_resampling;
46     private String                           _intermediate_files_base;
47     private String                           _msa_prg_parameters;
48     private boolean                          _execute_msa_processing;
49     private boolean                          _msa_processing_remove_all_gap_columns;
50     private double                           _msa_processing_max_allowed_gap_ratio;
51     private int                              _msa_processing_min_allowed_length;
52     private boolean                          _save_pwd_file;
53     private boolean                          _save_processed_msa;
54     private boolean                          _save_original_msa;
55     private File                             _pwd_outfile;
56     private File                             _processed_msa_outfile;
57     private File                             _original_msa_outfile;
58
59     public synchronized String getMsaPrgParameters() {
60         return _msa_prg_parameters;
61     }
62
63     public synchronized void setMsaPrgParameters( final String msa_prg_parameters ) {
64         _msa_prg_parameters = new String( msa_prg_parameters );
65     }
66
67     public synchronized String getIntermediateFilesBase() {
68         return _intermediate_files_base;
69     }
70
71     public synchronized String getMsaPrg() {
72         return "MAFFT";
73     }
74
75     public synchronized void setIntermediateFilesBase( final String intermediate_files_base ) {
76         _intermediate_files_base = new String( intermediate_files_base );
77     }
78
79     public PhylogeneticInferenceOptions() {
80         init();
81     }
82
83     // Deep copy.
84     public synchronized PhylogeneticInferenceOptions copy() {
85         final PhylogeneticInferenceOptions o = new PhylogeneticInferenceOptions();
86         o._bootstrap_samples = _bootstrap_samples;
87         o._pwd_distance_method = _pwd_distance_method;
88         o._random_number_generator_seed = _random_number_generator_seed;
89         o._perform_bootstrap_resampling = _perform_bootstrap_resampling;
90         o._intermediate_files_base = new String( _intermediate_files_base );
91         o._msa_prg_parameters = new String( _msa_prg_parameters );
92         o._msa_processing_max_allowed_gap_ratio = _msa_processing_max_allowed_gap_ratio;
93         o._msa_processing_min_allowed_length = _msa_processing_min_allowed_length;
94         o._execute_msa_processing = _execute_msa_processing;
95         o._msa_processing_remove_all_gap_columns = _msa_processing_remove_all_gap_columns;
96         o._save_pwd_file = _save_pwd_file;
97         o._save_processed_msa = _save_processed_msa;
98         o._save_original_msa = _save_original_msa;
99         if ( _pwd_outfile != null ) {
100             o._pwd_outfile = new File( _pwd_outfile.toString() );
101         }
102         if ( _processed_msa_outfile != null ) {
103             o._processed_msa_outfile = new File( _processed_msa_outfile.toString() );
104         }
105         if ( _original_msa_outfile != null ) {
106             o._original_msa_outfile = new File( _original_msa_outfile.toString() );
107         }
108         return o;
109     }
110
111     private synchronized void init() {
112         _bootstrap_samples = BOOTSTRAP_RESAMPLES_DEFAULT;
113         _pwd_distance_method = PWD_DISTANCE_METHOD_DEFAULT;
114         _random_number_generator_seed = RANDOM_NUMBER_SEED_DEFAULT;
115         _perform_bootstrap_resampling = PERFORM_BOOTSTRAP_RESAMPLING_DEFAULT;
116         _intermediate_files_base = "";
117         _msa_prg_parameters = Mafft.getDefaultParameters();
118         _msa_processing_max_allowed_gap_ratio = msa_processing_max_allowed_gap_ratio_default;
119         _msa_processing_min_allowed_length = msa_processing_min_allowed_length_default;
120         _execute_msa_processing = false;
121         _msa_processing_remove_all_gap_columns = false;
122         _save_pwd_file = false;
123         _save_processed_msa = false;
124         _save_original_msa = false;
125         _pwd_outfile = null;
126         _processed_msa_outfile = null;
127         _original_msa_outfile = null;
128     }
129
130     public synchronized void setBootstrapSamples( final int bootstrap_samples ) {
131         _bootstrap_samples = bootstrap_samples;
132     }
133
134     public synchronized int getBootstrapSamples() {
135         return _bootstrap_samples;
136     }
137
138     public synchronized void setPwdDistanceMethod( final PWD_DISTANCE_METHOD pwd_distance_method ) {
139         _pwd_distance_method = pwd_distance_method;
140     }
141
142     public synchronized PWD_DISTANCE_METHOD getPwdDistanceMethod() {
143         return _pwd_distance_method;
144     }
145
146     public synchronized void setRandomNumberGeneratorSeed( final long random_number_generator_seed ) {
147         _random_number_generator_seed = random_number_generator_seed;
148     }
149
150     public synchronized long getRandomNumberGeneratorSeed() {
151         return _random_number_generator_seed;
152     }
153
154     public synchronized void setPerformBootstrapResampling( final boolean perform_bootstrap_resampling ) {
155         _perform_bootstrap_resampling = perform_bootstrap_resampling;
156     }
157
158     public synchronized boolean isPerformBootstrapResampling() {
159         return _perform_bootstrap_resampling;
160     }
161
162     public static PhylogeneticInferenceOptions createInstance( final Configuration configuration ) {
163         final PhylogeneticInferenceOptions o = new PhylogeneticInferenceOptions();
164         if ( configuration.getDefaultBootstrapSamples() >= 0 ) {
165             o.setBootstrapSamples( configuration.getDefaultBootstrapSamples() );
166         }
167         return o;
168     }
169
170     public File getTempDir() {
171         //TODO
172         return new File( "/Users/zma/Desktop/tmp/" );
173     }
174
175     public void setMsaProcessingMaxAllowedGapRatio( final double msa_processing_max_allowed_gap_ratio ) {
176         _msa_processing_max_allowed_gap_ratio = msa_processing_max_allowed_gap_ratio;
177     }
178
179     public double getMsaProcessingMaxAllowedGapRatio() {
180         return _msa_processing_max_allowed_gap_ratio;
181     }
182
183     public void setMsaProcessingMinAllowedLength( final int msa_processing_min_allowed_length ) {
184         _msa_processing_min_allowed_length = msa_processing_min_allowed_length;
185     }
186
187     public int getMsaProcessingMinAllowedLength() {
188         return _msa_processing_min_allowed_length;
189     }
190
191     boolean isExecuteMsaProcessing() {
192         return _execute_msa_processing;
193     }
194
195     void setExecuteMsaProcessing( final boolean execute_msa_processing ) {
196         _execute_msa_processing = execute_msa_processing;
197     }
198
199     boolean isMsaProcessingRemoveAllGapColumns() {
200         return _msa_processing_remove_all_gap_columns;
201     }
202
203     void setMsaProcessingRemoveAllGapColumns( final boolean msa_processing_remove_all_gap_columns ) {
204         _msa_processing_remove_all_gap_columns = msa_processing_remove_all_gap_columns;
205     }
206
207     boolean isSavePwdFile() {
208         return _save_pwd_file;
209     }
210
211     void setSavePwdFile( final boolean save_pwd_file ) {
212         _save_pwd_file = save_pwd_file;
213     }
214
215     boolean isSaveProcessedMsa() {
216         return _save_processed_msa;
217     }
218
219     void setSaveProcessedMsa( final boolean save_processed_msa ) {
220         _save_processed_msa = save_processed_msa;
221     }
222
223     boolean isSaveOriginalMsa() {
224         return _save_original_msa;
225     }
226
227     void setSaveOriginalMsa( final boolean save_original_msa ) {
228         _save_original_msa = save_original_msa;
229     }
230
231     File getPwdOutfile() {
232         return _pwd_outfile;
233     }
234
235     void setPwdOutfile( final File pwd_outfile ) {
236         _pwd_outfile = pwd_outfile;
237     }
238
239     File getProcesseMsaOutfile() {
240         return _processed_msa_outfile;
241     }
242
243     void setProcesseMsaOutfile( final File processed_msa_outfile ) {
244         _processed_msa_outfile = processed_msa_outfile;
245     }
246
247     File getOriginalMsaOutfile() {
248         return _original_msa_outfile;
249     }
250
251     void setOriginalMsaOutfile( final File original_msa_outfile ) {
252         _original_msa_outfile = original_msa_outfile;
253     }
254 }