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 * Created on May 21, 2006
021 *
022 */
023package org.biojava.nbio.structure.align;
024
025import org.biojava.nbio.structure.StructureTools;
026
027/** A class that contains all the parameters of the structure alignment algorithm.
028 *
029 * @author Andreas Prlic
030 * @since 1.5
031 * @version %I% %G%
032 */
033public class StrucAligParameters {
034
035
036        int initialK;
037        String[] usedAtomNames = { StructureTools.CA_ATOM_NAME, } ;
038
039        // step 1
040
041        int seedFragmentLength; // seed fragment length
042        float seedRmsdCutoff;
043
044        int fragmentLength;
045        int diagonalDistance;
046        int diagonalDistance2; // set to < 1 if not used.
047        boolean reduceInitialFragments;
048
049        // step 2
050        float fragmentMiniDistance;
051        float fragCompat;   // fragment compatibility cutoff
052        int maxrefine;      // max number of JointFragments to be refined
053
054        boolean joinPlo; // joining according to BioPython variant
055        boolean joinFast; // apply a fast procedure for extending the alignments
056
057        // joininf of fragments - checks
058        boolean doAngleCheck  ;
059        boolean doDistanceCheck;
060        boolean doDensityCheck;
061        boolean doRMSCheck;
062        float densityCutoff;
063
064        int angleDiff;      // directional difference
065        double joinRMSCutoff; // rms cutoff to be applied during joining of fragments.
066
067        // step 4
068        float create_co; //  alignment generation cutoff
069        int maxIter; //  # max number of iterations in refinement
070        float gapOpen;// gap open penalty
071        float gapExtension; // gap extensionpenalty
072        int permutationSize; // minimal size for a permutated fragment ( -1 means no circular permutation search)
073        float evalCutoff; //  alignment evaluation cutoff
074
075        public StrucAligParameters() {
076                super();
077                setDefault();
078        }
079
080        public static StrucAligParameters getDefaultParameters(){
081                StrucAligParameters n = new StrucAligParameters();
082                return n;
083        }
084
085        private void setDefault() {
086                initialK = 6;
087
088                // step 1
089                seedFragmentLength      = 8;
090                seedRmsdCutoff          = 3.0f; // orig 2.0 - better?
091                fragmentLength          = 10;
092                diagonalDistance        = 3;
093                diagonalDistance2       = 9; // this helps a lot in 1buz vs 1aua
094                fragmentMiniDistance    = 3.5f; // orig 2
095                angleDiff               = 10;
096                fragCompat              = 6.0f; // orig 4.0
097                maxrefine               = 20; // orig 20
098
099                // step 2
100                reduceInitialFragments  =  true; // if this is disabled, you might want to also disable doRMSCheck for large structures...
101                joinRMSCutoff           = 5.0; // orig 4
102                joinPlo                 = false;
103                joinFast                = false;
104
105
106                // 3 joint fragments
107                doAngleCheck            = true;
108                doDistanceCheck         = true;
109                doRMSCheck              = true;
110
111                doDensityCheck          = false; // hm this one needs improvements before being used
112                densityCutoff           = 7.0f;
113
114                //  step 3
115                create_co           = 6.0f;
116                maxIter             = 4;  // number of times dynamic programming is run. set to zero for quick search (but imprecise)
117                gapOpen             = 20.0f;
118                gapExtension        = 0.0f;
119                permutationSize     = 20;
120                evalCutoff          = 6.0f;
121        }
122        @Override
123        public String toString() {
124                StringBuffer buf = new StringBuffer();
125                String t = " ";
126
127                Object[] params = new Object[]{new Integer(initialK) ,new Integer(seedFragmentLength),
128                                new Float(seedRmsdCutoff),
129                                new Integer(fragmentLength),
130                                new Integer(diagonalDistance), new Integer(diagonalDistance2), new Float(fragmentMiniDistance),
131                                new Integer(angleDiff),
132                                new Float(fragCompat), new Integer(maxrefine),
133                                new Boolean(reduceInitialFragments), new Double(joinRMSCutoff), new Boolean(joinPlo),
134                                new Boolean(doAngleCheck), new Boolean(doDistanceCheck), new Boolean(doRMSCheck),
135                                new Boolean(doDensityCheck), new Float(densityCutoff), new Float(create_co), new Integer(maxIter),
136                                new Float(gapOpen), new Float(gapExtension), new Integer(permutationSize), new Float(evalCutoff)};
137
138                for (int i=0 ; i< params.length ; i++){
139                        buf.append(params[i]);
140                        buf.append(t);
141                }
142
143
144                return buf.toString();
145
146        }
147
148        public static StrucAligParameters getDBSearchParameters(){
149                StrucAligParameters params = new StrucAligParameters();
150
151                params.setMaxIter(0); // not so nice alignments, but significant similarities should already be found,
152                // one could do a second interation later over the top ranking hits and make a nicer alignment.
153
154
155                return params;
156        }
157
158        public float getDensityCutoff() {
159                return densityCutoff;
160        }
161
162        public void setDensityCutoff(float densityCutoff) {
163                this.densityCutoff = densityCutoff;
164        }
165
166        public int getInitialK() {
167                return initialK;
168        }
169
170        public void setInitialK(int initialK) {
171                this.initialK = initialK;
172        }
173
174        public int getSeedFragmentLength() {
175                return seedFragmentLength;
176        }
177
178        public boolean isJoinFast(){
179           return joinFast;
180        }
181
182        public void setJoinFast(boolean fastJoin){
183           joinFast = fastJoin;
184        }
185
186        public boolean isJoinPlo() {
187                return joinPlo;
188        }
189
190        public void setJoinPlo(boolean joinPlo) {
191                this.joinPlo = joinPlo;
192        }
193
194        public void setSeedFragmentLength(int seedFragmentLength) {
195                this.seedFragmentLength = seedFragmentLength;
196        }
197
198
199
200        public float getSeedRmsdCutoff() {
201                return seedRmsdCutoff;
202        }
203
204
205
206        public void setSeedRmsdCutoff(float seedRmsdCutoff) {
207                this.seedRmsdCutoff = seedRmsdCutoff;
208        }
209
210
211
212        public boolean isDoAngleCheck() {
213                return doAngleCheck;
214        }
215
216        public void setDoAngleCheck(boolean doAngleCheck) {
217                this.doAngleCheck = doAngleCheck;
218        }
219
220        public boolean isDoDensityCheck() {
221                return doDensityCheck;
222        }
223
224        public void setDoDensityCheck(boolean doDensityCheck) {
225                this.doDensityCheck = doDensityCheck;
226        }
227
228        public boolean isDoDistanceCheck() {
229                return doDistanceCheck;
230        }
231
232        public void setDoDistanceCheck(boolean doDistanceCheck) {
233                this.doDistanceCheck = doDistanceCheck;
234        }
235
236        public boolean isDoRMSCheck() {
237                return doRMSCheck;
238        }
239
240        public void setDoRMSCheck(boolean doRMSCheck) {
241                this.doRMSCheck = doRMSCheck;
242        }
243
244        public double getJoinRMSCutoff() {
245                return joinRMSCutoff;
246        }
247
248
249
250        public void setJoinRMSCutoff(double joinRMSCutoff) {
251                this.joinRMSCutoff = joinRMSCutoff;
252        }
253
254
255
256        public float getEvalCutoff() {
257                return evalCutoff;
258        }
259
260        public void setEvalCutoff(float evalCutoff) {
261                this.evalCutoff = evalCutoff;
262        }
263
264
265
266
267        public int getPermutationSize() {
268                return permutationSize;
269        }
270
271        public void setPermutationSize(int permutationSize) {
272                this.permutationSize = permutationSize;
273        }
274
275        public float getGapExtension() {
276                return gapExtension;
277        }
278
279        public void setGapExtension(float gapExtension) {
280                this.gapExtension = gapExtension;
281        }
282
283        public float getGapOpen() {
284                return gapOpen;
285        }
286
287        public void setGapOpen(float gapOpen) {
288                this.gapOpen = gapOpen;
289        }
290
291        public int getMaxIter() {
292                return maxIter;
293        }
294
295        public void setMaxIter(int maxIter) {
296                this.maxIter = maxIter;
297        }
298
299        public float getCreate_co() {
300                return create_co;
301        }
302
303        public void setCreate_co(float create_co) {
304                this.create_co = create_co;
305        }
306
307        /** if this is set to false, the time spent to joint the initial fragments (step 2)
308         * is increased. - particular for large structures this increases calc. time a lot.
309         * advantage: more combinations of fragments are used.
310         *
311         * @return a flag if the inital fragments should be reduced
312         */
313        public boolean reduceInitialFragments() {
314                return reduceInitialFragments;
315        }
316
317        public void setReduceInitialFragments(boolean reduceInitialFragments) {
318                this.reduceInitialFragments = reduceInitialFragments;
319        }
320
321        public int getAngleDiff() {
322                return angleDiff;
323        }
324
325        public void setAngleDiff(int angleDiff) {
326                this.angleDiff = angleDiff;
327        }
328
329        public float getFragCompat() {
330                return fragCompat;
331        }
332
333        public void setFragCompat(float fragCompat) {
334                this.fragCompat = fragCompat;
335        }
336
337        public int getMaxrefine() {
338                return maxrefine;
339        }
340
341        public void setMaxrefine(int maxrefine) {
342                this.maxrefine = maxrefine;
343        }
344
345        public String[] getUsedAtomNames() {
346                return usedAtomNames;
347        }
348
349        public void setUsedAtomNames(String[] usedAtomNames) {
350                this.usedAtomNames = usedAtomNames;
351        }
352
353        public int getFragmentLength() {
354                return fragmentLength;
355        }
356
357        public void setFragmentLength(int fragmentLength) {
358                this.fragmentLength = fragmentLength;
359        }
360
361        public int getDiagonalDistance() {
362                return diagonalDistance;
363        }
364
365        public void setDiagonalDistance(int diagonalDistance) {
366                this.diagonalDistance = diagonalDistance;
367        }
368
369
370
371        public int getDiagonalDistance2() {
372                return diagonalDistance2;
373        }
374
375        public void setDiagonalDistance2(int diagonalDistance2) {
376                this.diagonalDistance2 = diagonalDistance2;
377        }
378
379        public float getFragmentMiniDistance() {
380                return fragmentMiniDistance;
381        }
382
383        public void setFragmentMiniDistance(float fragmentMiniDistance) {
384                this.fragmentMiniDistance = fragmentMiniDistance;
385        }
386
387
388
389
390}