Changeset 4134
- Timestamp:
- Feb 8, 2008, 2:48:22 PM (15 years ago)
- Location:
- trunk/src/core/net/sf/basedb
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/Hybridization.java
r4131 r4134 311 311 312 312 /** 313 Get a query that returns labeled extracts connected to 314 this hybridization. 315 @param arrayNum If > 0 only labeled extracts on the specific sub-array 316 are returned by the query, if <= 0, all labeled extracts 317 are returned 318 @return An {@link ItemQuery} object 319 @since 2.6 320 */ 321 @SuppressWarnings("unchecked") 322 public ItemQuery<LabeledExtract> getLabeledExtracts(int arrayNum) 323 { 324 ItemQuery<LabeledExtract> query = (ItemQuery<LabeledExtract>)getCreationEvent().getSources(); 325 if (arrayNum > 0) 326 { 327 query.restrictPermanent( 328 Restrictions.eq( 329 Hql.property("srcevt", "sourceGroup"), 330 Expressions.integer(arrayNum) 331 ) 332 ); 333 } 334 return query; 335 } 336 337 /** 313 338 Create a new {@link Scan} from this hybridization. 314 339 -
trunk/src/core/net/sf/basedb/util/overview/ExperimentOverview.java
r4129 r4134 168 168 Validator.NONMATHCING_ARRAYDESIGN, Validator.MULTIPLE_ARRAYDESIGNS, 169 169 Validator.INCORRECT_PROTOCOLTYPE, Validator.INCORRECT_SOFTWARETYPE, 170 Validator.INCORRECT_HARDWARETYPE, Validator.INCORRECT_NUM_LABELEDEXTRACTS, 170 Validator.INCORRECT_HARDWARETYPE, Validator.INCORRECT_ARRAY_NUM, 171 Validator.DUPLICATE_ARRAY_NUM, Validator.INCORRECT_NUM_LABELEDEXTRACTS, 171 172 Validator.NONUNIQUE_LABEL, Validator.DIFFERENT_LABEL, 172 173 Validator.NONUNIQUE_NAME_FOR_TYPE, Validator.NONUNIQUE_NAME_GLOBAL, … … 261 262 private Map<String, Node> allNodes; 262 263 private Map<Item, Set<AnnotationType>> miameAnnotations; 263 private Map<Annotatable, Set<Annotatable>> annotatableParents; 264 private Map<Object, Set<Annotatable>> annotatableParents; 265 private Map<String, Node> usedHybArrays; 264 266 265 267 /** … … 299 301 { 300 302 this.failures = new LinkedList<Failure>(); 301 this.annotatableParents = new HashMap<Annotatable, Set<Annotatable>>(); 303 this.annotatableParents = new HashMap<Object, Set<Annotatable>>(); 304 this.usedHybArrays = new HashMap<String, Node>(); 302 305 303 306 // Load 'Required for MIAME' annotation types (parameter='false' must also be set) … … 349 352 } 350 353 354 usedHybArrays.clear(); // No longer needed 351 355 this.allNodes = new HashMap<String, Node>(); 352 356 allNodes.put(rootNode.getId(), rootNode); … … 470 474 public Set<Annotatable> getAnnotatableParents(Annotatable item) 471 475 { 472 Set<Annotatable> parents = annotatableParents.get(item); 476 return getAnnotatableParents(item, item); 477 } 478 479 private Set<Annotatable> getAnnotatableParents(Annotatable current, Annotatable root) 480 { 481 Object cacheKey = current; 482 Hybridization hyb = null; 483 int arrayNum = 1; 484 // Special case when starting with a raw bioassay since we only 485 // want to get parents from the sub-array with the same 486 // index = rba.getArrayNum() 487 if (root instanceof RawBioAssay) 488 { 489 RawBioAssay rba = (RawBioAssay)root; 490 arrayNum = rba.getArrayNum(); 491 if (current instanceof Scan) 492 { 493 cacheKey = "SCAN:" + current.getId() + ":" + arrayNum; 494 } 495 else if (current instanceof Hybridization) 496 { 497 hyb = (Hybridization)current; 498 cacheKey = "HYB:" + hyb.getId() + ":" + arrayNum; 499 } 500 } 501 502 Set<Annotatable> parents = annotatableParents.get(cacheKey); 473 503 if (parents == null) 474 504 { 475 505 parents = new HashSet<Annotatable>(); 476 annotatableParents.put(item, parents); 477 Set<Annotatable> temp = item.getAnnotatableParents(); 506 annotatableParents.put(cacheKey, parents); 507 Set<Annotatable> temp = hyb != null ? 508 hyb.getAnnotatableParents(arrayNum) : current.getAnnotatableParents(); 478 509 if (temp != null) 479 510 { … … 481 512 { 482 513 parents.add(a); 483 parents.addAll(getAnnotatableParents(a ));514 parents.addAll(getAnnotatableParents(a, root)); 484 515 } 485 516 } 486 517 } 487 518 return parents; 519 488 520 } 489 521 … … 773 805 addImages(dc, scanNode); 774 806 addHardware(dc, scanNode, "Scanner"); 775 addHybridization(dc, scanNode );807 addHybridization(dc, scanNode, rawBioAssayNode); 776 808 addProtocol(dc, scanNode, Project.Default.SCANNING_PROTOCOL); 777 809 } … … 788 820 Creates an item-type node with the name <code>hybridization</code>. 789 821 */ 790 private Node addHybridization(DbControl dc, Node scanNode )822 private Node addHybridization(DbControl dc, Node scanNode, Node rawBioAssayNode) 791 823 { 792 824 Scan scan = (Scan)scanNode.getItem(); 825 RawBioAssay rba = (RawBioAssay)rawBioAssayNode.getItem(); 793 826 Node hybNode = null; 794 827 Hybridization hyb = null; … … 806 839 hybNode = new Node("hybridization", "Hybridization: " + hyb.getName(), scanNode, hyb); 807 840 addAnnotations(dc, hybNode); 808 addLabeledExtracts(dc, hybNode );841 addLabeledExtracts(dc, hybNode, rawBioAssayNode); 809 842 addHardware(dc, hybNode, "Hyb. station"); 810 843 addProtocol(dc, hybNode, Project.Default.HYBRIDIZATION_PROTOCOL); 811 844 addArraySlide(dc, hybNode); 845 846 // Check that arrayNum <= hyb.getNumArrays() 847 int arrayNum = rba.getArrayNum(); 848 if (arrayNum > hyb.getNumArrays()) 849 { 850 Failure failure = new Failure(Validator.INCORRECT_ARRAY_NUM, rawBioAssayNode, 851 "Incorrect sub-array index: " + arrayNum + " (expected 1--" + hyb.getNumArrays() + ")", 852 new Fix("Change array index on raw bioassay", rba), 853 new Fix("Increase arrays on hybridization", hyb)); 854 failures.add(failure); 855 } 856 857 String usedHybIndex = hyb.getId() + ":" + arrayNum; 858 if (usedHybArrays.containsKey(usedHybIndex)) 859 { 860 Node other = usedHybArrays.get(usedHybIndex); 861 Fix fixA = new Fix("Change array index on " + rba.getName(), rba); 862 Fix fixB = new Fix("Change array index on " + other.getTitle(), other.getItem()); 863 864 Failure failure = new Failure(Validator.DUPLICATE_ARRAY_NUM, rawBioAssayNode, 865 "Duplicate sub-array index: " + arrayNum + " (used by " + other.getTitle() + ")", 866 fixA, fixB); 867 failures.add(failure); 868 869 failure = new Failure(Validator.DUPLICATE_ARRAY_NUM, other, 870 "Duplicate sub-array index: " + arrayNum + " (used by " + rba.getName() + ")", 871 fixB, fixA); 872 failures.add(failure); 873 } 874 else 875 { 876 usedHybArrays.put(usedHybIndex, rawBioAssayNode); 877 } 878 812 879 } 813 880 if (hybNode == null) … … 853 920 */ 854 921 @SuppressWarnings("unchecked") 855 private Node addLabeledExtracts(DbControl dc, Node hybNode )922 private Node addLabeledExtracts(DbControl dc, Node hybNode, Node rawBioAssayNode) 856 923 { 857 924 Node leNode = new Node("labeledextracts", "Labeled extracts", hybNode); 858 925 Hybridization hyb = (Hybridization)hybNode.getItem(); 926 RawBioAssay rba = (RawBioAssay)rawBioAssayNode.getItem(); 927 int arrayNum = rba.getArrayNum(); 859 928 ItemQuery<LabeledExtract> leQuery = 860 (ItemQuery<LabeledExtract>)initQuery(hyb.getCreationEvent().getSources(), null, "label.name");929 initQuery(hyb.getLabeledExtracts(arrayNum), null, "label.name"); 861 930 int added = 0; 862 931 int channels = experiment.getRawDataType().getChannels(); … … 893 962 String message = added > channels ? 894 963 "Too many labeled extracts" : "Too few labeled extracts"; 895 failures.add(new Failure(Validator.INCORRECT_NUM_LABELEDEXTRACTS, hybNode, message, fix)); 964 message += ": " + added + " (" + channels + " expected)"; 965 Failure failure = new Failure(Validator.INCORRECT_NUM_LABELEDEXTRACTS, hybNode, message, fix); 966 failure.setDescriptor(arrayNum); 967 failures.add(failure); 896 968 } 897 969 … … 900 972 { 901 973 Failure failure = new Failure(Validator.NONUNIQUE_LABEL, hybNode); 974 failure.setDescriptor(arrayNum); 902 975 failure.addFix(new Fix("Change labeled extracts on hybridization", hyb)); 903 976 for (LabeledExtract le : nonUnique) … … 907 980 failures.add(failure); 908 981 } 982 909 983 return leNode; 910 984 } … … 1826 1900 "Inheriting annotation '" + (at != null ? 1827 1901 at.getName() : a.getValueType().toString()) + "' from non-parent", 1828 new Fix(" Remove inherited annotation", parentNode.getItem(), at, true)1902 new Fix("Inherit from another item", parentNode.getItem(), at, true) 1829 1903 )); 1830 1904 } -
trunk/src/core/net/sf/basedb/util/overview/Failure.java
r4034 r4134 39 39 this object is a bit unorthodox. Two failures are considered equal 40 40 if they have the same validator but different nodes referencing the 41 same item . Two failures on the same node are never equal. This allows42 us to filter out duplicate failures that happens because there43 can be several ways to reach a certain item (for example a reference44 sample that is used on all hybridizations).41 same item with the same descriptor. Two failures on the same node 42 are never equal. This allows us to filter out duplicate failures that 43 happens because there can be several ways to reach a certain item (for 44 example a reference sample that is used on all hybridizations). 45 45 46 46 @author Nicklas … … 59 59 private String message; 60 60 private List<Fix> fixes; 61 private Object descriptor; 61 62 62 63 /** … … 102 103 103 104 /** 105 Set a descriptor on this failure. This affects the {@link #equals(Object)} 106 method, since the descriptor must be equal for two failures to be 107 equal. 108 <p> 109 NOTE! The main reason for this property is that we need to discriminate 110 between failures on different sub-arrays on hybridizations. 111 @param descriptor Any object 112 @since 2.6 113 */ 114 public void setDescriptor(Object descriptor) 115 { 116 this.descriptor = descriptor; 117 } 118 /** 119 @return The descriptor 120 @since 2.6 121 @see #setDescriptor(Object) 122 */ 123 public Object getDescriptor() 124 { 125 return descriptor; 126 } 127 128 /** 104 129 Get the validation rule that failed. 105 130 */ … … 154 179 /** 155 180 One failure is the same as another if they have the same validator 156 but different nodes referencing the same item .181 but different nodes referencing the same item with equal descriptors. 157 182 */ 158 183 @Override … … 165 190 boolean sameItem = sameNode || this.node.getItem() == other.node.getItem(); 166 191 boolean sameValidator = this.validator == other.validator; 167 return !sameNode && sameItem && sameValidator; 192 boolean sameSpecificator = sameNode || this.descriptor == other.descriptor || 193 (this.descriptor != null && this.descriptor.equals(other.descriptor)); 194 return !sameNode && sameItem && sameValidator && sameSpecificator; 168 195 } 169 196 -
trunk/src/core/net/sf/basedb/util/overview/Validator.java
r3859 r4134 468 468 "Checks if the hardware attached to an item has a correct hardware type.", 469 469 "Incorrect hardware type", Severity.WARNING 470 ); 471 472 /** 473 Validator rule that checks if the sub-array index on a raw bioassay 474 is between 1 and the number of sub-arrays on the hybridization. 475 Default severity level is WARNING. 476 */ 477 public static final Validator INCORRECT_ARRAY_NUM = new Validator( 478 "misc.incorrectarraynum", "Incorrect sub-array index", 479 "Checks if the sub-array index on a raw bioassay " + 480 "is between 1 and the number of sub-arrays on the hybridization.", 481 "Incorrect sub-array index", Severity.WARNING 482 ); 483 484 /** 485 Validator rule that checks if the same sub-array index is used 486 on more than one raw bioassay from the same hybridization. 487 Default severity level is WARNING. 488 */ 489 public static final Validator DUPLICATE_ARRAY_NUM = new Validator( 490 "misc.duplicatearraynum", "Duplicate sub-array index", 491 "Checks if the same sub-array index is used on more " + 492 "than one raw bioassay from the same hybridization.", 493 "Duplicate sub-array index", Severity.WARNING 470 494 ); 471 495
Note: See TracChangeset
for help on using the changeset viewer.