Ejemplo n.º 1
0
  private void processFilter(Session session, Element element, HashMap additionalInformation) {

    String match = getAttribute(element, SessionAttribute.FILTER_MATCH.getText());
    String showAllTracks = getAttribute(element, SessionAttribute.FILTER_SHOW_ALL_TRACKS.getText());

    String filterName = getAttribute(element, SessionAttribute.NAME.getText());
    TrackFilter filter = new TrackFilter(filterName, null);
    additionalInformation.put(SessionElement.FILTER, filter);

    NodeList elements = element.getChildNodes();
    process(session, elements, additionalInformation);

    // Save the filter
    session.setFilter(filter);

    // Set filter properties
    if ("all".equalsIgnoreCase(match)) {
      IGV.getInstance().setFilterMatchAll(true);
    } else if ("any".equalsIgnoreCase(match)) {
      IGV.getInstance().setFilterMatchAll(false);
    }

    if ("true".equalsIgnoreCase(showAllTracks)) {
      IGV.getInstance().setFilterShowAllTracks(true);
    } else {
      IGV.getInstance().setFilterShowAllTracks(false);
    }
  }
Ejemplo n.º 2
0
  private void processPreferences(Session session, Element element, HashMap additionalInformation) {

    NodeList elements = element.getChildNodes();
    for (int i = 0; i < elements.getLength(); i++) {
      Node child = elements.item(i);
      if (child.getNodeName().equalsIgnoreCase(SessionElement.PROPERTY.getText())) {
        Element childNode = (Element) child;
        String name = getAttribute(childNode, SessionAttribute.NAME.getText());
        String value = getAttribute(childNode, SessionAttribute.VALUE.getText());
        session.setPreference(name, value);
      }
    }
  }
Ejemplo n.º 3
0
  private void processGeneList(Session session, Element element, HashMap additionalInformation) {

    String name = getAttribute(element, SessionAttribute.NAME.getText());

    String txt = element.getTextContent();
    String[] genes = txt.trim().split("\\s+");
    GeneList gl = new GeneList(name, Arrays.asList(genes));
    GeneListManager.getInstance().addGeneList(gl);
    session.setCurrentGeneList(gl);

    // Adjust frames
    processFrames(element);
  }
Ejemplo n.º 4
0
  private void processFrames(Element element) {
    NodeList elements = element.getChildNodes();
    if (elements.getLength() > 0) {
      Map<String, ReferenceFrame> frames = new HashMap();
      for (ReferenceFrame f : FrameManager.getFrames()) {
        frames.put(f.getName(), f);
      }
      List<ReferenceFrame> reorderedFrames = new ArrayList();

      for (int i = 0; i < elements.getLength(); i++) {
        Node childNode = elements.item(i);
        if (childNode.getNodeName().equalsIgnoreCase(SessionElement.FRAME.getText())) {
          String frameName = getAttribute((Element) childNode, SessionAttribute.NAME.getText());

          ReferenceFrame f = frames.get(frameName);
          if (f != null) {
            reorderedFrames.add(f);
            try {
              String chr = getAttribute((Element) childNode, SessionAttribute.CHR.getText());
              final String startString =
                  getAttribute((Element) childNode, SessionAttribute.START.getText())
                      .replace(",", "");
              final String endString =
                  getAttribute((Element) childNode, SessionAttribute.END.getText())
                      .replace(",", "");
              int start = ParsingUtils.parseInt(startString);
              int end = ParsingUtils.parseInt(endString);
              org.broad.igv.feature.Locus locus = new Locus(chr, start, end);
              f.jumpTo(locus);
            } catch (NumberFormatException e) {
              e.printStackTrace(); // To change body of catch statement use File | Settings |
              // File Templates.
            }
          }
        }
      }
      if (reorderedFrames.size() > 0) {
        FrameManager.setFrames(reorderedFrames);
      }
    }
    IGV.getInstance().resetFrames();
  }
Ejemplo n.º 5
0
  private void processResource(Session session, Element element, HashMap additionalInformation) {

    String nodeName = element.getNodeName();
    boolean oldSession = nodeName.equals(SessionElement.DATA_FILE.getText());

    String label = getAttribute(element, SessionAttribute.LABEL.getText());
    String name = getAttribute(element, SessionAttribute.NAME.getText());
    String sampleId = getAttribute(element, SessionAttribute.SAMPLE_ID.getText());
    String description = getAttribute(element, SessionAttribute.DESCRIPTION.getText());
    String type = getAttribute(element, SessionAttribute.TYPE.getText());
    String coverage = getAttribute(element, SessionAttribute.COVERAGE.getText());
    String trackLine = getAttribute(element, SessionAttribute.TRACK_LINE.getText());
    String colorString = getAttribute(element, SessionAttribute.COLOR.getText());

    String relPathValue = getAttribute(element, SessionAttribute.RELATIVE_PATH.getText());
    boolean isRelativePath = ((relPathValue != null) && relPathValue.equalsIgnoreCase("true"));
    String serverURL = getAttribute(element, SessionAttribute.SERVER_URL.getText());

    // Older sessions used the "name" attribute for the path.
    String path = getAttribute(element, SessionAttribute.PATH.getText());

    if (oldSession && name != null) {
      path = name;
      int idx = name.lastIndexOf("/");
      if (idx > 0 && idx + 1 < name.length()) {
        name = name.substring(idx + 1);
      }
    }

    ResourceLocator resourceLocator;
    if (isRelativePath) {
      final String sessionPath = session.getPath();

      String absolutePath;
      if (sessionPath == null) {
        log.error("Null session path -- this is not expected");
        MessageUtils.showMessage("Unexpected error loading session: null session path");
        return;
      }
      absolutePath = FileUtils.getAbsolutePath(path, sessionPath);
      fullToRelPathMap.put(absolutePath, path);
      resourceLocator = new ResourceLocator(serverURL, absolutePath);

      // If the resourceLocator is relative, we assume coverage is as well
      if (coverage != null) {
        String absoluteCoveragePath = FileUtils.getAbsolutePath(coverage, sessionPath);
        resourceLocator.setCoverage(absoluteCoveragePath);
      }
    } else {
      resourceLocator = new ResourceLocator(serverURL, path);
      resourceLocator.setCoverage(coverage);
    }

    String url = getAttribute(element, SessionAttribute.URL.getText());
    if (url == null) {
      url = getAttribute(element, SessionAttribute.FEATURE_URL.getText());
    }
    resourceLocator.setUrl(url);

    String infolink = getAttribute(element, SessionAttribute.HYPERLINK.getText());
    if (infolink == null) {
      infolink = getAttribute(element, SessionAttribute.INFOLINK.getText());
    }
    resourceLocator.setInfolink(infolink);

    // Label is deprecated in favor of name.
    if (name != null) {
      resourceLocator.setName(name);
    } else {
      resourceLocator.setName(label);
    }

    resourceLocator.setSampleId(sampleId);

    resourceLocator.setDescription(description);
    // This test added to get around earlier bug in the writer
    if (type != null && !type.equals("local")) {
      resourceLocator.setType(type);
    }
    resourceLocator.setCoverage(coverage);
    resourceLocator.setTrackLine(trackLine);

    if (colorString != null) {
      try {
        Color c = ColorUtilities.stringToColor(colorString);
        resourceLocator.setColor(c);
      } catch (Exception e) {
        log.error("Error setting color: ", e);
      }
    }

    dataFiles.add(resourceLocator);

    NodeList elements = element.getChildNodes();
    process(session, elements, additionalInformation);
  }