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 Sep 15, 2009 021 * Author: Andreas Prlic 022 * 023 */ 024 025package org.biojava.nbio.structure.align.ce; 026 027import org.biojava.nbio.core.alignment.matrices.SubstitutionMatrixHelper; 028import org.biojava.nbio.core.alignment.template.SubstitutionMatrix; 029import org.biojava.nbio.structure.align.util.CliTools; 030import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; 031 032import java.util.ArrayList; 033import java.util.List; 034 035 036/** 037 * Contains the parameters that can be sent to CE 038 * 039 * @author Andreas Prlic 040 * 041 */ 042public class CeParameters implements ConfigStrucAligParams { 043 044 protected int winSize; 045 protected double rmsdThr; 046 protected double rmsdThrJoin; 047 protected double maxOptRMSD; 048 049 public static enum ScoringStrategy { 050 CA_SCORING("CA only"), 051 SIDE_CHAIN_SCORING("Sidechain orientation"), 052 SIDE_CHAIN_ANGLE_SCORING("Angle between sidechains"), 053 CA_AND_SIDE_CHAIN_ANGLE_SCORING("CA distance+Angle between sidechains"), 054 SEQUENCE_CONSERVATION("Sequence Conservation"); 055 public static ScoringStrategy DEFAULT_SCORING_STRATEGY = CA_SCORING; 056 057 private String name; 058 private ScoringStrategy(String name) { 059 this.name = name; 060 } 061 @Override 062 public String toString() { 063 return name; 064 } 065 } 066 067 protected ScoringStrategy scoringStrategy; 068 //String[] alignmentAtoms; 069 protected int maxGapSize; 070 071 protected boolean showAFPRanges; 072 protected int sideChainScoringType; 073 074 protected static final double DEFAULT_GAP_OPEN = 5.0; 075 protected static final double DEFAULT_GAP_EXTENSION = 0.5; 076 protected static final double DISTANCE_INCREMENT = 0.5; 077 protected static final double DEFAULT_oRmsdThr = 2.0; 078 protected static final String DEFAULT_SUBSTITUTION_MATRIX = "PRLA000101"; 079 080 protected double gapOpen; 081 protected double gapExtension; 082 protected double distanceIncrement; 083 protected double oRmsdThr; 084 085 protected int maxNrIterationsForOptimization; 086 087 protected SubstitutionMatrix<AminoAcidCompound> substitutionMatrix; 088 protected double seqWeight; 089 090 public CeParameters(){ 091 reset(); 092 } 093 094 @Override 095 public String toString() { 096 return "CeParameters [scoringStrategy=" + scoringStrategy 097 + ", maxGapSize=" + maxGapSize 098 + ", rmsdThr=" + rmsdThr 099 + ", rmsdThrJoin="+ rmsdThrJoin 100 + ", winSize=" + winSize 101 + ", showAFPRanges=" + showAFPRanges 102 + ", maxOptRMSD=" + maxOptRMSD 103 + ", seqWeight=" + seqWeight 104 + "]"; 105 } 106 107 108 109 @Override 110 public void reset(){ 111 winSize = 8; 112 rmsdThr = 3.0; 113 rmsdThrJoin = 4.0; 114 scoringStrategy = ScoringStrategy.DEFAULT_SCORING_STRATEGY; 115 maxGapSize = 30; 116 showAFPRanges = false; 117 maxOptRMSD = 99; 118 119 gapOpen = DEFAULT_GAP_OPEN; 120 gapExtension = DEFAULT_GAP_EXTENSION; 121 distanceIncrement = DISTANCE_INCREMENT; 122 oRmsdThr = DEFAULT_oRmsdThr; 123 124 maxNrIterationsForOptimization = Integer.MAX_VALUE; 125 seqWeight = 0; 126 } 127 128 /** The window size to look at 129 * 130 * @return window size 131 */ 132 public Integer getWinSize() { 133 return winSize; 134 } 135 public void setWinSize(Integer winSize) { 136 this.winSize = winSize; 137 } 138 139 /** RMSD Threshold 140 * 141 * @return RMSD threshold 142 */ 143 public Double getRmsdThr() { 144 return rmsdThr; 145 } 146 public void setRmsdThr(Double rmsdThr) { 147 this.rmsdThr = rmsdThr; 148 } 149 150 /** RMSD threshold for joining of AFPs 151 * 152 * @return rmsd threshold 153 */ 154 public Double getRmsdThrJoin() { 155 return rmsdThrJoin; 156 } 157 public void setRmsdThrJoin(Double rmsdThrJoin) { 158 this.rmsdThrJoin = rmsdThrJoin; 159 } 160 161 public ScoringStrategy getScoringStrategy() 162 { 163 return scoringStrategy; 164 } 165 166 167 /** Set the scoring strategy to use. 0 is default CE scoring scheme. 1 uses 168 * Side chain orientation. 169 * 170 * @param scoringStrategy 171 */ 172 public void setScoringStrategy(ScoringStrategy scoringStrategy) 173 { 174 this.scoringStrategy = scoringStrategy; 175 } 176 177 178 179 /** Set the Max gap size parameter. Default 30. For unlimited gaps set to -1 180 * 181 * @param maxGapSize 182 */ 183 public void setMaxGapSize(Integer maxGapSize){ 184 this.maxGapSize = maxGapSize; 185 } 186 187 /** the Max gap size parameter G . default is 30, which was 188 * described to obtained empirically in the CE paper. 189 * the larger the max gap size, the longer the compute time, 190 * but in same cases drastically improved results. Set to -1 for unlimited gap size. 191 * 192 * @return max gap size parameter 193 */ 194 public Integer getMaxGapSize() { 195 return maxGapSize; 196 } 197 198 199 @Override 200 public List<String> getUserConfigHelp() { 201 List<String> params =new ArrayList<String>(); 202 String helpMaxGap = "This parameter configures the maximum gap size G, that is applied during the AFP extension. The larger the value, the longer the calculation time can become, Default value is 30. Set to 0 for no limit. " ; 203 //String helpRmsdThr = "This configures the RMSD threshold applied during the trace of the fragment matrix."; 204 String helpWinSize = "This configures the fragment size m of Aligned Fragment Pairs (AFPs)."; 205 206 params.add(helpMaxGap); 207 //params.add(helpRmsdThr); 208 params.add(helpWinSize); 209 params.add("Which scoring function to use: "+CliTools.getEnumValuesAsString(ScoringStrategy.class) ); 210 params.add("The maximum RMSD at which to stop alignment optimization. (default: unlimited=99)"); 211 params.add("Gap opening penalty during alignment optimization [default: "+DEFAULT_GAP_OPEN+"]."); 212 params.add("Gap extension penalty during alignment optimization [default: "+DEFAULT_GAP_EXTENSION+"]."); 213 return params; 214 } 215 216 @Override 217 public List<String> getUserConfigParameters() { 218 List<String> params = new ArrayList<String>(); 219 params.add("MaxGapSize"); 220 //params.add("RmsdThr"); 221 params.add("WinSize"); 222 params.add("ScoringStrategy"); 223 params.add("MaxOptRMSD"); 224 params.add("GapOpen"); 225 params.add("GapExtension"); 226 227 return params; 228 } 229 230 @Override 231 public List<String> getUserConfigParameterNames(){ 232 List<String> params = new ArrayList<String>(); 233 params.add("max. gap size G (during AFP extension)."); 234 //params.add("RMSD threshold during trace of the fragment matrix."); 235 params.add("fragment size m"); 236 params.add("Which scoring function to use"); 237 params.add("RMSD threshold for alignment."); 238 params.add("Gap open"); 239 params.add("Gap extension"); 240 return params; 241 } 242 243 @Override 244 @SuppressWarnings("rawtypes") 245 public List<Class> getUserConfigTypes() { 246 List<Class> params = new ArrayList<Class>(); 247 params.add(Integer.class); 248 //params.add(Double.class); 249 params.add(Integer.class); 250 params.add(ScoringStrategy.class); 251 params.add(Double.class); 252 params.add(Double.class); 253 params.add(Double.class); 254 return params; 255 } 256 257 258 259 /** 260 * @return whether information about AFPs should be printed 261 */ 262 public boolean isShowAFPRanges() 263 { 264 return showAFPRanges; 265 } 266 public void setShowAFPRanges(boolean showAFPRanges) 267 { 268 this.showAFPRanges = showAFPRanges; 269 } 270 271 272 273 274 275 /** set the maximum RMSD cutoff to be applied during alignment optimization. (default: 99 = unlimited) 276 * 277 * @param param maxOptRMSD 278 */ 279 public void setMaxOptRMSD(Double param){ 280 if ( param == null) 281 param = 99d; 282 maxOptRMSD = param; 283 } 284 285 /** Returns the maximum RMSD cutoff to be applied during alignment optimization (default: 99 = unlimited) 286 * 287 * @return maxOptRMSD 288 */ 289 public Double getMaxOptRMSD() 290 { 291 return maxOptRMSD; 292 } 293 294 295 296 public Double getGapOpen() 297 { 298 return gapOpen; 299 } 300 301 302 303 public void setGapOpen(Double gapOpen) 304 { 305 this.gapOpen = gapOpen; 306 } 307 308 309 310 public Double getGapExtension() 311 { 312 return gapExtension; 313 } 314 315 316 317 public void setGapExtension(Double gapExtension) 318 { 319 this.gapExtension = gapExtension; 320 } 321 322 323 324 public Double getDistanceIncrement() 325 { 326 return distanceIncrement; 327 } 328 329 330 331 public void setDistanceIncrement(Double distanceIncrement) 332 { 333 this.distanceIncrement = distanceIncrement; 334 } 335 336 337 338 /** Get the Original RMSD threshold from which the alignment optimization is started 339 * 340 * @return oRMSDThreshold 341 */ 342 public Double getORmsdThr() 343 { 344 return oRmsdThr; 345 } 346 347 348 349 /** Set the Original RMSD threshold from which the alignment optimization is started 350 * 351 * @param oRmsdThr the threshold 352 */ 353 public void setORmsdThr(Double oRmsdThr) 354 { 355 this.oRmsdThr = oRmsdThr; 356 } 357 358 359 /** Get the maximum nr of times the (slow) optimiziation of alignment should iterate. Default: unlimited 360 * 361 * @param maxNrIterationsForOptimization 362 */ 363 public int getMaxNrIterationsForOptimization() { 364 return maxNrIterationsForOptimization; 365 } 366 367 368 /** Set the maximum nr of times the (slow) optimiziation of alignment should iterate. Default: unlimited 369 * 370 * @param maxNrIterationsForOptimization 371 */ 372 public void setMaxNrIterationsForOptimization(int maxNrIterationsForOptimization) { 373 this.maxNrIterationsForOptimization = maxNrIterationsForOptimization; 374 } 375 376 377 /** Should sequence conservation be considered as part of the alignment? If yes, this weight factor allows to determine how much. 378 * By default this is set to 0, meaning no contribution of the sequence alignment score. 379 * 380 * @return seqWeight the weight factor (default 0) 381 */ 382 383 public double getSeqWeight() { 384 return seqWeight; 385 } 386 387 388 /** Should sequence conservation be considered as part of the alignment? If yes, this weight factor allows to determine how much. 389 * By default this is set to 0, meaning no contribution of the sequence alignment score. 390 * 391 * @param seqWeight the weight factor (default 0) 392 */ 393 public void setSeqWeight(double seqWeight) { 394 this.seqWeight = seqWeight; 395 } 396 397 398 /** Sets the substitution matrix to be used for influencing the alignment with sequence conservation information. 399 * Default: SDM matrix (Prlic et al 2000) 400 * @return substitutionMatrix 401 */ 402 public SubstitutionMatrix<AminoAcidCompound> getSubstitutionMatrix() { 403 if ( substitutionMatrix == null){ 404 substitutionMatrix = SubstitutionMatrixHelper.getMatrixFromAAINDEX(DEFAULT_SUBSTITUTION_MATRIX); 405 406 } 407 return substitutionMatrix; 408 } 409 410 411 /** Sets the substitution matrix to be used for influencing the alignment with sequence conservation information. 412 * Default: SDM matrix (Prlic et al 2000) 413 * @param substitutionMatrix 414 */ 415 public void setSubstitutionMatrix( 416 SubstitutionMatrix<AminoAcidCompound> substitutionMatrix) { 417 this.substitutionMatrix = substitutionMatrix; 418 } 419 420 421 422 423}