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