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); } }