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 Nov 2, 2009
021 * Author: Andreas Prlic
022 *
023 */
024
025package org.biojava.nbio.structure.align.fatcat;
026
027
028import org.biojava.nbio.structure.align.StructureAlignment;
029import org.biojava.nbio.structure.align.ce.AbstractUserArgumentProcessor;
030import org.biojava.nbio.structure.align.ce.StartupParameters;
031import org.biojava.nbio.structure.align.fatcat.calc.FatCatParameters;
032import org.slf4j.Logger;
033import org.slf4j.LoggerFactory;
034
035
036public class FatCatUserArgumentProcessor extends AbstractUserArgumentProcessor {
037        Logger logger = LoggerFactory.getLogger(FatCatUserArgumentProcessor.class);
038
039        protected class FatCatStartupParams extends StartupParameters {
040                int fragLen;
041                Double rmsdCut;
042                double disCut;
043                int maxTra;
044                boolean flexible;
045
046                public FatCatStartupParams() {
047                        // Defaults should match those in FatCatParameters.reset()
048                        fragLen = FatCatParameters.DEFAULT_FRAGLEN;
049                        rmsdCut = 3.0;
050                        disCut = 5.0;
051                        maxTra = 5;
052                        flexible = false;
053                }
054
055                public int getFragLen() {
056                        return fragLen;
057                }
058                public void setFragLen(int fragLen) {
059                        this.fragLen = fragLen;
060                }
061                public Double getRmsdCut() {
062                        return rmsdCut;
063                }
064                public void setRmsdCut(Double rmsdCut) {
065                        this.rmsdCut = rmsdCut;
066                }
067                public double getDisCut() {
068                        return disCut;
069                }
070                public void setDisCut(double disCut) {
071                        this.disCut = disCut;
072                }
073                public int getMaxTra() {
074                        return maxTra;
075                }
076                public void setMaxTra(int maxTra) {
077                        this.maxTra = maxTra;
078                }
079                public boolean isFlexible() {
080                        return flexible;
081                }
082                public void setFlexible(boolean flexible) {
083                        this.flexible = flexible;
084                }
085        }
086
087        @Override
088        protected StartupParameters getStartupParametersInstance() {
089                return new FatCatStartupParams();
090        }
091
092        @Override
093        public StructureAlignment getAlgorithm() {
094                StructureAlignment algorithm = null;
095                if ( params != null && ((FatCatStartupParams)params).isFlexible()) {
096                        logger.info("running flexible alignment");
097                        algorithm = new FatCatFlexible();
098                }
099                else {
100                        logger.info("running rigid alignment");
101                        algorithm = new FatCatRigid();
102                }
103                return algorithm;
104
105        }
106
107        @Override
108        public Object getParameters() {
109                StructureAlignment alignment = getAlgorithm();
110
111                FatCatParameters aligParams = (FatCatParameters) alignment.getParameters();
112                FatCatStartupParams startParams = (FatCatStartupParams) params;
113
114                if ( aligParams == null)
115                        aligParams = new FatCatParameters();
116
117                aligParams.setFragLen(startParams.getFragLen());
118                aligParams.setRmsdCut(startParams.getRmsdCut());
119                aligParams.setDisCut(startParams.getDisCut());
120                aligParams.setMaxTra(startParams.getMaxTra());
121
122                return aligParams;
123        }
124
125        @Override
126        public String getDbSearchLegend(){
127
128                return "# name1\tname2\tscore\tprobability\trmsd\tlen1\tlen2\tcov1\tcov2\t%ID\tDescription\t " ;
129
130        }
131
132}