Skip to content

Commit

Permalink
new config options for fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmoho committed Aug 18, 2024
1 parent f7775cd commit 546261e
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 25 deletions.
15 changes: 12 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,26 @@ dependencies {
implementation("org.sbml.jsbml:jsbml:1.6.1") {
exclude group: "org.apache.logging.log4j", module: "log4j-core"
exclude group: "org.apache.logging.log4j", module: "log4j-api"
exclude group: "org.apache.logging.log4j", module: "log4j-1.2-api "
exclude group: "org.apache.logging.log4j", module: "log4j-1.2-api"
exclude group: "org.apache.logging.log4j", module: "log4j-slf4j-impl"
exclude group: "org.apache.commons", module: "logging"
}
// ontology support within BioJava
implementation "org.biojava:biojava-ontology:7.1.1"
implementation("org.biojava:biojava-ontology:7.1.1") {
exclude group: "org.apache.logging.log4j", module: "log4j-core"
exclude group: "org.apache.logging.log4j", module: "log4j-slf4j-impl"
}
// handle Combine Archives (packages of biological models)
implementation "de.uni-rostock.sbi:CombineArchive:1.4.1"
// interacting with MATLAB files
implementation 'us.hebi.matlab.mat:mfl-core:0.5.15'

implementation "org.slf4j:slf4j-api:2.0.9"
implementation "org.slf4j:jul-to-slf4j:2.0.9"
implementation "org.slf4j:jcl-over-slf4j:2.0.9"
implementation "org.slf4j:log4j-over-slf4j:2.0.9"
implementation "org.slf4j:osgi-over-slf4j:2.0.9"

// JDBC connection pool
implementation "com.zaxxer:HikariCP:5.1.0"
// https://mvnrepository.com/artifact/commons-io/commons-io
Expand Down Expand Up @@ -275,4 +284,4 @@ tasks.register('uberjar', Jar) {
*/
application {
mainClass.set('ModelPolisher')
}
}
38 changes: 38 additions & 0 deletions src/main/java/edu/ucsd/sbrg/parameters/FixingParameters.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package edu.ucsd.sbrg.parameters;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Objects;

public class FixingParameters {

@JsonProperty("dont-fix")
private boolean dontFix = false;

public FixingParameters() {
}

public boolean dontFix() {
return dontFix;
}

@Override
public String toString() {
return "FixingParameters{" +
"dontFix=" + dontFix +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FixingParameters that = (FixingParameters) o;
return dontFix == that.dontFix;
}

@Override
public int hashCode() {
return Objects.hashCode(dontFix);
}
}
30 changes: 19 additions & 11 deletions src/main/java/edu/ucsd/sbrg/parameters/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

public class Parameters {

@JsonProperty("fixing")
private final FixingParameters fixing = new FixingParameters();
@JsonProperty("polishing")
private final PolishingParameters polishing = new PolishingParameters();
@JsonProperty("annotation")
Expand Down Expand Up @@ -39,27 +41,33 @@ public ModelPolisherOptions.OutputType outputType() {
return outputType;
}

@Override
public String toString() {
return "Parameters{" +
"polishing=" + polishing +
", annotation=" + annotation +
", sboTerms=" + sboTerms +
", sbmlValidation=" + sbmlValidation +
", outputType=" + outputType +
'}';
public FixingParameters fixing() {
return fixing;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Parameters that = (Parameters) o;
return sbmlValidation == that.sbmlValidation && Objects.equals(polishing, that.polishing) && Objects.equals(annotation, that.annotation) && Objects.equals(sboTerms, that.sboTerms) && outputType == that.outputType;
return sbmlValidation == that.sbmlValidation && Objects.equals(fixing, that.fixing) && Objects.equals(polishing, that.polishing) && Objects.equals(annotation, that.annotation) && Objects.equals(sboTerms, that.sboTerms) && outputType == that.outputType;
}

@Override
public int hashCode() {
return Objects.hash(polishing, annotation, sboTerms, sbmlValidation, outputType);
return Objects.hash(fixing, polishing, annotation, sboTerms, sbmlValidation, outputType);
}

@Override
public String toString() {
return "Parameters{" +
"fixing=" + fixing +
", polishing=" + polishing +
", annotation=" + annotation +
", sboTerms=" + sboTerms +
", sbmlValidation=" + sbmlValidation +
", outputType=" + outputType +
'}';
}

}
28 changes: 19 additions & 9 deletions src/main/java/edu/ucsd/sbrg/parameters/PolishingParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

public class PolishingParameters {

@JsonProperty("polish-even-if-model-invalid")
private boolean polishEvenIfModelInvalid = false;
@JsonProperty("reactions")
private ReactionPolishingParameters reactionPolishingParameters = new ReactionPolishingParameters();
@JsonProperty("flux-objectives")
Expand All @@ -15,9 +17,11 @@ public class PolishingParameters {
public PolishingParameters() { }

public PolishingParameters(ReactionPolishingParameters reactionPolishingParameters,
FluxObjectivesPolishingParameters fluxObjectivesPolishingParameters) {
FluxObjectivesPolishingParameters fluxObjectivesPolishingParameters,
boolean polishEvenIfModelInvalid) {
this.reactionPolishingParameters = reactionPolishingParameters;
this.fluxObjectivesPolishingParameters = fluxObjectivesPolishingParameters;
this.polishEvenIfModelInvalid = polishEvenIfModelInvalid;
}

public PolishingParameters(SBProperties args) throws IllegalArgumentException {
Expand All @@ -33,24 +37,30 @@ public FluxObjectivesPolishingParameters fluxObjectivesPolishingParameters() {
return fluxObjectivesPolishingParameters;
}

@Override
public String toString() {
return "PolishingParameters{" +
"reactionPolishingParameters=" + reactionPolishingParameters +
", fluxObjectivesPolishingParameters=" + fluxObjectivesPolishingParameters +
'}';
public boolean polishEvenIfModelInvalid() {
return polishEvenIfModelInvalid;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PolishingParameters that = (PolishingParameters) o;
return Objects.equals(reactionPolishingParameters, that.reactionPolishingParameters) && Objects.equals(fluxObjectivesPolishingParameters, that.fluxObjectivesPolishingParameters);
return polishEvenIfModelInvalid == that.polishEvenIfModelInvalid && Objects.equals(reactionPolishingParameters, that.reactionPolishingParameters) && Objects.equals(fluxObjectivesPolishingParameters, that.fluxObjectivesPolishingParameters);
}

@Override
public int hashCode() {
return Objects.hash(reactionPolishingParameters, fluxObjectivesPolishingParameters);
return Objects.hash(polishEvenIfModelInvalid, reactionPolishingParameters, fluxObjectivesPolishingParameters);
}

@Override
public String toString() {
return "PolishingParameters{" +
"polishEvenIfModelInvalid=" + polishEvenIfModelInvalid +
", reactionPolishingParameters=" + reactionPolishingParameters +
", fluxObjectivesPolishingParameters=" + fluxObjectivesPolishingParameters +
'}';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public void argumentsAreUsedToInferFluxObjectives() {
null,
new FluxObjectivesPolishingParameters(
null,
List.of("objective_reaction1", "objective_reaction2")));
List.of("objective_reaction1", "objective_reaction2")),
false);

new ListOfObjectivesFixer(parameters, fbcPlugin).fix(fbcPlugin.getListOfObjectives(), 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public void activeObjectiveRemainsUnchangedIfItHasFluxObjective() {
null,
new FluxObjectivesPolishingParameters(
null,
List.of(" objective_reaction1 ")));
List.of(" objective_reaction1 ")),
false);

m.createReaction("objective_reaction1");
m.createReaction("yadda_Biomass_yadda");
Expand Down

0 comments on commit 546261e

Please sign in to comment.