Skip to content

Commit

Permalink
Replace -debug by -verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasblum committed Nov 5, 2024
1 parent 6097d48 commit 71c3edb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -40,10 +40,13 @@ void buildDatabase(String url, String password, int fetchSize, File outputDirect
try (Connection connection = DriverManager.getConnection(url, USER, password)) {
List<String> partitions = getPartitions(connection);

long proteinCount = 0;
int proteinCount = 0;
int milestone = 1_000_000;
int step = 1_000_000;
int partitionDone = 0;
Map<String, KVSequenceEntry> 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)) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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();
Expand All @@ -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:@//<host>:<port>/<service>");
System.out.println(" -debug : show stats");
System.out.println(" -verbose : increase frequency of progress messages");
System.exit(1);
}
}

0 comments on commit 71c3edb

Please sign in to comment.