From 71c3edba4b98e5a94ad464dfa72e0b58ef0165ea Mon Sep 17 00:00:00 2001 From: Matthias Blum Date: Tue, 5 Nov 2024 15:29:52 +0000 Subject: [PATCH] Replace -debug by -verbose --- .../iprscan/CreateMatchesDBFromOracle.java | 25 +++++++++++-------- .../precalc/berkeley/iprscan/IprscanMain.java | 10 ++++---- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/core/precalcmatches/berkeley/src/main/java/uk/ac/ebi/interpro/scan/precalc/berkeley/iprscan/CreateMatchesDBFromOracle.java b/core/precalcmatches/berkeley/src/main/java/uk/ac/ebi/interpro/scan/precalc/berkeley/iprscan/CreateMatchesDBFromOracle.java index c38c161e9..1cc15e275 100644 --- a/core/precalcmatches/berkeley/src/main/java/uk/ac/ebi/interpro/scan/precalc/berkeley/iprscan/CreateMatchesDBFromOracle.java +++ b/core/precalcmatches/berkeley/src/main/java/uk/ac/ebi/interpro/scan/precalc/berkeley/iprscan/CreateMatchesDBFromOracle.java @@ -30,7 +30,7 @@ public class CreateMatchesDBFromOracle { "EVALUE, SEQ_FEATURE " + "FROM " + USER + ".LOOKUP_MATCH PARTITION (?)"; - void buildDatabase(String url, String password, int fetchSize, File outputDirectory, boolean debug) { + void buildDatabase(String url, String password, int fetchSize, File outputDirectory, boolean verbose) { System.err.println(Utilities.getTimeAlt() + ": starting"); try (BerkeleyDBJE bdbje = new BerkeleyDBJE(outputDirectory)) { @@ -40,10 +40,13 @@ void buildDatabase(String url, String password, int fetchSize, File outputDirect try (Connection connection = DriverManager.getConnection(url, USER, password)) { List partitions = getPartitions(connection); - long proteinCount = 0; + int proteinCount = 0; + int milestone = 1_000_000; + int step = 1_000_000; int partitionDone = 0; Map matches = new HashMap<>(); - for (String partition: partitions) { + for (int i = 0; i < partitions.size(); i++) { + String partition = partitions.get(i); String query = QUERY.replace("?", partition); try (PreparedStatement ps = connection.prepareStatement(query)) { @@ -157,14 +160,14 @@ void buildDatabase(String url, String password, int fetchSize, File outputDirect matches.clear(); partitionDone++; - String msg = String.format("%s: %,d proteins processed (%d/%d)", - Utilities.getTimeAlt(), - proteinCount, - partitionDone, - partitions.size()); - System.err.println(msg); - if (debug) { - System.err.println(bdbje.getStats()); + if (verbose || i + 1 == partitions.size() || proteinCount >= milestone) { + String msg = String.format("%s: %,d proteins processed (%d/%d)", + Utilities.getTimeAlt(), + proteinCount, + partitionDone, + partitions.size()); + System.err.println(msg); + milestone += step; } } } catch (SQLException e) { diff --git a/core/precalcmatches/berkeley/src/main/java/uk/ac/ebi/interpro/scan/precalc/berkeley/iprscan/IprscanMain.java b/core/precalcmatches/berkeley/src/main/java/uk/ac/ebi/interpro/scan/precalc/berkeley/iprscan/IprscanMain.java index 7b873489f..56a036b88 100644 --- a/core/precalcmatches/berkeley/src/main/java/uk/ac/ebi/interpro/scan/precalc/berkeley/iprscan/IprscanMain.java +++ b/core/precalcmatches/berkeley/src/main/java/uk/ac/ebi/interpro/scan/precalc/berkeley/iprscan/IprscanMain.java @@ -5,7 +5,7 @@ public class IprscanMain { private static String databaseType = null; private static String databasePath = null; private static String databaseUrl = null; - private static boolean debug = false; + private static boolean verbose = false; public static void main(String[] args) { parseArgs(args); @@ -48,7 +48,7 @@ public static void main(String[] args) { } case "matches": { CreateMatchesDBFromOracle builder = new CreateMatchesDBFromOracle(); - builder.buildDatabase(databaseUrl, databasePassword, fetchSize, outputDir, debug); + builder.buildDatabase(databaseUrl, databasePassword, fetchSize, outputDir, verbose); break; } case "sites": { @@ -76,8 +76,8 @@ private static void parseArgs(String[] args) { case "url": databaseUrl = args[++i]; break; - case "debug": - debug = true; + case "verbose": + verbose = true; break; default: usage(); @@ -93,7 +93,7 @@ private static void usage() { System.out.println(" -type TYPE: type of database to build (md5, matches, sites)"); System.out.println(" -dir PATH : output directory of the Berkeley DB"); System.out.println(" -url URL : Oracle connection URL, i.e. jdbc:oracle:thin:@//:/"); - System.out.println(" -debug : show stats"); + System.out.println(" -verbose : increase frequency of progress messages"); System.exit(1); } }