Skip to content

Commit

Permalink
static init biggdb
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmoho committed Aug 15, 2024
1 parent 7d57fdd commit 76077ff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
10 changes: 4 additions & 6 deletions src/main/java/edu/ucsd/sbrg/ModelPolisherCLILauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ public class ModelPolisherCLILauncher extends Launcher {

private CommandLineParameters parameters;
private Registry registry;
private BiGGDB bigg;
private AnnotateDB adb;

/**
* Entry point
Expand Down Expand Up @@ -125,11 +123,11 @@ public void commandLineMode(AppConf appConf) {
validateIOParameters();

if (parameters.annotationParameters().biggAnnotationParameters().annotateWithBiGG()) {
this.bigg = new BiGGDB(parameters.annotationParameters().biggAnnotationParameters().dbParameters());
BiGGDB.init(parameters.annotationParameters().biggAnnotationParameters().dbParameters());
}

if (parameters.annotationParameters().adbAnnotationParameters().addADBAnnotations()) {
this.adb = new AnnotateDB(parameters.annotationParameters().adbAnnotationParameters().dbParameters());
AnnotateDB.init(parameters.annotationParameters().adbAnnotationParameters().dbParameters());
}

var inputFiles = FileUtils.listFiles(parameters.input(), new String[]{"xml", "sbml", "json", "mat"}, true);
Expand Down Expand Up @@ -228,12 +226,12 @@ private void processFile(File input, File output) throws ModelReaderException, M
}

if (parameters.annotationParameters().biggAnnotationParameters().annotateWithBiGG()) {
new BiGGSBMLAnnotator(bigg, parameters.annotationParameters().biggAnnotationParameters(), parameters.sboParameters(),
new BiGGSBMLAnnotator(new BiGGDB(), parameters.annotationParameters().biggAnnotationParameters(), parameters.sboParameters(),
registry, annotationObservers).annotate(doc);
}

if (parameters.annotationParameters().adbAnnotationParameters().addADBAnnotations()) {
new ADBSBMLAnnotator(adb, parameters.annotationParameters().adbAnnotationParameters()).annotate(doc);
new ADBSBMLAnnotator(new AnnotateDB(), parameters.annotationParameters().adbAnnotationParameters()).annotate(doc);
}

for (var o : annotationObservers) {
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/edu/ucsd/sbrg/db/adb/AnnotateDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public class AnnotateDB {
private static final Logger logger = LoggerFactory.getLogger(AnnotateDB.class);
private static PostgresConnectionPool connectionPool;

public AnnotateDB (DBParameters parameters) {
public AnnotateDB () {}

public static void init(DBParameters parameters) {
String dbName = parameters.dbName();
String host = parameters.host();
String passwd = parameters.passwd();
Expand All @@ -52,11 +54,6 @@ private static boolean iStrNotNullOrEmpty(String string) {
return !(string == null || string.isEmpty());
}

public AnnotateDB(String host, Integer port, String user, String passwd, String dbName)
{
init(host, port, user, passwd, dbName);
}

public static void init(String host, Integer port, String user, String passwd, String dbName) {
if (null == connectionPool) {
logger.debug("Initialize AnnotateDB");
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/edu/ucsd/sbrg/db/bigg/BiGGDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ public class BiGGDB {
private static Set<String> BiGGDBReactions = new HashSet<>();


public BiGGDB (DBParameters parameters) {
public BiGGDB () {}

private static boolean iStrNotNullOrEmpty(String string) {
return !(string == null || string.isEmpty());
}

public static void init(DBParameters parameters) {
String dbName = parameters.dbName();
String host = parameters.host();
String passwd = parameters.passwd();
Expand All @@ -69,14 +75,6 @@ public BiGGDB (DBParameters parameters) {
}
}

private static boolean iStrNotNullOrEmpty(String string) {
return !(string == null || string.isEmpty());
}

public BiGGDB(String host, Integer port, String user, String passwd, String dbName) {
init(host, port, user, passwd, dbName);
}

public static void init(String host, Integer port, String user, String passwd, String dbName) {

if (null == connectionPool) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/ucsd/sbrg/util/ext/fbc/GPRParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static GeneProductRef createGPR(String astString, Model model) {

// Normalize the identifier to include "G_" prefix if missing.
String oldId = astString.startsWith("G_") ? astString : "G_" + astString;
boolean containsOldId = !model.containsUniqueNamedSBase(oldId);
boolean containsOldId = model.containsUniqueNamedSBase(oldId);

// Attempt to create or find the GeneProduct using a standardized identifier.
var id = BiGGId.createGeneId(astString).toBiGGId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ public abstract class BiGGDBContainerTest {

static {
biggContainer.start();
bigg = new BiGGDB(
BiGGDB.init(
biggContainer.getHost(),
biggContainer.getFirstMappedPort(),
"postgres",
"postgres",
"bigg");
bigg = new BiGGDB();
}

@AfterClass
Expand Down

0 comments on commit 76077ff

Please sign in to comment.