예제 #1
0
  /**
   * create a registared chemical structure node
   *
   * @param monomerID
   * @return chemcial modifier node graph
   */
  @Deprecated
  public static Graph2D createChemNode(String monomerID)
      throws MonomerException, IOException, JDOMException {

    MonomerFactory monomerFactory = MonomerFactory.getInstance();
    Map<String, Map<String, Monomer>> monomerDB = monomerFactory.getMonomerDB();

    MonomerInfo monomerKeys = new MonomerInfo(Monomer.CHEMICAL_POLYMER_TYPE, monomerID);
    Monomer monomer = monomerDB.get(monomerKeys.getPolymerType()).get(monomerKeys.getMonomerID());
    if (monomer == null) {
      throw new MonomerException("Invalid chemical ID " + monomerID);
    }

    Graph2D graph = new Graph2D();

    MonomerNodeRealizer nodeRealizer = new MonomerNodeRealizer(MonomerNodeRealizer.HEXAGON);
    nodeRealizer.setSize(size, size);
    nodeRealizer.setLabelText(monomerID);
    nodeRealizer.getLabel().setFontSize(calculateFontSize(monomerID));

    nodeRealizer.setFillColor(new Color(200, 0, 255)); // was Color.magenta;

    Node node = graph.createNode(nodeRealizer);

    NodeMap nodeMap = graph.createNodeMap();
    nodeMap.set(node, monomerKeys);

    graph.addDataProvider(NodeMapKeys.MONOMER_REF, nodeMap);

    return graph;
  }
예제 #2
0
  /**
   * create an (modified) amino acid node
   *
   * @param monomerID
   * @return amino acid node graph
   */
  @Deprecated
  public static Graph2D createAminoAcidNode(String monomerID)
      throws MonomerException, IOException, JDOMException {

    MonomerFactory monomerFactory = MonomerFactory.getInstance();
    Map<String, Map<String, Monomer>> monomerDB = monomerFactory.getMonomerDB();

    Graph2D graph = new Graph2D();

    MonomerInfo monomerKeys = new MonomerInfo(Monomer.PEPTIDE_POLYMER_TYPE, monomerID);
    Monomer monomer = monomerDB.get(monomerKeys.getPolymerType()).get(monomerKeys.getMonomerID());
    if (monomer == null) {
      throw new MonomerException("Invalid HELM notation " + monomerID);
    }

    MonomerNodeRealizer nodeRealizer = new MonomerNodeRealizer(MonomerNodeRealizer.DIAMOND);
    nodeRealizer.setSize(size, size);
    nodeRealizer.setLabelText(monomerID);
    nodeRealizer.setFillColor(ColorMap.getAminoAcidColor(monomer.getNaturalAnalog()));
    nodeRealizer.getLabel().setFontSize(calculateFontSize(monomerID));

    Node node = graph.createNode(nodeRealizer);
    NodeMap nodeMap = graph.createNodeMap();
    nodeMap.set(node, monomerKeys);

    graph.addDataProvider(NodeMapKeys.MONOMER_REF, nodeMap);

    return graph;
  }
예제 #3
0
  /**
   * Build a (modified) nucleic acid base node, this node should already registared in the database
   *
   * @param monomerID : the name of the base node
   * @return a graph contains a single (base) node
   */
  @Deprecated
  public static Graph2D createNucleicAcidBaseNode(String monomerID)
      throws MonomerException, IOException, JDOMException {

    MonomerFactory monomerFactory = MonomerFactory.getInstance();
    Map<String, Map<String, Monomer>> monomerDB = monomerFactory.getMonomerDB();

    Graph2D graph = new Graph2D();
    MonomerNodeRealizer baseNodeRealizer = new MonomerNodeRealizer(MonomerNodeRealizer.DIAMOND);
    graph.setDefaultNodeRealizer(baseNodeRealizer);

    baseNodeRealizer.setSize(size, size);

    MonomerInfo monomerKeys = new MonomerInfo(Monomer.NUCLIEC_ACID_POLYMER_TYPE, monomerID);
    Monomer baseMonomer =
        monomerDB.get(monomerKeys.getPolymerType()).get(monomerKeys.getMonomerID());

    if (baseMonomer == null) {
      throw new MonomerException("Invalid base monomer " + monomerID);
    }

    Node baseNode = graph.createNode();

    Color fillColor = ColorMap.getNucleotidesColor(baseMonomer.getNaturalAnalog());
    baseNodeRealizer.setFillColor(fillColor);

    Color textColor = Color.BLACK;
    // was: Color textColor = new Color(23 - fillColor.getRGB());
    // but we want identical view at left panel and at sequence panel, so
    // textColor is always set to black.

    baseNodeRealizer.setLabelText(monomerID);
    baseNodeRealizer.getLabel().setTextColor(textColor);
    baseNodeRealizer.getLabel().setFontSize(calculateFontSize(monomerID));

    graph.setRealizer(baseNode, baseNodeRealizer);

    NodeMap nodePropertiesNodeMap = graph.createNodeMap();
    graph.addDataProvider(NodeMapKeys.MONOMER_REF, nodePropertiesNodeMap);
    nodePropertiesNodeMap.set(baseNode, monomerKeys);

    return graph;
  }
예제 #4
0
  /**
   * create a (modified) nucleic acid backbone node. this monomer should already registared in the
   * monomer database
   *
   * @param monomerID
   * @return A graph contains a nucleic acid backbone node
   */
  @Deprecated
  public static Graph2D createNucleicAcidBackboneNode(String monomerID, String naturalAnalog)
      throws MonomerException, IOException, JDOMException {

    final String url = MacromoleculeEditor.class.getResource("resource/").getFile();

    MonomerFactory monomerFactory = MonomerFactory.getInstance();
    Map<String, Map<String, Monomer>> monomerDB = monomerFactory.getMonomerDB();

    Graph2D graph = new Graph2D();
    MonomerNodeRealizer backboneNodeRealizer = null;
    if (naturalAnalog.equalsIgnoreCase(Monomer.ID_R)) {
      backboneNodeRealizer = new MonomerNodeRealizer(MonomerNodeRealizer.ROUND_RECT);
    } else if (naturalAnalog.equalsIgnoreCase(Monomer.ID_P)) {
      backboneNodeRealizer = new MonomerNodeRealizer(MonomerNodeRealizer.ELLIPSE);
    } else {
      backboneNodeRealizer = new MonomerNodeRealizer(MonomerNodeRealizer.OCTAGON);
    }

    backboneNodeRealizer.setFillColor(ColorMap.getNucleotidesColor(naturalAnalog));
    backboneNodeRealizer.setSize(size, size);

    graph.setDefaultNodeRealizer(backboneNodeRealizer);

    MonomerInfo monomerKeys = new MonomerInfo(Monomer.NUCLIEC_ACID_POLYMER_TYPE, monomerID);
    Monomer monomer = monomerDB.get(monomerKeys.getPolymerType()).get(monomerKeys.getMonomerID());

    if (monomer == null) {
      throw new MonomerException("Invalid backbone monomer ID " + monomerID);
    }
    Node baseNode = graph.createNode();
    backboneNodeRealizer.setLabelText(monomerID);
    backboneNodeRealizer.setFillColor(ColorMap.getNucleotidesColor(monomer.getNaturalAnalog()));
    graph.setRealizer(baseNode, backboneNodeRealizer);

    NodeMap nodePropertiesNodeMap = graph.createNodeMap();
    graph.addDataProvider(NodeMapKeys.MONOMER_REF, nodePropertiesNodeMap);
    nodePropertiesNodeMap.set(baseNode, monomerKeys);
    return graph;
  }