Example usage for java.util.concurrent TimeoutException printStackTrace

List of usage examples for java.util.concurrent TimeoutException printStackTrace

Introduction

In this page you can find the example usage for java.util.concurrent TimeoutException printStackTrace.

Prototype

public void printStackTrace(PrintStream s) 

Source Link

Document

Prints this throwable and its backtrace to the specified print stream.

Usage

From source file:com.genentech.chemistry.openEye.apps.SDFTopologicalIndexer.java

private void run(String inFile) {
    oemolithread ifs = new oemolithread(inFile);
    long start = System.currentTimeMillis();
    int iCounter = 0; //Structures in the SD file.

    OEMolBase mol = new OEGraphMol();
    while (oechem.OEReadMolecule(ifs, mol)) {
        iCounter++;//from  w w  w  .  ja  v  a 2  s . co m

        try {
            indexer.computeIndexes(mol);
            //System.err.println(OETools.molToCanSmi(mol, true));
            if (doJ)
                oechem.OESetSDData(mol, "J", DataFormat.formatNumber(indexer.getBalabanJIndex(), "r3"));
            if (doJStar)
                oechem.OESetSDData(mol, "JStar", DataFormat.formatNumber(indexer.getBalabanJStarIndex(), "r3"));
            if (doJX)
                oechem.OESetSDData(mol, "JX", DataFormat.formatNumber(indexer.getBalabanJXIndex(), "r3"));
            if (doJXStar)
                oechem.OESetSDData(mol, "JXStar",
                        DataFormat.formatNumber(indexer.getBalabanJXStarIndex(), "r3"));
            if (doJY)
                oechem.OESetSDData(mol, "JY", DataFormat.formatNumber(indexer.getBalabanJYIndex(), "r3"));
            if (doJYStar)
                oechem.OESetSDData(mol, "JYStar",
                        DataFormat.formatNumber(indexer.getBalabanJYStarIndex(), "r3"));
            if (doWiener)
                oechem.OESetSDData(mol, "Wiener", Long.toString(indexer.getWienerIndex()));
            if (doZagreb)
                oechem.OESetSDData(mol, "Zagreb", Integer.toString(indexer.getZagrebIndex()));

        } catch (TimeoutException e) {
            System.err
                    .println("Conmputing topological Index timeed out for: " + OETools.molToCanSmi(mol, true));
        } catch (NumberFormatException e) {
            System.err.println("Conmputing topological Index caused NumberFormatException for: "
                    + OETools.molToCanSmi(mol, true));
            e.printStackTrace(System.err);
        } catch (OutOfMemoryError e) {
            System.err.println("Conmputing topological Index caused OutOfMemoryError for: "
                    + OETools.molToCanSmi(mol, true));
            throw e;
        }
        oechem.OEWriteMolecule(outputOEThread, mol);

        //Output "." to show that the program is running.
        if (iCounter % 100 == 0)
            System.err.print(".");
        if (iCounter % 4000 == 0) {
            System.err.printf(" %d %dsec\n", iCounter, (System.currentTimeMillis() - start) / 1000);
        }
    }

    mol.delete();
    ifs.close();
    inFile = inFile.replaceAll(".*" + Pattern.quote(File.separator), "");
    System.err.printf("%s: Read %d structures from %s. in %d sec\n", MY_NAME, iCounter, inFile,
            (System.currentTimeMillis() - start) / 1000);
}