示例#1
0
  private void checkRange(Structure s, String range) {
    GroupIterator iter = new GroupIterator(s);
    Group g1 = iter.next();
    Group g2 = null;
    while (iter.hasNext()) {
      g2 = iter.next();
    }
    assertNotNull(g1);
    assertNotNull(g2);
    String chainId = g1.getChain().getChainID();
    String rangeTest =
        chainId + ":" + g1.getResidueNumber().toString() + "-" + g2.getResidueNumber().toString();

    assertEquals("The expected range and the detected range don;t match!", rangeTest, range);
  }
示例#2
0
  /**
   * Calculates ASA for all atoms and return them as a GroupAsa array (one element per residue in
   * structure) containing ASAs per residue and per atom. The sorting of Groups in returned array is
   * as specified by {@link org.biojava.bio.structure.ResidueNumber}
   *
   * @return
   */
  public GroupAsa[] getGroupAsas() {

    TreeMap<ResidueNumber, GroupAsa> asas = new TreeMap<ResidueNumber, GroupAsa>();

    double[] asasPerAtom = calculateAsas();

    for (int i = 0; i < atoms.length; i++) {
      Group g = atoms[i].getGroup();
      if (!asas.containsKey(g.getResidueNumber())) {
        GroupAsa groupAsa = new GroupAsa(g);
        groupAsa.addAtomAsaU(asasPerAtom[i]);
        asas.put(g.getResidueNumber(), groupAsa);
      } else {
        GroupAsa groupAsa = asas.get(g.getResidueNumber());
        groupAsa.addAtomAsaU(asasPerAtom[i]);
      }
    }

    return (GroupAsa[]) asas.values().toArray(new GroupAsa[asas.size()]);
  }
  public static void main(String[] args) {

    try {
      FileParsingParameters params = new FileParsingParameters();
      params.setParseSecStruc(true);

      AtomCache cache = new AtomCache();
      cache.setFileParsingParams(params);

      Structure s = cache.getStructure("4hhb");

      for (Chain c : s.getChains()) {
        for (Group g : c.getAtomGroups()) {

          if (g instanceof AminoAcid) {

            AminoAcid aa = (AminoAcid) g;

            Map<String, String> sec = aa.getSecStruc();

            System.out.println(
                c.getChainID()
                    + " "
                    + g.getResidueNumber()
                    + " "
                    + g.getPDBName()
                    + " "
                    + " "
                    + sec);
          }
        }
      }

    } catch (Exception e) {

      e.printStackTrace();
    }
  }