001/* This class is based on the original FATCAT implementation by
002 * <pre>
003 * Yuzhen Ye & Adam Godzik (2003)
004 * Flexible structure alignment by chaining aligned fragment pairs allowing twists.
005 * Bioinformatics vol.19 suppl. 2. ii246-ii255.
006 * https://www.ncbi.nlm.nih.gov/pubmed/14534198
007 * </pre>
008 *
009 * Thanks to Yuzhen Ye and A. Godzik for granting permission to freely use and redistribute this code.
010 *
011 * This code may be freely distributed and modified under the
012 * terms of the GNU Lesser General Public Licence.  This should
013 * be distributed with the code.  If you do not have a copy,
014 * see:
015 *
016 *      http://www.gnu.org/copyleft/lesser.html
017 *
018 * Copyright for this code is held jointly by the individual
019 * authors.  These should be listed in @author doc comments.
020 *
021 *
022 * Created on Jun 17, 2009
023 * Created by Andreas Prlic - RCSB PDB
024 *
025 */
026
027package org.biojava.nbio.structure.align.fatcat.calc;
028
029import org.biojava.nbio.structure.align.ce.ConfigStrucAligParams;
030
031import java.io.StringWriter;
032import java.lang.reflect.Method;
033import java.util.ArrayList;
034import java.util.List;
035
036
037public class FatCatParameters implements ConfigStrucAligParams
038{
039
040        public static final int DEFAULT_FRAGLEN = 8;
041
042        int fragLen  ; // the length of the fragments to consider...
043        int fragLenSq ;
044        Double rmsdCut; // cutoff for AFP detection.
045        double disCut; // for AFPs connection, to be tuned, 4.0
046        double afpDisCut;
047        double afpDisCut0;
048        double disSmooth; // for smooth calculation of twist penalty calculation
049        int misCut;
050        int maxGap;
051        int maxGapFrag;
052        double disFilter;
053        double badRmsd;
054        int maxTra; // the maximum number of Twists that are allowed...
055        double gapCreate;
056        double gapExtend;
057        double misScore;
058        double torsionPenalty;
059        double maxPenalty;
060        double resScore;
061        double fragScore;
062        int sparse;
063
064        public FatCatParameters(){
065                reset();
066        }
067
068
069        @Override
070        public void reset(){
071                // Note: Update FatCatUserArgumentProcessor.FatCatStartupParams after
072                // modifying user-exposed values
073                fragLen = DEFAULT_FRAGLEN;
074                fragLenSq = fragLen * fragLen;
075                rmsdCut = 3.0; //cutoff for AFP detection
076                disCut = 5.0; //for AFPs connection, to be tuned, 4.0
077                afpDisCut = fragLenSq * disCut * disCut;
078                afpDisCut0 = fragLenSq * disCut;
079                disSmooth = 4.0; //for smoothly calculation of twist penalty calculation
080                misCut = 2 * fragLen; //structural-dismilar ranges allowed between AFPs
081                maxGap = 40; //try-1 30
082                maxGapFrag = fragLen + maxGap;
083                disFilter = 2.0 * rmsdCut; //for single AFP denifition to be tuned! //two CA-dis is 3.6
084                badRmsd = 4.0; //very important paramerter for twists detection
085                maxTra = 5;
086                gapCreate = -5.0;
087                gapExtend = -0.5;
088                misScore = gapExtend; //comparable to gapExtend
089                torsionPenalty = 5 * gapCreate; //to be tuned
090                maxPenalty = 1 * gapCreate; //to be tuned
091                resScore = 3.0; //on average, the score for each well-matched residue pair
092                fragScore = resScore * fragLen; //the score for each well-matched fragment
093                sparse = 0;
094        }
095
096
097        public Integer getFragLen()
098        {
099                return fragLen;
100        }
101
102
103        public void setFragLen(Integer fragLen)
104        {
105                this.fragLen = fragLen;
106        }
107
108
109        public int getFragLenSq()
110        {
111                return fragLenSq;
112        }
113
114
115        public void setFragLenSq(int fragLenSq)
116        {
117                this.fragLenSq = fragLenSq;
118        }
119
120
121        /** The cutoff to be used during AFP detection
122         *
123         * @return rmsdCut parameter
124         */
125        public Double getRmsdCut()
126        {
127                return rmsdCut;
128        }
129
130        /** The cutoff to be used during AFP detection
131         *
132         * @param rmsdCut
133         */
134        public void setRmsdCut(Double rmsdCut)
135        {
136                this.rmsdCut = rmsdCut;
137        }
138
139        /** Get the distance cutoff used during AFP chain connectivity checks
140         *
141         * @return distance Cutoff
142         */
143        public Double getDisCut()
144        {
145                return disCut;
146        }
147
148
149        public void setDisCut(Double disCut)
150        {
151                this.disCut = disCut;
152        }
153
154
155        public double getAfpDisCut()
156        {
157                return afpDisCut;
158        }
159
160
161        public void setAfpDisCut(double afpDisCut)
162        {
163                this.afpDisCut = afpDisCut;
164        }
165
166
167        public double getAfpDisCut0()
168        {
169                return afpDisCut0;
170        }
171
172
173        public void setAfpDisCut0(double afpDisCut0)
174        {
175                this.afpDisCut0 = afpDisCut0;
176        }
177
178
179        public double getDisSmooth()
180        {
181                return disSmooth;
182        }
183
184
185        public void setDisSmooth(double disSmooth)
186        {
187                this.disSmooth = disSmooth;
188        }
189
190
191        public int getMisCut()
192        {
193                return misCut;
194        }
195
196
197        public void setMisCut(int misCut)
198        {
199                this.misCut = misCut;
200        }
201
202
203        public int getMaxGap()
204        {
205                return maxGap;
206        }
207
208
209        public void setMaxGap(int maxGap)
210        {
211                this.maxGap = maxGap;
212        }
213
214
215        public int getMaxGapFrag()
216        {
217                return maxGapFrag;
218        }
219
220
221        public void setMaxGapFrag(int maxGapFrag)
222        {
223                this.maxGapFrag = maxGapFrag;
224        }
225
226
227        public double getDisFilter()
228        {
229                return disFilter;
230        }
231
232
233        public void setDisFilter(double disFilter)
234        {
235                this.disFilter = disFilter;
236        }
237
238
239        public double getBadRmsd()
240        {
241                return badRmsd;
242        }
243
244
245        public void setBadRmsd(double badRmsd)
246        {
247                this.badRmsd = badRmsd;
248        }
249
250
251        /** get the maximum number of Twists that are allowed...
252         *
253         * @return max nr of allowed twists
254         */
255        public Integer getMaxTra()
256        {
257                return maxTra;
258        }
259
260        /** set the maximum number of Twists that are allowed...
261         *
262         * @param maxTra
263         */
264        public void setMaxTra(Integer maxTra)
265        {
266                this.maxTra = maxTra;
267        }
268
269
270        public double getGapCreate()
271        {
272                return gapCreate;
273        }
274
275
276        public void setGapCreate(double gapCreate)
277        {
278                this.gapCreate = gapCreate;
279        }
280
281
282        public double getGapExtend()
283        {
284                return gapExtend;
285        }
286
287
288        public void setGapExtend(double gapExtend)
289        {
290                this.gapExtend = gapExtend;
291        }
292
293
294        public double getMisScore()
295        {
296                return misScore;
297        }
298
299
300        public void setMisScore(double misScore)
301        {
302                this.misScore = misScore;
303        }
304
305
306        public double getTorsionPenalty()
307        {
308                return torsionPenalty;
309        }
310
311
312        public void setTorsionPenalty(double torsionPenalty)
313        {
314                this.torsionPenalty = torsionPenalty;
315        }
316
317
318        public double getMaxPenalty()
319        {
320                return maxPenalty;
321        }
322
323
324        public void setMaxPenalty(double maxPenalty)
325        {
326                this.maxPenalty = maxPenalty;
327        }
328
329
330        public double getResScore()
331        {
332                return resScore;
333        }
334
335
336        public void setResScore(double resScore)
337        {
338                this.resScore = resScore;
339        }
340
341
342        public double getFragScore()
343        {
344                return fragScore;
345        }
346
347
348        public void setFragScore(double fragScore)
349        {
350                this.fragScore = fragScore;
351        }
352
353
354        public int getSparse()
355        {
356                return sparse;
357        }
358
359
360        public void setSparse(int sparse)
361        {
362                this.sparse = sparse;
363        }
364
365
366        @Override
367        public List<String> getUserConfigHelp() {
368                List<String> params = new ArrayList<String>();
369                String fragLen = "The length of the fragments.";
370                String rmsdCutHelp = "The RMSD cutoff to be used during AFP detection.";
371                String disCutHelp = "The distance cutoff used when calculate the connectivity of AFP pairs";
372                String twistHelp ="The number of twists that are allowed to be introduced. If set to 0 alignments are run in RIGID mode.";
373                params.add(fragLen);
374                params.add(rmsdCutHelp);
375                params.add(disCutHelp);
376                params.add(twistHelp);
377                return params;
378
379        }
380
381
382        @Override
383        public List<String> getUserConfigParameterNames() {
384                List<String> params = new ArrayList<String>();
385                params.add("Fragment Length");
386                params.add("RMSD Cutoff");
387                params.add("AFP Distance Cutoff");
388                params.add("Maximum Nr. of twists");
389                return params;
390        }
391
392
393        @Override
394        public List<String> getUserConfigParameters() {
395                List<String> params = new ArrayList<String>();
396                params.add("FragLen");
397                params.add("RmsdCut");
398                params.add("DisCut");
399                params.add("MaxTra");
400                return params;
401        }
402
403
404        @Override
405        @SuppressWarnings({  "rawtypes" })
406        public List<Class> getUserConfigTypes() {
407
408                List<Class> params = new ArrayList<Class>();
409                params.add(Integer.class);
410                params.add(Double.class);
411                params.add(Double.class);
412                params.add(Integer.class);
413                return params;
414        }
415
416
417        @Override
418        public String toString(){
419                StringWriter writer = new StringWriter();
420                writer.append("[");
421                if ( maxTra == 0)
422                        writer.append("Mode: rigid, ");
423                else
424                        writer.append("Mode: flexible, ");
425                List<String> params = getUserConfigParameters();
426
427                for ( String s : params){
428                        writer.append(s);
429                        writer.append(": ");
430                        Object val = getValue(s);
431                        writer.append(val.toString());
432                        writer.append(", ");
433                }
434                writer.append("]");
435                return writer.toString();
436        }
437
438        private Object  getValue(String name){
439
440                try {
441                        String methodName = "get" + name;
442
443                        Class<?> paramC = this.getClass();
444
445                        Method m =paramC.getMethod(methodName,(Class[])null);
446
447                        Object value = m.invoke(this);
448
449                        return value;
450                } catch (Exception e){
451                        e.printStackTrace();
452                        return null;
453                }
454
455
456        }
457
458}