Skip to content

Commit

Permalink
comments and minor code orga
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmoho committed Aug 18, 2024
1 parent 9518897 commit f433465
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
19 changes: 12 additions & 7 deletions src/main/java/edu/ucsd/sbrg/ModelPolisherCLILauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ public void commandLineMode(AppConf appConf) {
}
}
else {
long startTime = System.currentTimeMillis();

processFile(parameters.input(), parameters.output());

// Log the time taken to process the file
long timeTaken = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime);
logger.info(String.format(MESSAGES.getString("FINISHED_TIME"), (timeTaken / 60), (timeTaken % 60)));
}

} catch (ModelValidatorException | ModelWriterException | IOException |
Expand Down Expand Up @@ -196,20 +202,20 @@ private void validateIOParameters() throws IOException {


private void processFile(File input, File output) throws ModelReaderException, ModelWriterException, ModelValidatorException, AnnotationException, SQLException {
long startTime = System.currentTimeMillis();

SBMLDocument doc = new ModelReader(parameters.sboParameters(), registry).read(input);

// TODO: hier wäre es jetzt angebracht das Ding zu validieren, geht aber nicht, weil es keinen Validator in JSBML gibt
// TODO: validieren und ggf. fixer aufrufen

Model model = doc.getModel();

// TODO: das sollte sich durch JSBML UpdateListener ersetzen lassen
List<ProgressObserver> polishingObservers = List.of(new PolisherProgressBar());
int count = getPolishingTaskCount(model);
for (var o : polishingObservers) {
o.initialize(new ProgressInitialization(count));
}

// TODO: dispatch abhängig von level und version
new SBMLPolisher(
parameters.polishingParameters(),
parameters.sboParameters(),
Expand All @@ -219,17 +225,20 @@ private void processFile(File input, File output) throws ModelReaderException, M
o.finish(null);
}

// TODO: das sollte sich durch JSBML UpdateListener ersetzen lassen
List<ProgressObserver> annotationObservers = List.of(new PolisherProgressBar());
int annotationTaskCount = getAnnotationTaskCount(model);
for (var o : annotationObservers) {
o.initialize(new ProgressInitialization(annotationTaskCount));
}

// TODO: dispatch abhängig von level und version
if (parameters.annotationParameters().biggAnnotationParameters().annotateWithBiGG()) {
new BiGGSBMLAnnotator(new BiGGDB(), parameters.annotationParameters().biggAnnotationParameters(), parameters.sboParameters(),
registry, annotationObservers).annotate(doc);
}

// TODO: dispatch abhängig von level und version
if (parameters.annotationParameters().adbAnnotationParameters().annotateWithAdb()) {
new ADBSBMLAnnotator(new AnnotateDB(), parameters.annotationParameters().adbAnnotationParameters()).annotate(doc);
}
Expand All @@ -246,10 +255,6 @@ private void processFile(File input, File output) throws ModelReaderException, M
// use offline validation
mv.validate(output);
}

// Log the time taken to process the file
long timeTaken = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime);
logger.info(String.format(MESSAGES.getString("FINISHED_TIME"), (timeTaken / 60), (timeTaken % 60)));
}

private int getPolishingTaskCount(Model model) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/ucsd/sbrg/fixing/ReactionFixer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public void fix(Reaction reaction, int index) {
fixMissingReactionId(reaction, index);
setFastProperty(reaction);
setReversibleProperty(reaction);
new SpeciesReferenceFixer().fix(reaction.getListOfReactants());
new SpeciesReferenceFixer().fix(reaction.getListOfProducts());
}

private void fixMissingReactionId(Reaction reaction, int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.sbml.jsbml.SpeciesReference;

public class SpeciesReferenceFixer implements IFixSpeciesReferences{
public class SpeciesReferenceFixer implements IFixSpeciesReferences {

@Override
public void fix(SpeciesReference sr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public class GroupsFixer {
private static final Logger logger = LoggerFactory.getLogger(GroupsFixer.class);
private static final ResourceBundle MESSAGES = ResourceManager.getBundle("edu.ucsd.sbrg.polisher.Messages");

/**
* Set group kind where required
*
*/
public static void fixGroups(Model model) {
GroupsModelPlugin gPlug = (GroupsModelPlugin) model.getExtension(GroupsConstants.shortLabel);
if ((gPlug != null) && gPlug.isSetListOfGroups()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import edu.ucsd.sbrg.reporting.ProgressObserver;
import edu.ucsd.sbrg.resolver.Registry;
import org.sbml.jsbml.Compartment;
import org.sbml.jsbml.Model;
import org.sbml.jsbml.SBO;
import org.sbml.jsbml.Unit;

import de.zbit.util.ResourceManager;
import edu.ucsd.sbrg.db.bigg.BiGGId;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/edu/ucsd/sbrg/polishing/SBMLPolisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public SBMLPolisher(PolishingParameters parameters, SBOParameters sboParameters,
@Override
public void polish(SBMLDocument doc) {
logger.debug(format("Polish doc: {0}", doc.toString()));
// Ensure the document is at the correct SBML level and version
if (!doc.isSetLevelAndVersion() || (doc.getLevelAndVersion().compareTo(ValuePair.of(3, 1)) < 0)) {
if (!doc.isSetLevelAndVersion() || (doc.getLevelAndVersion().compareTo(ValuePair.of(3, 1)) < 0)) {
logger.debug(MESSAGES.getString("TRY_CONV_LVL3_V1"));
SBMLtools.setLevelAndVersion(doc, 3, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.sbml.jsbml.SpeciesReference;

public class SpeciesReferencesPolisher implements IPolishSpeciesReferences{
public class SpeciesReferencesPolisher implements IPolishSpeciesReferences {

private final Integer defaultSBOterm;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import de.zbit.util.ResourceManager;
import edu.ucsd.sbrg.db.bigg.BiGGId;
import org.sbml.jsbml.Annotation;
import org.sbml.jsbml.Model;
import org.sbml.jsbml.Reaction;
import org.sbml.jsbml.ext.fbc.*;
Expand Down

0 comments on commit f433465

Please sign in to comment.