Example #1
0
  /**
   * Draw a complex graph to an image file in the requested format.
   *
   * @param baseFilePathNoExt the img base file name, no file extension
   * @param drawBlackAndWhite whether to draw in grayscale only
   * @param formats a list of img formats to write
   * @param cg the complex graph to draw
   * @param molInfoForChains info mapping chain IDs (like "A") to their macromolecule (MOL_ID in PDB
   *     file, e.g., "1"). Give an empty one if you dont know
   * @return a list of file names that were written to disk, (as a map of formats to file names)
   */
  public static HashMap<DrawTools.IMAGEFORMAT, String> drawComplexGraph(
      String baseFilePathNoExt,
      Boolean drawBlackAndWhite,
      DrawTools.IMAGEFORMAT[] formats,
      ComplexGraph cg,
      Map<String, String> molInfoForChains) {

    DrawResult drawRes =
        ComplexGraph.drawChainLevelComplexGraphG2D(drawBlackAndWhite, cg, molInfoForChains);

    // System.out.println("drawProteinGraph: Basefilepath is '" + baseFilePathNoExt + "'.");
    String svgFilePath = baseFilePathNoExt + ".svg";
    HashMap<DrawTools.IMAGEFORMAT, String> resultFilesByFormat =
        new HashMap<DrawTools.IMAGEFORMAT, String>();
    try {
      DrawTools.writeG2dToSVGFile(svgFilePath, drawRes);
      resultFilesByFormat.put(DrawTools.IMAGEFORMAT.SVG, svgFilePath);
      resultFilesByFormat.putAll(
          DrawTools.convertSVGFileToOtherFormats(svgFilePath, baseFilePathNoExt, drawRes, formats));
    } catch (IOException ex) {
      DP.getInstance().e("Could not write protein graph file : '" + ex.getMessage() + "'.");
    }

    if (!Settings.getBoolean("plcc_B_silent")) {
      StringBuilder sb = new StringBuilder();
      sb.append("      Output complex graph files: ");
      for (DrawTools.IMAGEFORMAT format : resultFilesByFormat.keySet()) {
        String ffile = new File(resultFilesByFormat.get(format)).getName();
        sb.append("(").append(format.toString()).append(" => ").append(ffile).append(") ");
      }
      System.out.println(sb.toString());
    }
    return resultFilesByFormat;
  }
Example #2
0
 public static DP getInstance() {
   if (instance == null) {
     instance = new DP();
     instance.init();
   }
   return instance;
 }
Example #3
0
  public void writeSSEComplexContactInfoToDB(String pdbid) {

    // DBManager.writeSSEComplexContactToDB()
    String chainA;
    String chainB;

    Integer numHelixHelixInteractions;
    Integer numHelixStrandInteractions;
    Integer numHelixLoopInteractions;
    Integer numSSInteractions;
    Integer numStrandLoopInteractions;
    Integer numLoopLoopInteractions;
    Integer numAllInteractions;
    Integer numDisulfides;

    int countInsert = 0;
    int countFail = 0;
    Boolean retVal = false;
    for (Map.Entry<List<Integer>, Integer> pair : this.numSSEContacts.entrySet()) {

      List<Integer> curSSEs = (List<Integer>) pair.getKey();
      chainA = this.numSSEContactChainNames.get(curSSEs).get(0);
      chainB = this.numSSEContactChainNames.get(curSSEs).get(1);

      Integer sse1_dssp_start = (Integer) curSSEs.get(0);
      Integer sse2_dssp_start = (Integer) curSSEs.get(1);
      Integer contactCount = (Integer) pair.getValue();

      Boolean res = false;

      // this action could result in an error due to the definition of a PTGL SSE
      // e.g. the SSE is too short and is merged to another SSE or not defined in the DB
      try {
        res =
            DBManager.writeSSEComplexContactToDB(
                pdbid, chainA, chainB, sse1_dssp_start, sse2_dssp_start, contactCount);
        // it.remove(); // avoids a ConcurrentModificationException
        if (res) {
          countInsert++;
          retVal = true;
        } else {
          countFail++;
          retVal = false;
        }
      } catch (SQLException ex) {
        DP.getInstance()
            .e(
                "ComplexGraph",
                "writeSSEComplexContactInfoToDB: SQL exception: '" + ex.getMessage() + "'.");
        Logger.getLogger(ComplexGraph.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
    if (!Settings.getBoolean("plcc_B_silent")) {
      System.out.println(
          "    SSE Contacts written to DB: "
              + countInsert
              + " inserted, "
              + countFail
              + " skipped (contact involved coils).");
    }
  }