Exemplo n.º 1
0
  @Override
  public SortedSet<String> getDomainNames(String name) throws IOException, StructureException {

    if (name.length() < 4)
      throw new IllegalArgumentException("Can't interpret IDs that are shorter than 4 residues!");

    if (serializedCache != null) {
      if (serializedCache.containsKey(name)) {
        return serializedCache.get(name);
      }
    }

    StructureName n = new StructureName(name);

    List<ScopDomain> scopDomains = scop.getDomainsForPDB(n.getPdbId());

    String chainID = n.getChainId();

    if (scopDomains == null || scopDomains.size() == 0) {
      SortedSet<String> data = getPDPDomains(n);
      cache(name, data);
      return data;
    } else {
      SortedSet<String> r = new TreeSet<String>();
      for (ScopDomain d : scopDomains) {
        StructureName s = new StructureName(d.getScopId());

        if (chainID == null) {
          r.add(s.getIdentifier());

        } else if (s.getChainId().equalsIgnoreCase(n.getChainId())) {
          // SCOP IDS are case insensitive...
          r.add(s.getIdentifier());
        }
      }
      cache(name, r);
      return r;
    }
  }
Exemplo n.º 2
0
  /**
   * Returns the representation of a {@link ScopDomain} as a BioJava {@link Structure} object.
   *
   * @param domain a SCOP domain
   * @param scopDatabase A {@link ScopDatabase} to use
   * @param strictLigandHandling If set to false, hetero-atoms are included if and only if they
   *     belong to a chain to which the SCOP domain belongs; if set to true, hetero-atoms are
   *     included if and only if they are strictly within the definition (residue numbers) of the
   *     SCOP domain
   * @return a Structure object
   * @throws IOException
   * @throws StructureException
   */
  public Structure getStructureForDomain(
      ScopDomain domain, ScopDatabase scopDatabase, boolean strictLigandHandling)
      throws IOException, StructureException {

    String pdbId = domain.getPdbId();
    Structure fullStructure = getStructureForPdbId(pdbId);
    Structure structure = domain.reduce(fullStructure);

    // TODO It would be better to move all of this into the reduce method,
    // but that would require ligand handling properties in StructureIdentifiers

    // because ligands sometimes occur after TER records in PDB files, we may need to add some
    // ligands back in
    // specifically, we add a ligand if and only if it occurs within the domain
    AtomPositionMap map = null;
    List<ResidueRangeAndLength> rrs = null;
    if (strictLigandHandling) {
      map =
          new AtomPositionMap(
              StructureTools.getAllAtomArray(fullStructure), AtomPositionMap.ANYTHING_MATCHER);
      rrs = ResidueRangeAndLength.parseMultiple(domain.getRanges(), map);
    }
    for (Chain chain : fullStructure.getChains()) {
      if (!structure.hasChain(chain.getChainID())) {
        continue; // we can't do anything with a chain our domain
      }
      // doesn't contain
      Chain newChain = structure.getChainByPDB(chain.getChainID());
      List<Group> ligands = StructureTools.filterLigands(chain.getAtomGroups());
      for (Group group : ligands) {
        boolean shouldContain = true;
        if (strictLigandHandling) {
          shouldContain = false; // whether the ligand occurs within the domain
          for (ResidueRange rr : rrs) {
            if (rr.contains(group.getResidueNumber(), map)) {
              shouldContain = true;
            }
          }
        }
        boolean alreadyContains =
            newChain.getAtomGroups().contains(group); // we don't want to add duplicate
        // ligands
        if (shouldContain && !alreadyContains) {
          newChain.addGroup(group);
        }
      }
    }

    // build a more meaningful description for the new structure
    StringBuilder header = new StringBuilder();
    header.append(domain.getClassificationId());
    if (scopDatabase != null) {
      int sf = domain.getSuperfamilyId();
      ScopDescription description = scopDatabase.getScopDescriptionBySunid(sf);
      if (description != null) {
        header.append(" | ");
        header.append(description.getDescription());
      }
    }
    structure.getPDBHeader().setDescription(header.toString());

    return structure;
  }