Ejemplo n.º 1
0
  private void checkAddHBond(int i, int j) {
    SecStrucGroup one = groups[i];
    SecStrucGroup two = groups[j];
    if (!two.hasAtom("H")) {
      System.err.println("two has no H " + j);
      return;
    }

    if (one.getPDBName().equals("PRO")) {
      if (debug) System.out.println("     ignore: PRO " + one.getPDBCode());

      return;
    }

    double energy = 0;
    try {
      energy = calculateHBondEnergy(one, two);
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }
    // System.out.println(" " + energy);

    trackHBondEnergy(i, j, energy);
  }
Ejemplo n.º 2
0
  /**
   * calculate the coordinates for the H atoms. They are usually missing in the PDB files as only
   * few experimental methods allow to resolve their location
   */
  private void calculateHAtoms() throws StructureException {

    for (int i = 0; i < groups.length - 1; i++) {

      SecStrucGroup a = groups[i];
      SecStrucGroup b = groups[i + 1];

      if (!b.hasAtom("H")) {

        // System.out.println(cur);
        // calculate the coordinate for the H atom
        // Atom H = calc_H(a.getC(), b.getN(), b.getCA());

        // alternative:
        Atom H = calcSimple_H(a.getC(), a.getO(), b.getN());

        b.setH(H);

        /*System.out.println("added H for " + i + " " + H);
        for ( int aa = 0 ; aa < b.size() ; aa++){
           Atom at = b.getAtom(aa);
           System.out.println(aa + " " + at.getFullName() + " "+ Calc.getDistance(at,H));
        }*/

      }
    }
  }
Ejemplo n.º 3
0
  /** detect helical turn patterns */
  private void calculateTurns() {

    int l = groups.length;
    for (int i = 0; i < l; i++) {

      for (int turn = 3; turn <= 5; turn++) {
        if (i + turn >= l) continue;

        if (isBonded(i + turn, i)) {
          // System.out.println("is bondend " + (i+turn) + i );
          for (int j = i; j < i + turn + 1; j++) {
            // System.out.println("turn at i:" + i + " j:" + j + " turn" + turn);
            SecStrucGroup group = groups[j];
            SecStrucState state = (SecStrucState) group.getProperty("secstruc");
            boolean[] turns = state.getTurn();
            turns[turn - 3] = true;
          }
        }
      }
    }
  }
Ejemplo n.º 4
0
  /** calculate the HBonds between different groups ... see Creighton page 147 f */
  private void calculateHBonds() throws StructureException {
    System.out.println("groups length: " + groups.length);

    // skip the first residue , unable to calc H for it ...
    for (int i = 1; i < groups.length; i++) {

      SecStrucGroup one = groups[i];

      if (!one.hasAtom("H")) {
        System.out.println(" no H at " + i);
        continue;
      }

      for (int j = i + 1; j < groups.length; j++) {

        SecStrucGroup two = groups[j];

        // check if distance is  too large.
        // if too big - for sure no HBonds ...
        double dist = Calc.getDistance(one.getCA(), two.getCA());

        // speed up...
        if (dist >= CA_MIN_DIST) continue;
        // System.out.println("calc " + i + " " + j + " "+  dist);

        checkAddHBond(i, j);

        // "backwards" hbonds are not allowed
        if (j != (i + 1)) {

          checkAddHBond(j, i);
        }
        // System.out.println(" ");
      }
    }
  }
Ejemplo n.º 5
0
  /**
   * calculate HBond energy of two groups in cal/mol ... see Creighton page 147 f
   *
   * <p>Jeffrey, George A., An introduction to hydrogen bonding, Oxford University Press, 1997.
   * categorizes hbonds with donor-acceptor distances of 2.2-2.5 &aring; as "strong, mostly
   * covalent", 2.5-3.2 &aring; as "moderate, mostly electrostatic", 3.2-4.0 &aring; as "weak,
   * electrostatic". Energies are given as 40-14, 15-4, and <4 kcal/mol respectively.
   */
  public double calculateHBondEnergy(SecStrucGroup one, SecStrucGroup two)
      throws StructureException {

    // System.out.println("calcHBondEnergy" + one + "|" + two);

    Atom N = one.getN();
    Atom H = one.getH();

    Atom O = two.getO();
    Atom C = two.getC();

    double dno = Calc.getDistance(O, N);
    double dhc = Calc.getDistance(C, H);
    double dho = Calc.getDistance(O, H);
    double dnc = Calc.getDistance(C, N);

    if (debug) {

      System.out.println(
          "     cccc: "
              + one.getPDBCode()
              + " "
              + one.getPDBName()
              + " "
              + two.getPDBCode()
              + " "
              + two.getPDBName()
              + String.format(
                  " O ("
                      + O.getPDBserial()
                      + ")..N ("
                      + N.getPDBserial()
                      + "):%4.1f  |  ho:%4.1f - hc:%4.1f + nc:%4.1f - no:%4.1f ",
                  dno,
                  dho,
                  dhc,
                  dnc,
                  dno));
    }
    // System.out.println( cn > ch && oh < 3.0f);

    double contact = MINDIST;

    //		 there seems to be a contact!
    if ((dno < contact) || (dhc < contact) || (dnc < contact) || (dno < contact)) {
      // System.out.println("!!! contact " + one + " " + two);
      return HBONDLOWENERGY;
    }

    double e1 = Q / dho - Q / dhc;
    double e2 = Q / dnc - Q / dno;

    double energy = e1 + e2;

    if (debug)
      System.out.println(
          String.format(
              "      N (%d) O(%d): %4.1f : %4.2f ",
              N.getPDBserial(), O.getPDBserial(), (float) dno, energy));

    // bond too weak
    if (energy > HBONDHIGHENERGY) return 0;

    // test to avoid bond too strong
    if (energy > HBONDLOWENERGY) return energy;

    return HBONDLOWENERGY;
  }
Ejemplo n.º 6
0
  private static SecStrucGroup[] initGroupArray(Structure s) {
    List<SecStrucGroup> groupList = new ArrayList<SecStrucGroup>();
    // GroupIterator iter = new GroupIterator(s);
    for (Chain c : s.getChains()) {

      for (Group g : c.getAtomGroups()) {
        // System.out.println(g);
        //			 we can also calc secstruc if hetatom is a modified amino acid.
        if (g.hasAminoAtoms()) {

          SecStrucGroup sg = new SecStrucGroup();
          sg.setPDBCode(g.getPDBCode());
          sg.setPDBFlag(true);
          try {
            sg.setPDBName(g.getPDBName());
          } catch (PDBParseException e) {
            e.printStackTrace();
          }
          sg.setParent(g.getChain());

          try {

            sg.setN((Atom) g.getAtomByPDBname(" N  ").clone());
            sg.setCA((Atom) g.getAtomByPDBname(" CA ").clone());
            sg.setC((Atom) g.getAtomByPDBname(" C  ").clone());
            sg.setO((Atom) g.getAtomByPDBname(" O  ").clone());
            sg.setOriginal(g);
            // create H in calc_H

          } catch (StructureException e) {
            e.printStackTrace();
            // one of these atoms is not found!
            continue;
          }

          SecStrucState state = new SecStrucState();
          Map m = sg.getProperties();
          if (m == null) {
            m = new HashMap();
            sg.setProperties(m);
          }

          m.put("secstruc", state);

          groupList.add(sg);
        } else {
          // System.out.println("not an amino group");
        }
      }
    }

    return (SecStrucGroup[]) groupList.toArray(new SecStrucGroup[groupList.size()]);
  }