Exemplo n.º 1
0
  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();
    }
  }
Exemplo n.º 2
0
  private static char getOneLetter(Group g) {

    try {
      Character c = StructureTools.get1LetterCode(g.getPDBName());
      return c;
    } catch (Exception e) {
      return 'X';
    }
  }
Exemplo n.º 3
0
  /**
   * Constructs a new AsaCalculator. Subsequently call {@link #calculateAsas()} or {@link
   * #getGroupAsas()} to calculate the ASAs Only non-Hydrogen atoms are considered in the
   * calculation.
   *
   * @param structure
   * @param probe
   * @param nSpherePoints
   * @param nThreads
   * @param hetAtoms if true HET residues are considered, if false they aren't, equivalent to
   *     NACCESS' -h option
   * @see StructureTools.getAllNonHAtomArray
   */
  public AsaCalculator(
      Structure structure, double probe, int nSpherePoints, int nThreads, boolean hetAtoms) {
    this.atoms = StructureTools.getAllNonHAtomArray(structure, hetAtoms);
    this.probe = probe;
    this.nThreads = nThreads;

    // initialising the radii by looking them up through AtomRadii
    radii = new double[atoms.length];
    for (int i = 0; i < atoms.length; i++) {
      radii[i] = getRadius(atoms[i]);
    }

    // initialising the sphere points to sample
    spherePoints = generateSpherePoints(nSpherePoints);

    cons = 4.0 * Math.PI / (double) nSpherePoints;
  }
Exemplo n.º 4
0
  public void run() {

    AtomCache cache = new AtomCache(config);

    StructureAlignment algorithm = null;
    if (parent != null) algorithm = parent.getStructureAlignment();
    else {
      algorithm = customAlgorithm;
    }
    String serverLocation = FarmJobParameters.DEFAULT_SERVER_URL;
    if (representatives == null) {
      SortedSet<String> repre = JFatCatClient.getRepresentatives(serverLocation, 40);
      System.out.println("got  " + repre.size() + " representatives for comparison");
      representatives = repre;
    }

    String header = "# algorithm:" + algorithm.getAlgorithmName();

    String legend =
        "# name1\tname2\tscore\tprobability\trmsd\tlen1\tlen2\tcov1\tcov2\t%ID\tDescription\t ";
    if (algorithm.getAlgorithmName().equalsIgnoreCase(CeMain.algorithmName)
        || algorithm.getAlgorithmName().equalsIgnoreCase(CeSideChainMain.algorithmName)) {
      legend = "# name1\tname2\tscore\tz-score\trmsd\tlen1\tlen2\tcov1\tcov2\t%ID\tDescription\t ";
    }

    File outFileF = new File(outFile);
    if (!outFileF.isDirectory()) {
      System.err.println(
          outFileF.getAbsolutePath()
              + " is not a directory, can't create result files in there... ");
      interrupt();
      cleanup();
    }

    if (name1 == null) name1 = "CUSTOM";

    SynchronizedOutFile out;

    resultList = new File(outFileF, "results_" + name1 + ".out");

    try {

      out = new SynchronizedOutFile(resultList);

      out.write(header);
      out.write(AFPChain.newline);
      out.write(legend);
      out.write(AFPChain.newline);

      if (name1.equals("CUSTOM")) {

        String config1 = "#param:file1=" + parent.getDBSearch().getPDBUploadPanel().getFilePath1();
        out.write(config1);
        out.write(AFPChain.newline);

        String config2 = "#param:chain1=" + parent.getDBSearch().getPDBUploadPanel().getChain1();
        out.write(config2);
        out.write(AFPChain.newline);
      }

      if (algorithm.getAlgorithmName().startsWith("jCE")) {
        ConfigStrucAligParams params = algorithm.getParameters();
        if (params instanceof CeParameters) {
          CeParameters ceParams = (CeParameters) params;
          if (ceParams.getScoringStrategy() != CeParameters.DEFAULT_SCORING_STRATEGY) {
            String scoring = "#param:scoring=" + ceParams.getScoringStrategy();
            out.write(scoring);
            out.write(AFPChain.newline);
          }
        }
      }

    } catch (Exception e) {
      System.err.println("Error while loading representative structure " + name1);
      e.printStackTrace();
      interrupt();
      cleanup();
      return;
    }

    DomainProvider domainProvider = DomainProviderFactory.getDomainProvider();

    ConcurrencyTools.setThreadPoolSize(nrCPUs);

    Atom[] ca1 = StructureTools.getAtomCAArray(structure1);

    int nrJobs = 0;
    for (String repre : representatives) {

      if (domainSplit) {
        SortedSet<String> domainNames = domainProvider.getDomainNames(repre);
        // System.out.println(repre +" got domains: " +domainNames);
        if (domainNames == null || domainNames.size() == 0) {
          // no domains found, use whole chain.
          submit(name1, repre, ca1, algorithm, outFileF, out, cache);
          nrJobs++;
          continue;
        }
        // System.out.println("got " + domainNames.size() + " for " + repre);
        for (String domain : domainNames) {
          submit(name1, domain, ca1, algorithm, outFileF, out, cache);
          nrJobs++;
        }
      } else {
        submit(name1, repre, ca1, algorithm, outFileF, out, cache);
        nrJobs++;
      }
    }

    ThreadPoolExecutor pool = ConcurrencyTools.getThreadPool();
    System.out.println(pool.getPoolSize());

    long startTime = System.currentTimeMillis();

    try {
      while (pool.getCompletedTaskCount() < nrJobs - 1) {
        // long now = System.currentTimeMillis();
        // System.out.println( pool.getCompletedTaskCount() + " " + (now-startTime)/1000 + " " +
        // pool.getPoolSize() + " " + pool.getActiveCount()  + " " + pool.getTaskCount()  );
        //				if ((now-startTime)/1000 > 60) {
        //
        //					interrupt();
        //					System.out.println("completed: " + pool.getCompletedTaskCount());
        //				}

        if (interrupted.get()) break;

        Thread.sleep(2000);
      }
      out.close();
    } catch (Exception e) {
      e.printStackTrace();
      interrupt();
      cleanup();
    }

    if (domainProvider instanceof RemoteDomainProvider) {
      RemoteDomainProvider remote = (RemoteDomainProvider) domainProvider;
      remote.flushCache();
    }
    long now = System.currentTimeMillis();
    System.out.println("Calculation took : " + (now - startTime) / 1000 + " sec.");
    System.out.println(
        pool.getCompletedTaskCount()
            + " "
            + pool.getPoolSize()
            + " "
            + pool.getActiveCount()
            + " "
            + pool.getTaskCount());
    //		if ((now-startTime)/1000 > 30) {

    //		try {
    //			out.flush();
    //			out.close();
    //		} catch (Exception e) {
    //			e.printStackTrace();
    //		}
    if (parent != null) {
      parent.notifyCalcFinished();
      DBResultTable table = new DBResultTable();
      table.show(resultList, config);
    }
  }
  /**
   * 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);
    }
  }