Commit 26e89d1e authored by cfrainay's avatar cfrainay
Browse files

Merge branch 'develop' into feature/mergedSideCompounds

parents c3850ec4 bf25b558
...@@ -19,8 +19,6 @@ test: ...@@ -19,8 +19,6 @@ test:
- mvn clean test - mvn clean test
- cat coverage/target/site/jacoco-aggregate/index.html | grep -o '<tfoot>.*</tfoot>' - cat coverage/target/site/jacoco-aggregate/index.html | grep -o '<tfoot>.*</tfoot>'
deploySnapshot: deploySnapshot:
stage: deploy stage: deploy
script: script:
......
...@@ -55,27 +55,49 @@ import fr.inrae.toulouse.metexplore.met4j_io.jsbml.attributes.Notes; ...@@ -55,27 +55,49 @@ import fr.inrae.toulouse.metexplore.met4j_io.jsbml.attributes.Notes;
*/ */
public class GenericAttributes { public class GenericAttributes {
/** Constant <code>SBML_UNIT_DEFINITIONS="unit_definitions"</code> */ /**
* Constant <code>SBML_UNIT_DEFINITIONS="unit_definitions"</code>
*/
public static final String SBML_UNIT_DEFINITIONS = "unit_definitions"; public static final String SBML_UNIT_DEFINITIONS = "unit_definitions";
/** Constant <code>SBML_NOTES="notes"</code> */ /**
* Constant <code>SBML_NOTES="notes"</code>
*/
public static final String SBML_NOTES = "notes"; public static final String SBML_NOTES = "notes";
/** Constant <code>PMIDS="pmids"</code> */ /**
* Constant <code>PMIDS="pmids"</code>
*/
public static final String PMIDS = "pmids"; public static final String PMIDS = "pmids";
/** Constant <code>COMMENT="comment"</code> */ /**
* Constant <code>COMMENT="comment"</code>
*/
public static final String COMMENT = "comment"; public static final String COMMENT = "comment";
/** Constant <code>SBO_TERM="sbo_term"</code> */ /**
* Constant <code>SBO_TERM="sbo_term"</code>
*/
public static final String SBO_TERM = "sbo_term"; public static final String SBO_TERM = "sbo_term";
/** Constant <code>CONSTANT="constant"</code> */ /**
* Constant <code>CONSTANT="constant"</code>
*/
public static final String CONSTANT = "constant"; public static final String CONSTANT = "constant";
/** Constant <code>SBML_ANNOTATION="annotation"</code> */ /**
* Constant <code>SBML_ANNOTATION="annotation"</code>
*/
public static final String SBML_ANNOTATION = "annotation"; public static final String SBML_ANNOTATION = "annotation";
/** Constant <code>GENERIC="generic"</code> */ /**
* Constant <code>GENERIC="generic"</code>
*/
public static final String GENERIC = "generic"; public static final String GENERIC = "generic";
/** Constant <code>TYPE="type"</code> */ /**
* Constant <code>TYPE="type"</code>
*/
public static final String TYPE = "type"; public static final String TYPE = "type";
/** Constant <code>ANNOTATOR_COMMENTS="annotator_comments"</code> */ /**
* Constant <code>ANNOTATOR_COMMENTS="annotator_comments"</code>
*/
public static final String ANNOTATOR_COMMENTS = "annotator_comments"; public static final String ANNOTATOR_COMMENTS = "annotator_comments";
/** Constant <code>AUTHORS="AUTHORS"</code> */ /**
* Constant <code>AUTHORS="AUTHORS"</code>
*/
public static final String AUTHORS = "AUTHORS"; public static final String AUTHORS = "AUTHORS";
...@@ -103,7 +125,7 @@ public class GenericAttributes { ...@@ -103,7 +125,7 @@ public class GenericAttributes {
/** /**
* Set constant condition * Set constant condition
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param flag a {@link java.lang.Boolean} object. * @param flag a {@link java.lang.Boolean} object.
*/ */
public static void setConstant(BioEntity e, Boolean flag) { public static void setConstant(BioEntity e, Boolean flag) {
...@@ -131,7 +153,7 @@ public class GenericAttributes { ...@@ -131,7 +153,7 @@ public class GenericAttributes {
/** /**
* set notes * set notes
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param notes a {@link fr.inrae.toulouse.metexplore.met4j_io.jsbml.attributes.Notes} object. * @param notes a {@link fr.inrae.toulouse.metexplore.met4j_io.jsbml.attributes.Notes} object.
*/ */
public static void setNotes(BioEntity e, Notes notes) { public static void setNotes(BioEntity e, Notes notes) {
...@@ -145,7 +167,7 @@ public class GenericAttributes { ...@@ -145,7 +167,7 @@ public class GenericAttributes {
* <p> * <p>
* TODO : see if it useful since there is BioRef... * TODO : see if it useful since there is BioRef...
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param pmids a {@link java.util.Set} object. * @param pmids a {@link java.util.Set} object.
*/ */
public static void setPmids(BioEntity e, Set<Integer> pmids) { public static void setPmids(BioEntity e, Set<Integer> pmids) {
...@@ -157,7 +179,7 @@ public class GenericAttributes { ...@@ -157,7 +179,7 @@ public class GenericAttributes {
/** /**
* add pmid * add pmid
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param pmid a {@link java.lang.Integer} object. * @param pmid a {@link java.lang.Integer} object.
*/ */
public static void addPmid(BioEntity e, Integer pmid) { public static void addPmid(BioEntity e, Integer pmid) {
...@@ -196,7 +218,7 @@ public class GenericAttributes { ...@@ -196,7 +218,7 @@ public class GenericAttributes {
/** /**
* set comment * set comment
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param comment a {@link java.lang.String} object. * @param comment a {@link java.lang.String} object.
*/ */
public static void setComment(BioEntity e, String comment) { public static void setComment(BioEntity e, String comment) {
...@@ -206,13 +228,14 @@ public class GenericAttributes { ...@@ -206,13 +228,14 @@ public class GenericAttributes {
/** /**
* set Sbo term * set Sbo term
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param sboTerm a {@link java.lang.String} object. * @param sboTerm a {@link java.lang.String} object.
*/ */
public static void setSboTerm(BioEntity e, String sboTerm) { public static void setSboTerm(BioEntity e, String sboTerm) {
if (!StringUtils.isValidSboTerm(sboTerm)) { if (!StringUtils.isValidSboTerm(sboTerm)) {
System.err.println("[Warning] SBO term badly formatted for " + e.getId() System.err.println("[Warning] SBO term badly formatted for " + e.getId()
+ " ("+sboTerm+", must be in the format SBO:1234567). It has not been set."); + " (" + sboTerm + ", must be in the format SBO:1234567). It has been set to null.");
e.getAttributes().remove(SBO_TERM);
} else { } else {
e.setAttribute(SBO_TERM, sboTerm); e.setAttribute(SBO_TERM, sboTerm);
} }
...@@ -241,7 +264,7 @@ public class GenericAttributes { ...@@ -241,7 +264,7 @@ public class GenericAttributes {
/** /**
* set annotation * set annotation
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param val a {@link fr.inrae.toulouse.metexplore.met4j_io.jsbml.attributes.SbmlAnnotation} object. * @param val a {@link fr.inrae.toulouse.metexplore.met4j_io.jsbml.attributes.SbmlAnnotation} object.
*/ */
public static void setAnnotation(BioEntity e, SbmlAnnotation val) { public static void setAnnotation(BioEntity e, SbmlAnnotation val) {
...@@ -269,7 +292,7 @@ public class GenericAttributes { ...@@ -269,7 +292,7 @@ public class GenericAttributes {
/** /**
* Set generic attribute * Set generic attribute
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param flag a {@link java.lang.Boolean} object. * @param flag a {@link java.lang.Boolean} object.
*/ */
public static void setGeneric(BioEntity e, Boolean flag) { public static void setGeneric(BioEntity e, Boolean flag) {
...@@ -289,7 +312,7 @@ public class GenericAttributes { ...@@ -289,7 +312,7 @@ public class GenericAttributes {
/** /**
* set comment * set comment
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param type a {@link java.lang.String} object. * @param type a {@link java.lang.String} object.
*/ */
public static void setType(BioEntity e, String type) { public static void setType(BioEntity e, String type) {
...@@ -299,7 +322,7 @@ public class GenericAttributes { ...@@ -299,7 +322,7 @@ public class GenericAttributes {
/** /**
* set annotator comments * set annotator comments
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param comments a {@link java.util.Set} object. * @param comments a {@link java.util.Set} object.
*/ */
public static void setAnnotatorComments(BioEntity e, Set<AnnotatorComment> comments) { public static void setAnnotatorComments(BioEntity e, Set<AnnotatorComment> comments) {
...@@ -311,7 +334,7 @@ public class GenericAttributes { ...@@ -311,7 +334,7 @@ public class GenericAttributes {
/** /**
* add comment * add comment
* *
* @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object. * @param e a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity} object.
* @param comment a {@link fr.inrae.toulouse.metexplore.met4j_io.annotations.AnnotatorComment} object. * @param comment a {@link fr.inrae.toulouse.metexplore.met4j_io.annotations.AnnotatorComment} object.
*/ */
public static void addAnnotatorComment(BioEntity e, AnnotatorComment comment) { public static void addAnnotatorComment(BioEntity e, AnnotatorComment comment) {
......
...@@ -37,10 +37,6 @@ package fr.inrae.toulouse.metexplore.met4j_io.jsbml.errors; ...@@ -37,10 +37,6 @@ package fr.inrae.toulouse.metexplore.met4j_io.jsbml.errors;
public class GeneSetException extends Exception { public class GeneSetException extends Exception {
public GeneSetException(String message) {
super(message);
}
public GeneSetException() { public GeneSetException() {
super("Not possible to transform gene set since it has been added in a gene association"); super("Not possible to transform gene set since it has been added in a gene association");
} }
......
...@@ -64,7 +64,7 @@ public class FluxReaction extends BioEntity { ...@@ -64,7 +64,7 @@ public class FluxReaction extends BioEntity {
* The actual {@link BioReaction} that is behind this * The actual {@link BioReaction} that is behind this
* {@link FluxReaction} * {@link FluxReaction}
*/ */
private BioReaction underlyingReaction; private final BioReaction underlyingReaction;
/** /**
* The object holding the Gene Association * The object holding the Gene Association
* *
...@@ -151,16 +151,6 @@ public class FluxReaction extends BioEntity { ...@@ -151,16 +151,6 @@ public class FluxReaction extends BioEntity {
bn.affectEnzyme(rxn, enz); bn.affectEnzyme(rxn, enz);
} }
/**
* <p>createIdFromProteins.</p>
*
* @param proteins a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection} object.
* @return a {@link java.lang.String} object.
*/
public static String createIdFromProteins(BioCollection<BioProtein> proteins) {
return proteins.getIds().stream().sorted().collect(Collectors.joining("_AND_"));
}
/** /**
* Get the {@link #underlyingReaction} * Get the {@link #underlyingReaction}
* *
......
...@@ -39,18 +39,15 @@ package fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader; ...@@ -39,18 +39,15 @@ package fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set;
import java.util.stream.Collectors;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import fr.inrae.toulouse.metexplore.met4j_io.jsbml.errors.JSBMLPackageReaderException;
import org.sbml.jsbml.Model; import org.sbml.jsbml.Model;
import org.sbml.jsbml.SBMLDocument; import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.SBMLError;
import org.sbml.jsbml.SBMLError.SEVERITY;
import org.sbml.jsbml.SBMLReader; import org.sbml.jsbml.SBMLReader;
import org.sbml.jsbml.validator.SBMLValidator;
import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork; import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
import fr.inrae.toulouse.metexplore.met4j_io.jsbml.dataTags.AdditionalDataTag; import fr.inrae.toulouse.metexplore.met4j_io.jsbml.dataTags.AdditionalDataTag;
...@@ -66,8 +63,8 @@ import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.PackageParser; ...@@ -66,8 +63,8 @@ import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.PackageParser;
* depending on the SBML level defined in the file * depending on the SBML level defined in the file
* *
* @author Benjamin Merlet * @author Benjamin Merlet
* @since 3.0
* @version $Id: $Id * @version $Id: $Id
* @since 3.0
*/ */
public class JsbmlReader { public class JsbmlReader {
...@@ -80,7 +77,7 @@ public class JsbmlReader { ...@@ -80,7 +77,7 @@ public class JsbmlReader {
* The list of errors and/or warnings found by jsbml while parsing the SBML * The list of errors and/or warnings found by jsbml while parsing the SBML
* File * File
*/ */
public ArrayList<String> errorsAndWarnings = new ArrayList<String>(); public ArrayList<String> errorsAndWarnings = new ArrayList<>();
/** /**
* The SBML filename * The SBML filename
*/ */
...@@ -89,16 +86,8 @@ public class JsbmlReader { ...@@ -89,16 +86,8 @@ public class JsbmlReader {
* The SBML Model retrieved through jsbml's * The SBML Model retrieved through jsbml's
*/ */
private Model model; private Model model;
/**
* Attribute that specifies if the input sbml is valid or not
*/
private boolean validSBML = true;
/**
* Set to true to use SBML online validator
*/
private boolean useValidator = true;
private String xml = null; private String xmlString = null;
/** /**
* Constructor * Constructor
...@@ -108,19 +97,6 @@ public class JsbmlReader { ...@@ -108,19 +97,6 @@ public class JsbmlReader {
*/ */
public JsbmlReader(String filename) throws IOException { public JsbmlReader(String filename) throws IOException {
this.filename = filename; this.filename = filename;
this.useValidator = false;
}
/**
* Constructor
*
* @param filename the filename
* @param useValidator set the {@link #useValidator} attribute
* @throws java.io.IOException if any.
*/
public JsbmlReader(String filename, boolean useValidator) throws IOException {
this.filename = filename;
this.useValidator = useValidator;
} }
/** /**
...@@ -130,21 +106,8 @@ public class JsbmlReader { ...@@ -130,21 +106,8 @@ public class JsbmlReader {
* @throws java.io.IOException if any. * @throws java.io.IOException if any.
*/ */
public JsbmlReader(InputStream inputStream) throws IOException { public JsbmlReader(InputStream inputStream) throws IOException {
this.xml = this.inputStreamToString(inputStream); this.xmlString = this.inputStreamToString(inputStream);
this.useValidator = false;
}
/**
* <p>Constructor for JsbmlReader.</p>
*
* @param inputStream a {@link java.io.InputStream} object.
* @param useValidator a boolean.
* @throws java.io.IOException if any.
*/
public JsbmlReader(InputStream inputStream, boolean useValidator) throws IOException {
this.xml = this.inputStreamToString(inputStream);
this.useValidator = useValidator;
} }
private String inputStreamToString(InputStream inputStream) throws IOException { private String inputStreamToString(InputStream inputStream) throws IOException {
...@@ -152,21 +115,19 @@ public class JsbmlReader { ...@@ -152,21 +115,19 @@ public class JsbmlReader {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
sb.append(line + System.lineSeparator()); sb.append(line).append(System.lineSeparator());
} }
return sb.toString(); return sb.toString();
} }
/** /*
* A test main method * A test main method
* *
* @param args the arguments * @param args the arguments
* @throws fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException if any. * @throws fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException if any.
* @throws java.io.IOException if any. * @throws java.io.IOException if any.
*/ */
public static void main(String[] args) throws Met4jSbmlReaderException, IOException, JSBMLPackageReaderException { /* public static void main(String[] args) throws Met4jSbmlReaderException, IOException, JSBMLPackageReaderException {
// String // String
String inputFile = args[0]; String inputFile = args[0];
...@@ -205,7 +166,7 @@ public class JsbmlReader { ...@@ -205,7 +166,7 @@ public class JsbmlReader {
System.err.println("End :" + new Date()); System.err.println("End :" + new Date());
} }*/
/** /**
* <p>read.</p> * <p>read.</p>
...@@ -218,43 +179,41 @@ public class JsbmlReader { ...@@ -218,43 +179,41 @@ public class JsbmlReader {
* @throws fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException if any. * @throws fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException if any.
*/ */
public BioNetwork read(ArrayList<PackageParser> userEnabledPackages) throws Met4jSbmlReaderException { public BioNetwork read(ArrayList<PackageParser> userEnabledPackages) throws Met4jSbmlReaderException {
try { try {
this.initiateModel(); this.initiateModel();
} catch (IOException | XMLStreamException e) { } catch (IOException | XMLStreamException e) {
e.printStackTrace(); e.printStackTrace();
this.setValidSBML(false);
} }
if (this.isValidSBML()) {
System.err.println("Verifying enabled Plugins..."); System.err.println("Verifying enabled Plugins...");
ArrayList<PackageParser> verifiedPkgs = this ArrayList<PackageParser> verifiedPkgs = this.verifyPackages(userEnabledPackages);
.verifyPackages(userEnabledPackages);
JsbmlToBioNetwork converter = new JsbmlToBioNetwork(this.getModel()); JsbmlToBioNetwork converter = new JsbmlToBioNetwork(this.getModel());
this.setConverter(converter); this.setConverter(converter);
try { try {
converter.setPackages(verifiedPkgs); converter.setPackages(verifiedPkgs);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.exit(1); throw new Met4jSbmlReaderException("Problem while setting the JSBML packages");
} }
System.err.println("Parsing model " + this.getModel().getId()); return parseModel();
}
this.getConverter().parseModel(); protected BioNetwork parseModel() throws Met4jSbmlReaderException {
System.err.println("Parsing model " + this.getModel().getId());
System.err.println("End Parsing model " + this.getModel().getId()); this.getConverter().parseModel();
this.errorsAndWarnings.addAll(PackageParser.errorsAndWarnings); System.err.println("End Parsing model " + this.getModel().getId());
return this.getConverter().getNetwork(); this.errorsAndWarnings.addAll(PackageParser.errorsAndWarnings);
} else {
return null; return this.getConverter().getNetwork();
}
} }
/** /**
...@@ -264,9 +223,7 @@ public class JsbmlReader { ...@@ -264,9 +223,7 @@ public class JsbmlReader {
* @throws fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException if any. * @throws fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException if any.
*/ */
public BioNetwork read() throws Met4jSbmlReaderException { public BioNetwork read() throws Met4jSbmlReaderException {
ArrayList<PackageParser> pkgs = new ArrayList<PackageParser>(Arrays.asList( ArrayList<PackageParser> pkgs = new ArrayList<>(Arrays.asList(new NotesParser(true), new FBCParser(), new GroupPathwayParser(), new AnnotationParser(true)));
new NotesParser(true), new FBCParser(), new GroupPathwayParser(), new AnnotationParser(
true)));
return this.read(pkgs); return this.read(pkgs);
}