Пример #1
0
  void draw(Graphics2D g) {

    int endX, endY;
    Block from = null;
    if (fromId > -1) from = diag.blocks.get(new Integer(fromId));
    Block to = null;
    if (!endsAtLine && toId > -1) to = diag.blocks.get(new Integer(toId));

    if (toX == -1) endX = diag.xa;
    else endX = toX;

    if (toY == -1) endY = diag.ya;
    else endY = toY;

    g.setColor(Color.GRAY);

    Stroke stroke = g.getStroke();
    ZigzagStroke zzstroke = new ZigzagStroke(stroke, 2, 4);

    if (toX == -1) {
      g.drawRect(fromX - 3, fromY - 3, 6, 6);
      return;
    }

    if (from != null) {
      if (fromSide == Side.TOP) fromY = from.cy - from.height / 2;
      else if (fromSide == Side.BOTTOM) fromY = from.cy + from.height / 2;
      else if (fromSide == Side.LEFT) fromX = from.cx - from.width / 2;
      else if (fromSide == Side.RIGHT) fromX = from.cx + from.width / 2;
    }

    if (to != null) {
      if (toSide == Side.TOP) toY = to.cy - to.height / 2;
      else if (toSide == Side.BOTTOM) toY = to.cy + to.height / 2;
      else if (toSide == Side.LEFT) toX = to.cx - to.width / 2;
      else if (toSide == Side.RIGHT) toX = to.cx + to.width / 2;
    }

    if (driver.selArrowP == this) g.setColor(Color.BLUE);
    else if ((from instanceof ComponentBlock
            || from instanceof ExtPortBlock
            || from instanceof Enclosure)
        && (to instanceof ComponentBlock
            || to instanceof ExtPortBlock
            || to instanceof Enclosure
            || endsAtLine))
      if (checkStatus == Status.UNCHECKED) g.setColor(Color.BLACK);
      else if (checkStatus == Status.COMPATIBLE) g.setColor(FOREST_GREEN);
      else g.setColor(ORANGE_RED);
    else if (from instanceof LegendBlock || to instanceof LegendBlock) g.setColor(Color.GRAY);

    int fx, fy, tx, ty;
    fx = fromX;
    fy = fromY;
    // tx = toX;
    // ty = toY;
    // int autoX = -1, autoY = -1;  // only used for automatic ports
    if (bends != null) {
      for (Bend bend : bends) {
        tx = bend.x;
        ty = bend.y;
        if (!dropOldest) g.drawLine(fx, fy, tx, ty);
        else {
          Shape shape = new Line2D.Double(fx, fy, tx, ty);
          shape = zzstroke.createStrokedShape(shape);
          g.draw(shape);
          // g.setStroke(stroke);
        }

        if (bend.marked) {
          Color col = g.getColor();
          g.setColor(Color.RED);
          g.drawOval(tx - 5, ty - 5, 10, 10);
          g.setColor(col);
        }
        calcLimits(fx, tx, fy, ty);
        fx = tx;
        fy = ty;
      }
    }
    tx = endX;
    ty = endY;

    int x = endX;
    if (to != null && endsAtBlock && to.multiplex) {
      String s = to.mpxfactor;
      if (s == null) s = " ";
      int i = s.length() * driver.fontWidth + 10;
      x -= i;
    }

    if (headMarked) {
      Color col = g.getColor();
      g.setColor(Color.RED);
      g.drawOval(x - 5, toY - 5, 10, 10);
      g.setColor(col);
    }

    if (!dropOldest) g.drawLine(fx, fy, tx, ty);
    else {
      Shape shape = new Line2D.Double(fx, fy, tx, ty);
      shape = zzstroke.createStrokedShape(shape);
      g.draw(shape);
      // g.setStroke(stroke);
    }

    if (tailMarked) {
      Color col = g.getColor();
      g.setColor(Color.RED);
      g.drawOval(fromX - 5, fromY - 5, 10, 10);
      g.setColor(col);
    }

    calcLimits(fx, x, fy, toY);

    if (!endsAtBlock && !endsAtLine) {
      g.drawRect(fromX - 3, fromY - 3, 6, 6);
      g.drawRect(x - 3, toY - 3, 6, 6);
    } else if (endsAtBlock) {
      if ((from instanceof ComponentBlock
              || from instanceof ExtPortBlock
              || from instanceof Enclosure)
          && (to instanceof ComponentBlock
              || to instanceof ExtPortBlock
              || to instanceof Enclosure)) {
        Arrowhead ah = new Arrowhead(fx, fy, toX, toY);
        ah.draw(g);
      }

    } else if (endsAtLine) {
      drawCircleTo(g, fx, fy, x, toY, Color.BLACK, 4);
      // g.drawOval(toX - 2, toY - 2, 4, 4);
      // g.fillOval(toX - 2, toY - 2, 4, 4);
    }

    if (toX != -1 && (endsAtBlock || endsAtLine)) {
      if (upStreamPort != null && (from instanceof ComponentBlock || from instanceof Enclosure)) {
        if (upStreamPort.equals("*")) {
          drawCircleFrom(g, fromX, fromY, endX, endY, Color.BLUE, 8);
          // g.setColor(Color.BLUE);
          // g.drawOval(fromX, fromY - 4, 8, 8);
          // g.fillOval(fromX, fromY - 4, 8, 8);
        } else if (from.visible) {
          g.setColor(Color.BLUE);
          int y = fromY + driver.fontHeight;
          int x2 = fromX + driver.fontWidth;
          g.drawString(upStreamPort, x2, y);
        }
        g.setColor(Color.BLACK);
      }
      if (downStreamPort != null
          && !endsAtLine
          && to != null
          && (to instanceof ComponentBlock || to instanceof Enclosure)) {
        if (downStreamPort.equals("*")) {
          drawCircleTo(g, fx, fy, toX, toY, Color.BLUE, 8);
          // g.setColor(Color.BLUE);
          // g.drawOval(x - 8, toY - 4, 8, 8);
          // g.fillOval(x - 8, toY - 4, 8, 8);
        } else if (to.visible) {
          g.setColor(Color.BLUE);
          int y = toY - driver.fontHeight / 2;
          x = toX - driver.fontWidth * (downStreamPort.length() + 1);
          if (!endsAtLine && to != null && to.multiplex) x -= 20;
          g.drawString(downStreamPort, x, y);
        }
        g.setColor(Color.BLACK);
      }
    }
    if (extraArrowhead != null) extraArrowhead.draw(g);
  }
Пример #2
0
/**
 * Factory for command line tools to call different functions
 *
 * @author Muhammad Shamim
 * @since 1/30/2015
 */
public class CLTFactory {

  // Commenting some out because we're not going to release all these when we release CLT
  private static final String[] commandLineToolUsages = {
    //        "addGWNorm",    "addGWNorm <input_HiC_file> <min resolution>",
    //        "addNorm",      "addNorm <input_HiC_file> [0 for no frag, 1 for no single frag]",
    //        "bigWig",       "bigWig <bigWig path or URL> <window size in bp> [chr] [start base]
    // [end base]",
    //        "binToPairs",   "binToPairs <input_HiC_file> <output_HiC_file>",
    //        "bpToFrag",     "bpToFrag <fragmentFile> <inputBedFile> <outputFile>",
    //        "calcKR",       "calcKR <input_HiC_file>",
    //        "fragmentToBed","fragmentToBed <fragmentFile>",
    //        "pairsToBin",   "pairsToBin <input_HiC_file> <output_HiC_file> <genomeID>",
    //        "db",           "db <frag|annot|update> [items]",
    Dump.getUsage(),
    PreProcessing.getBasicUsage(),
    APA.getBasicUsage(),
    Arrowhead.getBasicUsage(),
    HiCCUPS.getBasicUsage(),
    HiCCUPSDiff.getBasicUsage(),
    ValidateFile.getUsage()
  };

  public static void generalUsage() {

    System.out.println("Juicebox and Juicer Command Line Tools Usage:");
    for (String usage : commandLineToolUsages) {
      System.out.println("\t\t" + usage);
    }
    System.out.println("Type juicebox <commandName> for more detailed usage instructions");
  }

  public static JuiceboxCLT getCLTCommand(String cmd) {

    cmd = cmd.toLowerCase();

    if (cmd.equals("pre")) {
      return new PreProcessing();
    } else if (cmd.equals("dump")) {
      return new Dump();
    } else if (cmd.equals("validate")) {
      return new ValidateFile();
    } else if (cmd.equals("addGWNorm".toLowerCase())) {
      return new AddGWNorm();
    } else if (cmd.equals("addNorm".toLowerCase())) {
      return new AddNorm();
    } else if (cmd.equals("apa")) {
      return new APA();
    } else if (cmd.equals("compare")) {
      return new CompareLists();
    } else if (cmd.equals("arrowhead")) {
      return new Arrowhead();
    } else if (cmd.equals("bigWig".toLowerCase())) {
      return new BigWig();
    } else if (cmd.equals("binToPairs".toLowerCase())) {
      return new BinToPairs();
    } else if (cmd.equals("bpToFrag".toLowerCase())) {
      return new BPToFragment();
    } else if (cmd.equals("calcKR".toLowerCase())) {
      return new CalcKR();
    } else if (cmd.equals("fragmentToBed".toLowerCase())) {
      return new FragmentToBed();
    } else if (cmd.equals("hiccups")) {
      return new HiCCUPS();
    } else if (cmd.equals("motifs")) {
      return new MotifFinder();
    } else if (cmd.equals("pairsToBin".toLowerCase())) {
      return new PairsToBin();
    } else if (cmd.equals("db")) {
      return new SQLDatabase();
    } else if (cmd.equals("hiccupsdiff")) {
      return new HiCCUPSDiff();
    } else if (cmd.equals("ab_compdiff")) {
      return new ABCompartmentsDiff();
    }

    return null;
  }
}