Changeset 5076
- Timestamp:
- Aug 25, 2009, 11:15:41 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/overview/GenericOverview.java
r4789 r5076 294 294 Get the validation options currently in use. 295 295 */ 296 @Override 296 297 public ValidationOptions getValidationOptions() 297 298 { -
trunk/src/core/net/sf/basedb/util/overview/OverviewContext.java
r4768 r5076 68 68 public Project getProject(); 69 69 70 /** 71 Get the validation options that are currently in effect. 72 @since 2.13 73 */ 74 public ValidationOptions getValidationOptions(); 75 70 76 /** 71 77 Store an auxilliary object in the overview cache. This is a service -
trunk/src/core/net/sf/basedb/util/overview/OverviewUtil.java
r4767 r5076 130 130 Arrays.asList(new Validator[] 131 131 { 132 Validator.NONMATHCING_ARRAYDESIGN, Validator.MULTIPLE_ARRAYDESIGNS, 132 Validator.NONMATHCING_ARRAYDESIGN, Validator.NONMATCHING_SPOTCOUNT, 133 Validator.MULTIPLE_ARRAYDESIGNS, 133 134 Validator.INCORRECT_PROTOCOLTYPE, Validator.INCORRECT_SOFTWARETYPE, 134 135 Validator.INCORRECT_HARDWARETYPE, Validator.INCORRECT_ARRAY_NUM, -
trunk/src/core/net/sf/basedb/util/overview/ValidationOptions.java
r4789 r5076 44 44 Maps Validator ID to severity. 45 45 */ 46 private Map<String, Severity> options; 46 private Map<String, Severity> severities; 47 48 /** 49 Other options. Key is validator ID + key 50 */ 51 private Map<String, String> options; 47 52 48 53 /** … … 62 67 public ValidationOptions(Preset preset) 63 68 { 64 this.options = new HashMap<String, Severity>(); 69 this.severities = new HashMap<String, Severity>(); 70 this.options = new HashMap<String, String>(); 65 71 if (preset != null) loadFromPreset(preset, true); 66 72 } … … 75 81 public Severity getSeverity(Validator validator) 76 82 { 77 Severity option = options.get(validator.getId());83 Severity option = severities.get(validator.getId()); 78 84 if (option == null) option = validator.getDefaultSeverity(); 79 85 return option; … … 89 95 if (severity == null) 90 96 { 91 options.remove(validator.getId());97 severities.remove(validator.getId()); 92 98 } 93 99 else 94 100 { 95 options.put(validator.getId(), severity); 101 severities.put(validator.getId(), severity); 102 } 103 } 104 105 /** 106 Get the configured option for a validator rule. 107 108 @param validator The validator 109 @param key The key (name) of the option 110 @param defaultValue The default value in case there is no configured value 111 @return The value of the option 112 @since 2.13 113 */ 114 public String getOption(Validator validator, String key, String defaultValue) 115 { 116 String value = options.get(validator.getId() + "+" + key); 117 if (value == null) value = defaultValue; 118 return value; 119 } 120 121 /** 122 Set an option for a validator rule. 123 124 @param validator The validator 125 @param key The key (name) of the option 126 @param value The value to set or null to remove the value 127 @since 2.13 128 */ 129 public void setOption(Validator validator, String key, String value) 130 { 131 key = validator.getId() + "+" + key; 132 if (value == null) 133 { 134 options.remove(key); 135 } 136 else 137 { 138 options.put(key, value); 96 139 } 97 140 } … … 109 152 public void loadFromPreset(Preset preset, boolean clearFirst) 110 153 { 111 if (clearFirst) options.clear(); 154 if (clearFirst) 155 { 156 severities.clear(); 157 options.clear(); 158 } 112 159 for (Map.Entry<String, String> entry : preset) 113 160 { 114 options.put(entry.getKey(), Severity.valueOf(entry.getValue())); 161 String key = entry.getKey(); 162 String value = entry.getValue(); 163 if (key.contains("+")) 164 { 165 options.put(key, value); 166 } 167 else 168 { 169 severities.put(key, Severity.valueOf(value)); 170 } 115 171 } 116 172 } … … 123 179 public void saveToPreset(net.sf.basedb.core.Presets.Preset preset) 124 180 { 125 for (Map.Entry<String, Severity> entry : options.entrySet())181 for (Map.Entry<String, Severity> entry : severities.entrySet()) 126 182 { 127 183 preset.setSetting(entry.getKey(), entry.getValue().name()); 184 } 185 for (Map.Entry<String, String> entry : options.entrySet()) 186 { 187 preset.setSetting(entry.getKey(), entry.getValue()); 128 188 } 129 189 } -
trunk/src/core/net/sf/basedb/util/overview/Validator.java
r4789 r5076 438 438 "array design as of the associated hybridization.", 439 439 "Array design mismatch", Severity.WARNING 440 ); 441 442 /** 443 Validator rule that checks if the number of raw data spots 444 are the same as the number of features (given a certain threshold). 445 Default severity level is WARNING. 446 */ 447 public static final Validator NONMATCHING_SPOTCOUNT = new Validator( 448 "misc.nonmatchingspotcount", "Raw spots <> features", 449 "Checks if the number of raw data spots matches the number of " + 450 "array design features. A threshold can be given as either an " + 451 "absolute number or as a percentage.", 452 "Raw spots <> features", Severity.WARNING 440 453 ); 441 454 -
trunk/src/core/net/sf/basedb/util/overview/validator/RawBioAssayValidator.java
r4816 r5076 25 25 import java.util.Map; 26 26 27 import net.sf.basedb.core.ArrayDesign; 27 28 import net.sf.basedb.core.DbControl; 28 29 import net.sf.basedb.core.Hybridization; … … 31 32 import net.sf.basedb.core.RawDataType; 32 33 import net.sf.basedb.core.Scan; 34 import net.sf.basedb.util.Values; 33 35 import net.sf.basedb.util.overview.Fix; 34 36 import net.sf.basedb.util.overview.OverviewContext; … … 43 45 <li>Two raw bioassays from the same scan uses the same array index: 44 46 {@link Validator#DUPLICATE_ARRAY_NUM} 47 <li>The number of raw data spots is different from the number of 48 features on the array design: {@link Validator#NONMATCHING_SPOTCOUNT}. 45 49 </ul> 46 50 … … 129 133 {} 130 134 135 if (rba.hasArrayDesign() && rba.hasData()) 136 { 137 try 138 { 139 ArrayDesign design = rba.getArrayDesign(); 140 String threshold = context.getValidationOptions().getOption( 141 Validator.NONMATCHING_SPOTCOUNT, "threshold", "5%"); 142 143 int numDbSpots = rba.getNumDbSpots(); 144 int numDbFeatures = design.getNumDbFeatures(); 145 int numFileSpots = rba.getNumFileSpots(); 146 int numFileFeatures = design.getNumFileFeatures(); 147 int maxDbDelta = 0; 148 int maxFileDelta = 0; 149 if (threshold.endsWith("%")) 150 { 151 int percentage = Values.getInt(threshold.substring(0, threshold.length()-1)); 152 if (numDbFeatures > 0) maxDbDelta = (numDbFeatures * percentage) / 100; 153 if (numFileFeatures > 0) maxFileDelta = (numFileFeatures * percentage) / 100; 154 } 155 else 156 { 157 maxDbDelta = Values.getInt(threshold); 158 maxFileDelta = maxDbDelta; 159 } 160 161 162 if (numDbSpots > 0 && Math.abs(numDbFeatures - numDbSpots) > maxDbDelta) 163 { 164 context.createFailure(Validator.NONMATCHING_SPOTCOUNT, node, 165 "Raw spots (db) <> features by more than " + threshold + ": " + 166 numDbSpots + "<>" + numDbFeatures); 167 } 168 if (numFileSpots > 0 && Math.abs(numFileFeatures - numFileSpots) > maxFileDelta) 169 { 170 context.createFailure(Validator.NONMATCHING_SPOTCOUNT, node, 171 "Raw spots (file) <> features by more than " + threshold + ": " + 172 numFileSpots + "<>" + numFileFeatures); 173 } 174 175 } 176 catch (Exception ex) 177 {} 178 } 131 179 } 132 180 -
trunk/www/common/overview/index.jsp
r4864 r5076 96 96 } 97 97 } 98 options.setOption(Validator.NONMATCHING_SPOTCOUNT, "threshold", request.getParameter("threshold")); 98 99 options.saveToPreset(presets.getDefault()); 99 100 OverviewUtil.saveValidationPresets(sc); … … 112 113 } 113 114 } 115 preset.setSetting(Validator.NONMATCHING_SPOTCOUNT.getId() + "+threshold", 116 request.getParameter("threshold")); 114 117 OverviewUtil.saveValidationPresets(sc); 115 118 forward = "options.jsp"; -
trunk/www/common/overview/options.jsp
r4745 r5076 50 50 final DbControl dc = sc.newDbControl(); 51 51 final String presetName = Values.getStringOrNull(request.getParameter("presetName")); 52 final boolean resetToDefault = Values.getBoolean(request.getParameter("resetToDefault")); 52 53 try 53 54 { 54 55 Presets presets = OverviewUtil.getValidationPresets(sc); 55 ValidationOptions options = presetName == null ? 56 new ValidationOptions() : 57 new ValidationOptions(presets.getPreset(presetName)); 56 ValidationOptions options = null; 57 if (resetToDefault) 58 { 59 options = new ValidationOptions(); 60 } 61 else if (presetName == null) 62 { 63 options = new ValidationOptions(presets.getDefault()); 64 } 65 else 66 { 67 options = new ValidationOptions(presets.getPreset(presetName)); 68 } 58 69 Map<String, List<Validator>> validators = OverviewUtil.getValidators(); 59 70 %> … … 128 139 var frm = document.forms['options']; 129 140 var selected = frm.presets[frm.presets.selectedIndex].value; 130 if (selected != '---') 131 { 132 location.href = 'options.jsp?ID=<%=ID%>&presetName='+escape(selected); 141 if (selected == '') 142 { 143 location.href = 'options.jsp?ID=<%=ID%>&resetToDefault=1'; 144 } 145 else if (selected != '---') 146 { 147 location.href = 'options.jsp?ID=<%=ID%>&presetName='+encodeURIComponent(selected); 133 148 } 134 149 } … … 208 223 /> <b><%=HTML.encodeTags(title)%></b></a> 209 224 </td> 210 <td style="padding-top: 6px;" >225 <td style="padding-top: 6px;" colspan="3"> 211 226 <select name="setall.<%=grp%>" onchange="setAllOnChange(<%=grp%>, this)"> 212 227 <option value="">- set all in this group - … … 243 258 image="<%=hasNext ? "joust/big/join.gif" : "joust/big/joinbottom.gif"%>" 244 259 /><%=HTML.encodeTags(validator.getTitle())%> </td> 245 <td >260 <td colspan="3"> 246 261 <select id="select.<%=grp%>.<%=vld%>" name="<%=validatorId%>"> 247 262 <% … … 254 269 %> 255 270 </select> 271 <% 272 if (validator == Validator.NONMATCHING_SPOTCOUNT) 273 { 274 %> 275 Threshold: 276 <input type="text" class="text" 277 name="threshold" 278 title="Threshold, as a percentage or an absolute value" 279 size="8" 280 value="<%=HTML.encodeTags(options.getOption(validator, "threshold", "5%"))%>" > 281 <% 282 } 283 %> 256 284 </td> 257 285 </tr>
Note: See TracChangeset
for help on using the changeset viewer.