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 */ 021 022package org.biojavax.bio.alignment.blast; 023 024import java.util.HashMap; 025import java.util.Set; 026import java.util.Arrays; 027 028import org.biojava.bio.BioException; 029import org.biojavax.bio.alignment.RemotePairwiseAlignmentProperties; 030 031/** 032 * 033 * This class implements RemotePairwiseAlignmentProperties by specifying several 034 * convenient methods used to wrap the addition of Blast alignment parameters. 035 * 036 * @author Sylvain Foisy, Diploide BioIT 037 * @since 1.8 038 * 039 */ 040public class RemoteQBlastAlignmentProperties implements 041 RemotePairwiseAlignmentProperties { 042 043 private static final long serialVersionUID = 1L; 044 private HashMap<String, String> param = new HashMap<String, String>(); 045 046 /** 047 * This method returns the value of the program used for this particular 048 * blast run. 049 * 050 * @return program :the name of the blastall program used. 051 */ 052 public String getBlastProgram() { 053 return param.get("PROGRAM"); 054 } 055 056 /** 057 * This method set the program to be use with blastall. This method does a 058 * validation before running on the valid blastall programs: blastn / blastp 059 * / blastx / tblastn / tblastx 060 * 061 * @param program 062 * : one of blastall programs 063 * @exception BioException 064 * if the named program is not a valid blastall options 065 * 066 */ 067 public void setBlastProgram(String program) throws BioException { 068 069 boolean isValid = false; 070 String[] blastPr = new String[]{ "blastn", "blastp", "blastx", "tblastn", "tblastx" }; 071 072// for (int i = 0; i < blastPr.length; i++) { 073// if (program.equals(blastPr[i])) { 074// this.param.put("PROGRAM", program); 075// isValid = true; 076// } 077// } 078 079 if(Arrays.binarySearch(blastPr,program)>=0){ 080 isValid = true; 081 } 082 083 if (!isValid) { 084 throw new BioException( 085 "Invalid blastall program selection! Use one of valid values: blastn/blastp/blastx/tblastn/tblastx"); 086 } 087 } 088 089 /** 090 * This method returns the value of the database used for this particular 091 * blast run. 092 * 093 * @return db :the name of the database used 094 */ 095 public String getBlastDatabase() { 096 return param.get("DATABASE"); 097 } 098 099 /** 100 * This method set the database to be use with blastall 101 * 102 * @param db :a valid name to a NCBI Blastable database 103 */ 104 public void setBlastDatabase(String db) { 105 this.param.put("DATABASE", db); 106 } 107 /** 108 * <p> 109 * This method is to be used if a request is to use non-default values at 110 * submission. According to QBlast info, the accepted parameters for PUT 111 * requests are: 112 * </p> 113 * 114 * <ul> 115 * <li>-G: cost to create a gap. Default = 5 (nuc-nuc) / 11 (protein) / 116 * non-affine for megablast</li> 117 * <li>-E: Cost to extend a gap. Default = 2 (nuc-nuc) / 1 (protein) / 118 * non-affine for megablast</li> 119 * <li>-r: integer to reward for match. Default = 1</li> 120 * <li>-q: negative integer for penalty to allow mismatch. Default = -3</li> 121 * <li>-e: expectation value. Default = 10.0</li> 122 * <li>-W: word size. Default = 3 (proteins) / 11 (nuc-nuc) / 28 (megablast) 123 * </li> 124 * <li>-y: dropoff for blast extensions in bits, using default if not 125 * specified. Default = 20 for blastn, 7 for all others (except megablast 126 * for which it is not applicable).</li> 127 * <li>-X: X dropoff value for gapped alignment, in bits. Default = 30 for 128 * blastn/megablast, 15 for all others.</li> 129 * <li>-Z: final X dropoff value for gapped alignement, in bits. Default = 130 * 50 for blastn, 25 for all others (except megablast for which it is not 131 * applicable)</li> 132 * <li>-P: equals 0 for multiple hits 1-pass, 1 for single hit 1-pass. Does 133 * not apply to blastn ou megablast.</li> 134 * <li>-A: multiple hits window size. Default = 0 (for single hit algorithm) 135 * </li> 136 * <li>-I: number of database sequences to save hits for. Default = 500</li> 137 * <li>-Y: effective length of the search space. Default = 0 (0 represents 138 * using the whole space)</li> 139 * <li>-z: a real specifying the effective length of the database to use. 140 * Default = 0 (0 represents the real size)</li> 141 * <li>-c: an integer representing pseudocount constant for PSI-BLAST. 142 * Default = 7</li> 143 * <li>-F: any filtering directive</li> 144 * </ul> 145 * 146 * <p>WARNING!! This method is still very much in flux and might not work as expected...</p> 147 * <p> 148 * You have to be aware that at not moment is there any error checking on 149 * the use of these parameters by this class. 150 * </p> 151 * 152 * @param aStr 153 * : a String with any number of optional parameters with an 154 * associated value. 155 * 156 */ 157 public void setAdvancedOptions(String aStr) { 158 this.param.put("OTHER_ADVANCED","OTHER_ADVANCED="+ aStr); 159 } 160 161 /** 162 * 163 * Simply return the string given as argument via setBlastAdvancedOptions 164 * 165 * @return advanced :the string with the advanced options 166 */ 167 public String getBlastAdvancedOptions() { 168 return this.param.get("OTHER_ADVANCED"); 169 } 170 public String getAlignmentOption(String key) throws BioException { 171 if(param.containsKey(key)){ 172 return this.param.get(key);} 173 else{ 174 throw new BioException("The key named "+key+" is not set in this RemoteQBlastOutputProperties object"); 175 } 176 } 177 178 public void setAlignementOption(String key, String val) { 179 this.param.put(key, val); 180 } 181 182 public Set<String> getAlignmentOptions() { 183 return param.keySet(); 184 } 185}