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.ce;
026
027
028import org.biojava.nbio.structure.align.StructureAlignment;
029import org.biojava.nbio.structure.align.ce.CeParameters.ScoringStrategy;
030
031/** process the arguments from command line
032 *
033 * @author Andreas Prlic
034 *
035 */
036public class CeUserArgumentProcessor extends AbstractUserArgumentProcessor {
037
038        protected static class CeStartupParams extends StartupParameters {
039                protected int maxGapSize;
040                protected int winSize;
041                protected ScoringStrategy scoringStrategy;
042                protected double maxOptRMSD;
043                protected double gapOpen;
044                protected double gapExtension;
045                protected boolean showAFPRanges;
046
047                public CeStartupParams() {
048                        super();
049                        maxGapSize = 30;
050                        winSize = 8;
051                        scoringStrategy = CeParameters.ScoringStrategy.DEFAULT_SCORING_STRATEGY;
052                        showAFPRanges = false;
053                        maxOptRMSD = 99d;
054                        gapOpen = CeParameters.DEFAULT_GAP_OPEN;
055                        gapExtension = CeParameters.DEFAULT_GAP_EXTENSION;
056                }
057
058                public int getWinSize() {
059                        return winSize;
060                }
061
062                public void setWinSize(int winSize) {
063                        this.winSize = winSize;
064                }
065
066                public ScoringStrategy getScoringStrategy() {
067                        return scoringStrategy;
068                }
069
070                public void setScoringStrategy(ScoringStrategy scoringStrategy) {
071                        this.scoringStrategy = scoringStrategy;
072                }
073
074                public double getGapOpen() {
075                        return gapOpen;
076                }
077
078                public void setGapOpen(double gapOpen) {
079                        this.gapOpen = gapOpen;
080                }
081
082                public double getGapExtension() {
083                        return gapExtension;
084                }
085
086                public void setGapExtension(double gapExtension) {
087                        this.gapExtension = gapExtension;
088                }
089
090                /** CE specific parameter: set the Max gap size parameter G (during AFP extension). Default: 30
091                 *
092                 * @return the maximum gap size G parameter.
093                 */
094                public int getMaxGapSize() {
095                        return maxGapSize;
096                }
097
098                /** CE specific parameter: set the Max gap size parameter G (during AFP extension). Default: 30
099                 *
100                 * @param maxGapSize
101                 */
102                public void setMaxGapSize(int maxGapSize) {
103                        this.maxGapSize = maxGapSize;
104                }
105
106                public boolean isShowAFPRanges()
107                {
108                        return showAFPRanges;
109                }
110
111                public void setShowAFPRanges(boolean showAFP)
112                {
113                        this.showAFPRanges = showAFP;
114                }
115
116
117                /**(jCE specific): maximum RMSD that shall be calculated for the alignment.
118                 *
119                 * @return maxOptRMSD parameter
120                 */
121                public Double getMaxOptRMSD() {
122                        return maxOptRMSD;
123                }
124
125                /** (jCE specific): maximum RMSD that shall be calculated for the alignment.
126                 *
127                 * @param maxOptRMSD max RMSD to calculate
128                 */
129                public void setMaxOptRMSD(Double maxOptRMSD) {
130                        this.maxOptRMSD = maxOptRMSD;
131                }
132
133                @Override
134                public String toString() {
135                        StringBuilder builder = new StringBuilder();
136                        builder.append("CeStartupParams [maxGapSize=").append(maxGapSize)
137                                        .append(", winSize=").append(winSize)
138                                        .append(", scoringStrategy=").append(scoringStrategy)
139                                        .append(", maxOptRMSD=").append(maxOptRMSD)
140                                        .append(", gapOpen=").append(gapOpen)
141                                        .append(", gapExtension=").append(gapExtension)
142                                        .append(", showAFPRanges=").append(showAFPRanges)
143                                        .append(", pdbFilePath=").append(pdbFilePath)
144                                        .append(", cacheFilePath=").append(cacheFilePath)
145                                        .append(", outFile=").append(outFile).append(", pdb1=")
146                                        .append(pdb1).append(", pdb2=").append(pdb2)
147                                        .append(", file1=").append(file1).append(", file2=")
148                                        .append(file2).append(", showDBresult=")
149                                        .append(showDBresult).append(", printXML=")
150                                        .append(printXML).append(", printFatCat=")
151                                        .append(printFatCat).append(", show3d=").append(show3d)
152                                        .append(", autoFetch=").append(autoFetch)
153                                        .append(", printCE=").append(printCE).append(", showMenu=")
154                                        .append(showMenu).append(", printPDB=").append(printPDB)
155                                        .append(", isDomainSplit=").append(isDomainSplit)
156                                        .append(", alignPairs=").append(alignPairs)
157                                        .append(", searchFile=").append(searchFile)
158                                        .append(", saveOutputDir=").append(saveOutputDir)
159                                        .append(", nrCPU=").append(nrCPU).append("]");
160                        return builder.toString();
161                }
162
163        }
164
165        @Override
166        protected StartupParameters getStartupParametersInstance() {
167                return new CeStartupParams();
168        }
169
170        @Override
171        public StructureAlignment getAlgorithm() {
172                return new CeMain();
173        }
174
175
176        @Override
177        public Object getParameters() {
178
179                StructureAlignment alignment = getAlgorithm();
180
181                CeParameters aligParams = (CeParameters) alignment.getParameters();
182                CeStartupParams startParams = (CeStartupParams) params;
183
184                if ( aligParams == null)
185                        aligParams = new CECPParameters();
186
187                // Copy relevant parameters from the startup parameters
188                aligParams.setMaxGapSize(startParams.getMaxGapSize());
189                aligParams.setWinSize(startParams.getWinSize());
190                aligParams.setScoringStrategy(startParams.getScoringStrategy());
191                aligParams.setMaxOptRMSD(startParams.getMaxOptRMSD());
192                aligParams.setGapOpen(startParams.getGapOpen());
193                aligParams.setGapExtension(startParams.getGapExtension());
194                aligParams.setShowAFPRanges(startParams.isShowAFPRanges());
195                return aligParams;
196        }
197
198
199        @Override
200        public String getDbSearchLegend(){
201                //String legend = "# name1\tname2\tscore\tz-score\trmsd\tlen1\tlen2\tsim1\tsim2\t " ;
202                //return legend;
203
204                return "# name1\tname2\tscore\tz-score\trmsd\tlen1\tlen2\tcov1\tcov2\t%ID\tDescription\t " ;
205
206        }
207
208
209}