inprogress
[jalview.git] / forester / java / src / org / forester / archaeopteryx / tools / 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: https://sites.google.com/site/cmzmasek/home/software/forester
26
27 package org.forester.archaeopteryx.tools;
28
29 import java.io.File;
30
31 import org.forester.archaeopteryx.Configuration;
32 import org.forester.evoinference.distance.PairwiseDistanceCalculator.PWD_DISTANCE_METHOD;
33 import org.forester.msa.Mafft;
34
35 public final class PhylogeneticInferenceOptions {
36
37     private static final int                 BOOTSTRAP_RESAMPLES_DEFAULT                  = 100;
38     private static final PWD_DISTANCE_METHOD PWD_DISTANCE_METHOD_DEFAULT                  = PWD_DISTANCE_METHOD.KIMURA_DISTANCE;
39     public static final long                 RANDOM_NUMBER_SEED_DEFAULT                   = 42L;
40     private static final boolean             PERFORM_BOOTSTRAP_RESAMPLING_DEFAULT         = false;
41     private static final double              msa_processing_max_allowed_gap_ratio_default = 0.5;
42     private static final int                 msa_processing_min_allowed_length_default    = 50;
43     private int                              _bootstrap_samples;
44     private PWD_DISTANCE_METHOD              _pwd_distance_method;
45     private long                             _random_number_generator_seed;
46     private boolean                          _perform_bootstrap_resampling;
47     private String                           _intermediate_files_base;
48     private String                           _msa_prg_parameters;
49     private boolean                          _execute_msa_processing;
50     private boolean                          _msa_processing_remove_all_gap_columns;
51     private double                           _msa_processing_max_allowed_gap_ratio;
52     private int                              _msa_processing_min_allowed_length;
53     private boolean                          _save_pwd_file;
54     private boolean                          _save_processed_msa;
55     private boolean                          _save_original_msa;
56     private File                             _pwd_outfile;
57     private File                             _processed_msa_outfile;
58     private File                             _original_msa_outfile;
59
60     public synchronized String getMsaPrgParameters() {
61         return _msa_prg_parameters;
62     }
63
64     public synchronized void setMsaPrgParameters( final String msa_prg_parameters ) {
65         _msa_prg_parameters = new String( msa_prg_parameters );
66     }
67
68     public synchronized String getIntermediateFilesBase() {
69         return _intermediate_files_base;
70     }
71
72     public synchronized String getMsaPrg() {
73         return "MAFFT";
74     }
75
76     public synchronized void setIntermediateFilesBase( final String intermediate_files_base ) {
77         _intermediate_files_base = new String( intermediate_files_base );
78     }
79
80     public PhylogeneticInferenceOptions() {
81         init();
82     }
83
84     // Deep copy.
85     public synchronized PhylogeneticInferenceOptions copy() {
86         final PhylogeneticInferenceOptions o = new PhylogeneticInferenceOptions();
87         o._bootstrap_samples = _bootstrap_samples;
88         o._pwd_distance_method = _pwd_distance_method;
89         o._random_number_generator_seed = _random_number_generator_seed;
90         o._perform_bootstrap_resampling = _perform_bootstrap_resampling;
91         o._intermediate_files_base = new String( _intermediate_files_base );
92         o._msa_prg_parameters = new String( _msa_prg_parameters );
93         o._msa_processing_max_allowed_gap_ratio = _msa_processing_max_allowed_gap_ratio;
94         o._msa_processing_min_allowed_length = _msa_processing_min_allowed_length;
95         o._execute_msa_processing = _execute_msa_processing;
96         o._msa_processing_remove_all_gap_columns = _msa_processing_remove_all_gap_columns;
97         o._save_pwd_file = _save_pwd_file;
98         o._save_processed_msa = _save_processed_msa;
99         o._save_original_msa = _save_original_msa;
100         if ( _pwd_outfile != null ) {
101             o._pwd_outfile = new File( _pwd_outfile.toString() );
102         }
103         if ( _processed_msa_outfile != null ) {
104             o._processed_msa_outfile = new File( _processed_msa_outfile.toString() );
105         }
106         if ( _original_msa_outfile != null ) {
107             o._original_msa_outfile = new File( _original_msa_outfile.toString() );
108         }
109         return o;
110     }
111
112     private synchronized void init() {
113         _bootstrap_samples = BOOTSTRAP_RESAMPLES_DEFAULT;
114         _pwd_distance_method = PWD_DISTANCE_METHOD_DEFAULT;
115         _random_number_generator_seed = RANDOM_NUMBER_SEED_DEFAULT;
116         _perform_bootstrap_resampling = PERFORM_BOOTSTRAP_RESAMPLING_DEFAULT;
117         _intermediate_files_base = "";
118         _msa_prg_parameters = Mafft.getDefaultParameters();
119         _msa_processing_max_allowed_gap_ratio = msa_processing_max_allowed_gap_ratio_default;
120         _msa_processing_min_allowed_length = msa_processing_min_allowed_length_default;
121         _execute_msa_processing = false;
122         _msa_processing_remove_all_gap_columns = false;
123         _save_pwd_file = false;
124         _save_processed_msa = false;
125         _save_original_msa = false;
126         _pwd_outfile = null;
127         _processed_msa_outfile = null;
128         _original_msa_outfile = null;
129     }
130
131     public synchronized void setBootstrapSamples( final int bootstrap_samples ) {
132         _bootstrap_samples = bootstrap_samples;
133     }
134
135     public synchronized int getBootstrapSamples() {
136         return _bootstrap_samples;
137     }
138
139     public synchronized void setPwdDistanceMethod( final PWD_DISTANCE_METHOD pwd_distance_method ) {
140         _pwd_distance_method = pwd_distance_method;
141     }
142
143     public synchronized PWD_DISTANCE_METHOD getPwdDistanceMethod() {
144         return _pwd_distance_method;
145     }
146
147     public synchronized void setRandomNumberGeneratorSeed( final long random_number_generator_seed ) {
148         _random_number_generator_seed = random_number_generator_seed;
149     }
150
151     public synchronized long getRandomNumberGeneratorSeed() {
152         return _random_number_generator_seed;
153     }
154
155     public synchronized void setPerformBootstrapResampling( final boolean perform_bootstrap_resampling ) {
156         _perform_bootstrap_resampling = perform_bootstrap_resampling;
157     }
158
159     public synchronized boolean isPerformBootstrapResampling() {
160         return _perform_bootstrap_resampling;
161     }
162
163     public static PhylogeneticInferenceOptions createInstance( final Configuration configuration ) {
164         final PhylogeneticInferenceOptions o = new PhylogeneticInferenceOptions();
165         if ( configuration.getDefaultBootstrapSamples() >= 0 ) {
166             o.setBootstrapSamples( configuration.getDefaultBootstrapSamples() );
167         }
168         return o;
169     }
170
171     public File getTempDir() {
172         //TODO
173         return new File( "/Users/zma/Desktop/tmp/" );
174     }
175
176     public void setMsaProcessingMaxAllowedGapRatio( final double msa_processing_max_allowed_gap_ratio ) {
177         _msa_processing_max_allowed_gap_ratio = msa_processing_max_allowed_gap_ratio;
178     }
179
180     public double getMsaProcessingMaxAllowedGapRatio() {
181         return _msa_processing_max_allowed_gap_ratio;
182     }
183
184     public void setMsaProcessingMinAllowedLength( final int msa_processing_min_allowed_length ) {
185         _msa_processing_min_allowed_length = msa_processing_min_allowed_length;
186     }
187
188     public int getMsaProcessingMinAllowedLength() {
189         return _msa_processing_min_allowed_length;
190     }
191
192     boolean isExecuteMsaProcessing() {
193         return _execute_msa_processing;
194     }
195
196     void setExecuteMsaProcessing( final boolean execute_msa_processing ) {
197         _execute_msa_processing = execute_msa_processing;
198     }
199
200     boolean isMsaProcessingRemoveAllGapColumns() {
201         return _msa_processing_remove_all_gap_columns;
202     }
203
204     void setMsaProcessingRemoveAllGapColumns( final boolean msa_processing_remove_all_gap_columns ) {
205         _msa_processing_remove_all_gap_columns = msa_processing_remove_all_gap_columns;
206     }
207
208     boolean isSavePwdFile() {
209         return _save_pwd_file;
210     }
211
212     void setSavePwdFile( final boolean save_pwd_file ) {
213         _save_pwd_file = save_pwd_file;
214     }
215
216     boolean isSaveProcessedMsa() {
217         return _save_processed_msa;
218     }
219
220     void setSaveProcessedMsa( final boolean save_processed_msa ) {
221         _save_processed_msa = save_processed_msa;
222     }
223
224     boolean isSaveOriginalMsa() {
225         return _save_original_msa;
226     }
227
228     void setSaveOriginalMsa( final boolean save_original_msa ) {
229         _save_original_msa = save_original_msa;
230     }
231
232     File getPwdOutfile() {
233         return _pwd_outfile;
234     }
235
236     void setPwdOutfile( final File pwd_outfile ) {
237         _pwd_outfile = pwd_outfile;
238     }
239
240     File getProcesseMsaOutfile() {
241         return _processed_msa_outfile;
242     }
243
244     void setProcesseMsaOutfile( final File processed_msa_outfile ) {
245         _processed_msa_outfile = processed_msa_outfile;
246     }
247
248     File getOriginalMsaOutfile() {
249         return _original_msa_outfile;
250     }
251
252     void setOriginalMsaOutfile( final File original_msa_outfile ) {
253         _original_msa_outfile = original_msa_outfile;
254     }
255 }