Ejemplo n.º 1
0
  public static boolean validateOverhangs(ArrayList<RGraph> graphs) {

    boolean valid = true;

    for (RGraph graph : graphs) {
      ArrayList<RNode> queue = new ArrayList<RNode>();
      HashSet<RNode> seenNodes = new HashSet<RNode>();
      RNode root = graph.getRootNode();
      queue.add(root);
      while (!queue.isEmpty()) {
        RNode current = queue.get(0);
        queue.remove(0);
        seenNodes.add(current);

        if (!("EX".equals(current.getLOverhang()) && "SP".equals(current.getROverhang()))) {
          return false;
        }

        ArrayList<RNode> neighbors = current.getNeighbors();
        for (RNode neighbor : neighbors) {
          if (!seenNodes.contains(neighbor)) {
            queue.add(neighbor);
          }
        }
      }
    }

    return valid;
  }
Ejemplo n.º 2
0
  /**
   * First step of overhang assignment - enforce numeric place holders for overhangs, ie no overhang
   * redundancy in any step *
   */
  private void assignBioBricksOverhangs(
      ArrayList<RGraph> optimalGraphs, HashMap<Integer, Vector> stageVectors) {

    // Initialize fields that record information to save complexity for future steps
    _rootBasicNodeHash = new HashMap<RNode, ArrayList<RNode>>();
    HashMap<Integer, RVector> stageRVectors = new HashMap<Integer, RVector>();
    for (Integer stage : stageVectors.keySet()) {
      RVector vec = ClothoReader.vectorImportClotho(stageVectors.get(stage));
      stageRVectors.put(stage, vec);
    }

    // If the stageVector hash is empty, make a new default vector
    if (stageRVectors.size() == 1) {
      if (stageRVectors.get(1) == null) {
        stageRVectors.put(0, new RVector("EX", "SP", -1, "pSK1A2", null));
      }
    }

    // Loop through each optimal graph and grab the root node to prime for the traversal
    for (RGraph graph : optimalGraphs) {

      RNode root = graph.getRootNode();
      RVector vector = stageRVectors.get(root.getStage() % stageRVectors.size());
      RVector rootVector = new RVector("EX", "SP", -1, vector.getName(), null);
      root.setVector(rootVector);
      root.setLOverhang("EX");
      root.setROverhang("SP");
      ArrayList<RNode> l0nodes = new ArrayList<RNode>();
      _rootBasicNodeHash.put(root, l0nodes);
      ArrayList<RNode> neighbors = root.getNeighbors();
      assignBioBricksOverhangsHelper(root, neighbors, root, stageRVectors);
    }

    // Determine which nodes impact which level to form the stageDirectionAssignHash
    for (RGraph graph : optimalGraphs) {
      RNode root = graph.getRootNode();
      ArrayList<String> rootDir = new ArrayList<String>();
      ArrayList<String> direction = root.getDirection();
      rootDir.addAll(direction);
      ArrayList<RNode> l0Nodes = _rootBasicNodeHash.get(root);

      // Determine which levels each basic node impacts
      for (int i = 0; i < l0Nodes.size(); i++) {

        // Determine direction of basic level 0 nodes
        RNode l0Node = l0Nodes.get(i);
        String l0Direction = rootDir.get(0);
        if (l0Node.getComposition().size() == 1) {
          ArrayList<String> l0Dir = new ArrayList<String>();
          l0Dir.add(l0Direction);
          l0Node.setDirection(l0Dir);
        }
        int size = l0Node.getDirection().size();
        rootDir.subList(0, size).clear();
      }
    }
  }
Ejemplo n.º 3
0
  /** Determine overhang scars * */
  private void assignScars(ArrayList<RGraph> optimalGraphs) {

    // Loop through each optimal graph and grab the root node to prime for the traversal
    for (RGraph graph : optimalGraphs) {

      RNode root = graph.getRootNode();
      ArrayList<RNode> children = root.getNeighbors();
      assignScarsHelper(root, children);
    }
  }