// from biojava structure, convert to own user model
  public void createUserModel(Structure struc) {
    // read default MMFFtypes for atoms

    if (modelList == null) modelList = new ArrayList<Model>();
    Model model = null;
    for (int i = 0; i < struc.nrModels(); i++) {
      // for each model, create and add to model list
      model = new Model();
      model.setModelName("Model" + (i + 1));
      model.setMolecule(struc.getModel(i)); // set the model
      modelList.add(model);
    }
  }
  public void loadStructureIO() {
    try {
      Structure s1 = StructureIO.getStructure("1gav");
      System.out.println(s1.getPDBCode() + " asym unit has nr atoms:");
      System.out.println(StructureTools.getNrAtoms(s1));

      Structure s2 = StructureIO.getBiologicalAssembly("1gav");
      System.out.println(s2.getPDBCode() + " biological assembly has nr atoms:");
      System.out.println(StructureTools.getNrAtoms(s2));

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Identify a set of modifications in a structure.
   *
   * @param structure query {@link Structure}.
   * @param potentialModifications query {@link ProteinModification}s.
   */
  public void identify(
      final Structure structure, final Set<ProteinModification> potentialModifications) {
    if (structure == null) {
      throw new IllegalArgumentException("Null structure.");
    }

    identify(structure.getChains(), potentialModifications);
  }
  public void basicLoad() {
    try {

      PDBFileReader reader = new PDBFileReader();

      // the path to the local PDB installation
      reader.setPath("/tmp");

      // are all files in one directory, or are the files split,
      // as on the PDB ftp servers?
      reader.setPdbDirectorySplit(true);

      // should a missing PDB id be fetched automatically from the FTP servers?
      reader.setAutoFetch(true);

      // configure the parameters of file parsing

      FileParsingParameters params = new FileParsingParameters();

      // should the ATOM and SEQRES residues be aligned when creating the internal data model?
      params.setAlignSeqRes(true);

      // should secondary structure get parsed from the file
      params.setParseSecStruc(false);

      reader.setFileParsingParameters(params);

      Structure structure = reader.getStructureById("4hhb");

      System.out.println(structure);

      Chain c = structure.getChainByPDB("C");

      System.out.print(c);

      System.out.println(c.getHeader());

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  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();
    }
  }
Exemple #6
0
  private void runSCOPTests() {

    ScopDatabase scop = ScopFactory.getSCOP();

    List<ScopDomain> domains = scop.getDomainsForPDB("4HHB");

    assertTrue(domains.size() == 4);

    // test case sensitivity;
    List<ScopDomain> domains2 = scop.getDomainsForPDB("4hhb");
    assertTrue(domains2.size() == domains.size());

    // System.out.println(domains);

    String scop1m02 =
        "d1m02a_	1m02	A:	k.36.1.1	74353	cl=58788,cf=75796,sf=75797,fa=75798,dm=75799,sp=75800,px=74353";

    List<ScopDomain> domains1m02 = scop.getDomainsForPDB("1m02");
    assertTrue(domains1m02.size() == 1);
    ScopDomain d1 = domains1m02.get(0);

    assertNotNull(d1);

    assertEquals(
        "The toString() methods for ScopDomains don't match the scop display",
        d1.toString(),
        scop1m02);

    List<ScopDomain> domains1cdg = scop.getDomainsForPDB("1CDG");
    assertTrue(domains1cdg.size() == 4);
    ScopDomain d2 = domains1cdg.get(0);
    AtomCache cache = new AtomCache();
    try {
      Structure s = cache.getStructureForDomain(d2);

      // checkRange(s,"A:496-581");
      // now with ligands!
      checkRange(s, "A:496-692");

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

    // check a domain with multiple ranges
    List<ScopDomain> domains1xzp = scop.getDomainsForPDB("1xzp");
    assertTrue(domains1xzp.size() == 4);

    try {
      Structure s = cache.getStructureForDomain(domains1xzp.get(0));
      Chain a = s.getChainByPDB("A");

      // now with ligands...
      assertEquals(a.getAtomGroups().size(), 176);

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

    // check insertion codes

    List<ScopDomain> domains2bq6 = scop.getDomainsForPDB("2bq6");
    assertTrue(domains2bq6.size() == 2);
    ScopDomain target = scop.getDomainByScopID("d2bq6a1");

    assertNotNull(target);
    try {
      Structure s = cache.getStructureForDomain(target);

      Chain a = s.getChainByPDB("A");
      assertEquals(a.getAtomGroups().size(), 52);
      checkRange(s, "A:1A-49");

    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
  /**
   * Identify a set of modifications in a a list of chains.
   *
   * @param chains query {@link Chain}s.
   * @param potentialModifications query {@link ProteinModification}s.
   */
  public void identify(
      final List<Chain> chains, final Set<ProteinModification> potentialModifications) {

    if (chains == null) {
      throw new IllegalArgumentException("Null structure.");
    }

    if (potentialModifications == null) {
      throw new IllegalArgumentException("Null potentialModifications.");
    }

    reset();

    if (potentialModifications.isEmpty()) {
      return;
    }

    Map<String, Chain> mapChainIdChain = new HashMap<String, Chain>(chains.size());
    residues = new ArrayList<Group>();
    List<Group> ligands = new ArrayList<Group>();
    Map<Component, Set<Group>> mapCompGroups = new HashMap<Component, Set<Group>>();

    for (Chain chain : chains) {
      mapChainIdChain.put(chain.getChainID(), chain);

      List<Group> ress = StructureUtil.getAminoAcids(chain);

      // List<Group> ligs = chain.getAtomLigands();
      List<Group> ligs = StructureTools.filterLigands(chain.getAtomGroups());
      residues.addAll(ress);
      residues.removeAll(ligs);
      ligands.addAll(ligs);
      addModificationGroups(potentialModifications, ress, ligs, mapCompGroups);
    }

    if (residues.isEmpty()) {
      String pdbId = "?";
      if (chains.size() > 0) {
        Structure struc = chains.get(0).getParent();
        if (struc != null) pdbId = struc.getPDBCode();
      }
      System.err.println(
          "WARNING: no amino acids found for "
              + pdbId
              + ". Either you did not parse the PDB file with alignSEQRES records, or this record does not contain any amino acids.");
    }
    List<ModifiedCompound> modComps = new ArrayList<ModifiedCompound>();

    for (ProteinModification mod : potentialModifications) {
      ModificationCondition condition = mod.getCondition();
      List<Component> components = condition.getComponents();
      if (!mapCompGroups.keySet().containsAll(components)) {
        // not all components exist for this mod.
        continue;
      }

      int sizeComps = components.size();
      if (sizeComps == 1) {

        processCrosslink1(mapCompGroups, modComps, mod, components);

      } else {

        processMultiCrosslink(mapCompGroups, modComps, mod, condition);
      }
    }

    if (recordAdditionalAttachments) {
      // identify additional groups that are not directly attached to amino acids.
      for (ModifiedCompound mc : modComps) {
        identifyAdditionalAttachments(mc, ligands, mapChainIdChain);
      }
    }

    mergeModComps(modComps);

    identifiedModifiedCompounds.addAll(modComps);

    // record unidentifiable linkage
    if (recordUnidentifiableModifiedCompounds) {
      recordUnidentifiableAtomLinkages(modComps, ligands);
      recordUnidentifiableModifiedResidues(modComps);
    }
  }