001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021package org.biojava.nbio.structure.align.multiple.mc;
022
023import java.util.ArrayList;
024import java.util.List;
025import java.util.Random;
026
027import org.biojava.nbio.structure.align.ce.ConfigStrucAligParams;
028
029/**
030 * Contains the parameters to be sent to the MC optimization.
031 *
032 * @author Aleix Lafita
033 * @since 4.1.0
034 *
035 */
036public class MultipleMcParameters implements ConfigStrucAligParams {
037
038        private int randomSeed;
039        private int minBlockLen;
040        private int minAlignedStructures;
041        private double gapOpen;
042        private double gapExtension;
043        private double distanceCutoff;
044        private int convergenceSteps;
045        private int nrThreads;
046
047        /**
048         * Constructor with DEFAULT values of the parameters.
049         */
050        public MultipleMcParameters(){
051                reset();
052        }
053
054        @Override
055        public List<String> getUserConfigParameters() {
056
057                List<String> params = new ArrayList<String>();
058                params.add("RandomSeed");
059                params.add("MinBlockLen");
060                params.add("MinAlignedStructures");
061                params.add("GapOpen");
062                params.add("GapExtension");
063                params.add("DistanceCutoff");
064                params.add("ConvergenceSteps");
065                params.add("NrThreads");
066                return params;
067        }
068
069        @Override
070        public List<String> getUserConfigParameterNames() {
071
072                List<String> params = new ArrayList<String>();
073                params.add("Random Seed");
074                params.add("Minimum Block Length");
075                params.add("Minimum Structures per Column");
076                params.add("Gap Opening Penalty");
077                params.add("Gap Extension Penalty");
078                params.add("Distance Cutoff");
079                params.add("Steps to Convergence");
080                params.add("Number of Threads");
081                return params;
082        }
083
084        @Override
085        @SuppressWarnings("rawtypes")
086        public List<Class> getUserConfigTypes() {
087
088                List<Class> params = new ArrayList<Class>();
089                params.add(Integer.class);
090                params.add(Integer.class);
091                params.add(Integer.class);
092                params.add(Double.class);
093                params.add(Double.class);
094                params.add(Double.class);
095                params.add(Integer.class);
096                params.add(Integer.class);
097                return params;
098        }
099
100        @Override
101        public List<String> getUserConfigHelp() {
102
103                List<String> params =new ArrayList<String>();
104                String randomSeed =
105                                "Random seed for the optimizer random number generator.";
106                String minBlockLen =
107                                "Minimum number of aligned positions in a Block of the "
108                                + "Multiple Alignment.";
109                String minAlignedStructures =
110                                "Minimum number of structures aligned in a column (without "
111                                + "gaps). If it is 0 the minimum is calculated as a third of "
112                                + "the total number of structures.";
113                String gapOpen = "Penalty for opening a gap in any of the structures.";
114                String gapExtension = "Penalty for extending a gapped region in any of"
115                                + " the structures.";
116                String dCutoff = "Distance Cutoff: the maximum allowed distance (in A) "
117                                + "between two aligned residues.";
118                String convergenceSteps =
119                                "Number of steps without a change in the alignment before "
120                                + "stopping. Proportional to the calculation time. "
121                                +"If it is 0 the convergence steps are calculated proportional"
122                                + " to the number of structures and their length.";
123                String nrThreads =
124                                "Number of threads to be used for the seed calculation (all-"
125                                + "to-all pairwise alignments) and the MC optimization.";
126
127                params.add(randomSeed);
128                params.add(minBlockLen);
129                params.add(minAlignedStructures);
130                params.add(gapOpen);
131                params.add(gapExtension);
132                params.add(dCutoff);
133                params.add(convergenceSteps);
134                params.add(nrThreads);
135                return params;
136        }
137
138        @Override
139        public String toString() {
140                return "MultipleMcParameters [randomSeed=" + randomSeed
141                                + ", minBlockLen=" + minBlockLen + ", minAlignedStructures="
142                                + minAlignedStructures + ", gapOpen=" + gapOpen
143                                + ", gapExtension=" + gapExtension + ", distanceCutoff="
144                                + distanceCutoff + ", convergenceSteps=" + convergenceSteps
145                                + ", nrThreads=" + nrThreads + "]";
146        }
147
148        @Override
149        public void reset() {
150
151                randomSeed = new Random().nextInt(10000);
152                minBlockLen = 10;
153                minAlignedStructures = 0;
154                gapOpen = 20.0;
155                gapExtension = 15.0;
156                distanceCutoff = 7.0;
157                convergenceSteps = 0;
158                nrThreads = Runtime.getRuntime().availableProcessors();
159        }
160
161        public int getRandomSeed() {
162                return randomSeed;
163        }
164
165        public void setRandomSeed(Integer randomSeed) {
166                this.randomSeed = randomSeed;
167        }
168
169        public int getMinBlockLen() {
170                return minBlockLen;
171        }
172
173        public void setMinBlockLen(Integer minBlockLen) {
174                this.minBlockLen = minBlockLen;
175        }
176
177        public int getMinAlignedStructures() {
178                return minAlignedStructures;
179        }
180
181        public void setMinAlignedStructures(Integer minAlignedStructures) {
182                this.minAlignedStructures = minAlignedStructures;
183        }
184
185        public double getGapOpen() {
186                return gapOpen;
187        }
188
189        public void setGapOpen(Double gapOpen) {
190                this.gapOpen = gapOpen;
191        }
192
193        public double getGapExtension() {
194                return gapExtension;
195        }
196
197        public void setGapExtension(Double gapExtension) {
198                this.gapExtension = gapExtension;
199        }
200
201        public int getConvergenceSteps() {
202                return convergenceSteps;
203        }
204
205        public void setConvergenceSteps(Integer convergenceSteps) {
206                this.convergenceSteps = convergenceSteps;
207        }
208
209        public int getNrThreads() {
210                return nrThreads;
211        }
212
213        public void setNrThreads(Integer nrThreads) {
214                this.nrThreads = nrThreads;
215        }
216
217        public double getDistanceCutoff() {
218                return distanceCutoff;
219        }
220
221        public void setDistanceCutoff(Double distanceCutoff) {
222                this.distanceCutoff = distanceCutoff;
223        }
224}