示例#1
0
  public static void main(String[] args) {

    String file = "/Users/ap3/tmp/4hhb.ce";

    try {
      BufferedReader in = new BufferedReader(new FileReader(file));
      StringBuffer xml = new StringBuffer();
      String str;
      while ((str = in.readLine()) != null) {
        xml.append(str);
      }
      in.close();

      AFPChain[] afps = AFPChainXMLParser.parseMultiXML(xml.toString());
      AFPChain afpChain = afps[0];

      UserConfiguration config = WebStartMain.getWebStartConfig();
      AtomCache cache = new AtomCache(config.getPdbFilePath(), config.isSplit());

      Atom[] ca1 = cache.getAtoms(afpChain.getName1());
      Atom[] ca2 = cache.getAtoms(afpChain.getName2());

      AFPChainXMLParser.rebuildAFPChain(afpChain, ca1, ca2);

      // StructureAlignment algorithm =
      // StructureAlignmentFactory.getAlgorithm(afpChain.getAlgorithmName());
      StructureAlignmentJmol jmol = StructureAlignmentDisplay.display(afpChain, ca1, ca2);

      DisplayAFP.showAlignmentImage(afpChain, ca1, ca2, jmol);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void loadStructureFromCache() {
    String pdbId = "4hhb";
    String chainName = "4hhb.A";
    String entityName = "4hhb:0";

    // we can set a flag if the file should be cached in memory
    // this will enhance IO massively if the same files have to be accessed over and over again.
    // since this is a soft cache, no danger of memory leak
    // this is actually not necessary to provide, since the default is "true" if the AtomCache is
    // being used.
    System.setProperty(InputStreamProvider.CACHE_PROPERTY, "true");

    AtomCache cache = new AtomCache();

    try {
      System.out.println("======================");
      Structure s = cache.getStructure(pdbId);

      System.out.println("Full Structure:" + s);

      Atom[] ca = cache.getAtoms(chainName);
      System.out.println("got " + ca.length + " CA atoms");

      Structure firstEntity = cache.getStructure(entityName);
      System.out.println("First entity: " + firstEntity);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }