Changeset 4134


Ignore:
Timestamp:
Feb 8, 2008, 2:48:22 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #921: Experiment overview should be updated with support for mutli-array slides

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  
    311311 
    312312  /**
     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  /**
    313338    Create a new {@link Scan} from this hybridization.
    314339   
  • trunk/src/core/net/sf/basedb/util/overview/ExperimentOverview.java

    r4129 r4134  
    168168            Validator.NONMATHCING_ARRAYDESIGN, Validator.MULTIPLE_ARRAYDESIGNS,
    169169            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,
    171172            Validator.NONUNIQUE_LABEL, Validator.DIFFERENT_LABEL,
    172173            Validator.NONUNIQUE_NAME_FOR_TYPE, Validator.NONUNIQUE_NAME_GLOBAL,
     
    261262  private Map<String, Node> allNodes;
    262263  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;
    264266 
    265267  /**
     
    299301  {
    300302    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>();
    302305   
    303306    // Load 'Required for MIAME' annotation types (parameter='false' must also be set)
     
    349352    }
    350353   
     354    usedHybArrays.clear(); // No longer needed
    351355    this.allNodes = new HashMap<String, Node>();
    352356    allNodes.put(rootNode.getId(), rootNode);
     
    470474  public Set<Annotatable> getAnnotatableParents(Annotatable item)
    471475  {
    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);
    473503    if (parents == null)
    474504    {
    475505      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();
    478509      if (temp != null)
    479510      {
     
    481512        {
    482513          parents.add(a);
    483           parents.addAll(getAnnotatableParents(a));
     514          parents.addAll(getAnnotatableParents(a, root));
    484515        }
    485516      }
    486517    }
    487518    return parents;
     519   
    488520  }
    489521 
     
    773805      addImages(dc, scanNode);
    774806      addHardware(dc, scanNode, "Scanner");
    775       addHybridization(dc, scanNode);
     807      addHybridization(dc, scanNode, rawBioAssayNode);
    776808      addProtocol(dc, scanNode, Project.Default.SCANNING_PROTOCOL);
    777809    }
     
    788820    Creates an item-type node with the name <code>hybridization</code>.
    789821  */
    790   private Node addHybridization(DbControl dc, Node scanNode)
     822  private Node addHybridization(DbControl dc, Node scanNode, Node rawBioAssayNode)
    791823  {
    792824    Scan scan = (Scan)scanNode.getItem();
     825    RawBioAssay rba = (RawBioAssay)rawBioAssayNode.getItem();
    793826    Node hybNode = null;
    794827    Hybridization hyb = null;
     
    806839      hybNode = new Node("hybridization", "Hybridization: " + hyb.getName(), scanNode, hyb);
    807840      addAnnotations(dc, hybNode);
    808       addLabeledExtracts(dc, hybNode);
     841      addLabeledExtracts(dc, hybNode, rawBioAssayNode);
    809842      addHardware(dc, hybNode, "Hyb. station");
    810843      addProtocol(dc, hybNode, Project.Default.HYBRIDIZATION_PROTOCOL);
    811844      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     
    812879    }
    813880    if (hybNode == null)
     
    853920  */
    854921  @SuppressWarnings("unchecked")
    855   private Node addLabeledExtracts(DbControl dc, Node hybNode)
     922  private Node addLabeledExtracts(DbControl dc, Node hybNode, Node rawBioAssayNode)
    856923  {
    857924    Node leNode = new Node("labeledextracts", "Labeled extracts", hybNode);
    858925    Hybridization hyb = (Hybridization)hybNode.getItem();
     926    RawBioAssay rba = (RawBioAssay)rawBioAssayNode.getItem();
     927    int arrayNum = rba.getArrayNum();
    859928    ItemQuery<LabeledExtract> leQuery =
    860       (ItemQuery<LabeledExtract>)initQuery(hyb.getCreationEvent().getSources(), null, "label.name");
     929      initQuery(hyb.getLabeledExtracts(arrayNum), null, "label.name");
    861930    int added = 0;
    862931    int channels = experiment.getRawDataType().getChannels();
     
    893962      String message = added > channels ?
    894963        "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);
    896968    }
    897969   
     
    900972    {
    901973      Failure failure = new Failure(Validator.NONUNIQUE_LABEL, hybNode);
     974      failure.setDescriptor(arrayNum);
    902975      failure.addFix(new Fix("Change labeled extracts on hybridization", hyb));
    903976      for (LabeledExtract le : nonUnique)
     
    907980      failures.add(failure);
    908981    }
     982   
    909983    return leNode;
    910984  }
     
    18261900                "Inheriting annotation '" + (at != null ?
    18271901                  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)
    18291903              ));
    18301904            }
  • trunk/src/core/net/sf/basedb/util/overview/Failure.java

    r4034 r4134  
    3939  this object is a bit unorthodox. Two failures are considered equal
    4040  if they have the same validator but different nodes referencing the
    41   same item. Two failures on the same node are never equal. This allows
    42   us to filter out duplicate failures that happens because there
    43   can be several ways to reach a certain item (for example a reference
    44   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).   
    4545 
    4646  @author Nicklas
     
    5959  private String message;
    6060  private List<Fix> fixes;
     61  private Object descriptor;
    6162 
    6263  /**
     
    102103 
    103104  /**
     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  /**
    104129    Get the validation rule that failed.
    105130  */
     
    154179  /**
    155180    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.
    157182  */
    158183  @Override
     
    165190    boolean sameItem = sameNode || this.node.getItem() ==  other.node.getItem();
    166191    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;
    168195  }
    169196
  • trunk/src/core/net/sf/basedb/util/overview/Validator.java

    r3859 r4134  
    468468      "Checks if the hardware attached to an item has a correct hardware type.",
    469469      "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
    470494    );
    471495 
Note: See TracChangeset for help on using the changeset viewer.