Ejemplo n.º 1
0
  @Override
  public Map<Integer, Set<TagBarcode>> getApplicableBarcodes() {
    if (tagBarcodeMap.isEmpty()) {
      if (requestManager != null) {
        tagBarcodeMap.put(1, new TreeSet<TagBarcode>());

        try {
          List<TagBarcode> barcodes =
              new ArrayList<TagBarcode>(
                  requestManager.listAllTagBarcodesByPlatform(PlatformType.ILLUMINA.getKey()));
          for (TagBarcode t : barcodes) {
            if (getName().equals(t.getStrategyName())
                && t.getName() != null
                && t.getName().startsWith("Index ")) {
              log.debug("Registering tag barcode: " + t.getName());
              tagBarcodeMap.get(1).add(t);
            }
          }
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
    return tagBarcodeMap;
  }
  public JSONObject plateElementsDataTable(HttpSession session, JSONObject json) {
    if (json.has("plateId")) {
      try {
        JSONObject j = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        long plateId = json.getLong("plateId");

        Plate<? extends List<? extends Plateable>, ? extends Plateable> plate =
            requestManager.getPlateById(plateId);
        if (plate != null) {
          for (Plateable p : plate.getElements()) {
            if (p instanceof Library) {
              Library l = (Library) p;
              String strategyName = "No barcode";

              StringBuilder seqbuilder = new StringBuilder();
              if (!l.getTagBarcodes().isEmpty()) {
                int count = 1;
                Collection<TagBarcode> barcodes = l.getTagBarcodes().values();
                for (TagBarcode tb : barcodes) {
                  strategyName = tb.getStrategyName();
                  seqbuilder.append(tb.getSequence());
                  if (l.getTagBarcodes().values().size() > 1
                      && count < l.getTagBarcodes().values().size()) {
                    seqbuilder.append("-");
                  }
                  count++;
                }
              } else {
                log.info("No tag barcodes!");
              }

              jsonArray.add(
                  "['"
                      + l.getName()
                      + "','"
                      + l.getAlias()
                      + "','"
                      + strategyName
                      + "','"
                      + seqbuilder.toString()
                      + "','"
                      + "<a href=\"/miso/library/"
                      + l.getId()
                      + "\"><span class=\"ui-icon ui-icon-pencil\"></span></a>"
                      + "']");
            }
          }
        }
        j.put("elementsArray", jsonArray);
        return j;
      } catch (IOException e) {
        log.debug("Failed", e);
        return JSONUtils.SimpleJSONError("Failed: " + e.getMessage());
      }
    } else {
      return JSONUtils.SimpleJSONError("No plates to show");
    }
  }