Exemplo n.º 1
0
  /**
   * Gets a list of atoms that are part of a ChemComp, with bonds already formed for you.
   *
   * @param name the name of the ChemComp, like "ALA" or "HEM".
   * @return a list of PDBAtoms that make up a ChemComp
   */
  public static List<PDBAtom> getGraph(String name) {
    ChemComp cc = ChemCompGroupFactory.getChemComp(name);

    List<PDBAtom> atoms = new ArrayList<PDBAtom>();
    List<String> atomNames = new ArrayList<String>();

    for (ChemCompAtom atom : cc.getAtoms()) {
      Element element = getElement(atom);

      if (element.isHeavyAtom()) {
        atoms.add(new PDBAtom(element, atom.getAtom_id()));
        atomNames.add(atom.getAtom_id());
      }
    }

    for (ChemCompBond bond : cc.getBonds()) {
      String atomName1 = bond.getAtom_id_1();
      String atomName2 = bond.getAtom_id_2();

      int index1 = atomNames.indexOf(atomName1);
      int index2 = atomNames.indexOf(atomName2);

      if (index1 != -1 && index2 != -1) {
        Atom atom1 = atoms.get(index1);
        Atom atom2 = atoms.get(index2);

        new Bond(atom1, atom2, bond.getNumericalBondOrder()).addSelfToAtoms();
      }
    }

    return atoms;
  }
  /** Converts biojava chemical components to ResidueInfo classes */
  public ResidueInfo getResidue(String monId) {

    BioJavaResidueInfo ri = (BioJavaResidueInfo) cache.get(monId);
    if (ri != null) return ri;

    ChemComp cc = ChemCompGroupFactory.getChemComp(monId);

    ri = new BioJavaResidueInfo();
    ri.setChemComp(cc);

    return ri;
  }