Skip to content

Commit

Permalink
organized external packages and options
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitoii11 committed Aug 21, 2016
1 parent 41c1d4d commit cec1bd8
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 36 deletions.
53 changes: 53 additions & 0 deletions src/org/sbml/extconverter/EXTConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright 2016 Kaito Ii
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package org.sbml.extconverter;

import org.sbml.jsbml.Model;
import org.sbml.wrapper.ModelWrapper;

// TODO: Auto-generated Javadoc
/**
* The Class EXTConverter.
*
* @author Kaito Ii
*
* Date Created: Aug 22, 2016
*/

public abstract class EXTConverter {

/** The model. */
protected Model model;

/** The m wrapper. */
protected ModelWrapper mWrapper;

/**
* Instantiates a new EXT converter.
*
* @param model the model
* @param mWrapper the m wrapper
*/
public EXTConverter(Model model, ModelWrapper mWrapper){
this.model = model;
this.mWrapper = mWrapper;
}

/**
* Convert.
*/
public abstract void convert();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package org.sbml.layoutconverter;
package org.sbml.extconverter;

import java.util.List;

Expand Down Expand Up @@ -44,13 +44,7 @@
* Date Created: Aug 6, 2016
*/

public class FBCConverter {

/** The model. */
private Model model;

/** The m wrapper. */
private ModelWrapper mWrapper;
public class FBCConverter extends EXTConverter{

/** The fbc plugin. */
private FBCModelPlugin fbcPlugin;
Expand All @@ -62,8 +56,7 @@ public class FBCConverter {
* @param mWrapper the m wrapper
*/
public FBCConverter(Model model, ModelWrapper mWrapper) {
this.model = model;
this.mWrapper = mWrapper;
super(model, mWrapper);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package org.sbml.layoutconverter;
package org.sbml.extconverter;

import org.sbml.jsbml.Model;
import org.sbml.wrapper.ModelWrapper;
Expand All @@ -27,13 +27,7 @@
* Date Created: Aug 7, 2016
*/
//TODO convert complex species and included species from CellDesigner Annootation to SBML Multi package
public class MultiConverter {

/** The model. */
private Model model;

/** The m wrapper. */
private ModelWrapper mWrapper;
public class MultiConverter extends EXTConverter{

/**
* Instantiates a new multi converter.
Expand All @@ -42,8 +36,7 @@ public class MultiConverter {
* @param mWrapper the m wrapper
*/
public MultiConverter(Model model, ModelWrapper mWrapper){
this.model = model;
this.mWrapper = mWrapper;
super(model, mWrapper);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/org/sbml/extconverter/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright 2016 Kaito Ii
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
/**
* @author Kaito Ii
*
* Date Created: Aug 22, 2016
*/
package org.sbml.extconverter;
49 changes: 49 additions & 0 deletions src/org/sbml/layoutconverter/ApplicationOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public class ApplicationOption {
/** The default compartment. */
@Option(name = "-d", aliases= {"--defaultCompartment"}, required = false, usage = "convert default compartment")
private Boolean defaultCompartment;

/** The convert 2 FBC. */
@Option(name = "-f", aliases= {"--fbc"}, required = false, usage = "add FBC packages")
private boolean convert2FBC;

/** The input. */
@Argument(index = 0, metaVar = "input files", required = true, usage = "input file")
Expand Down Expand Up @@ -104,6 +108,31 @@ public boolean issetLayout2CD() {
return true;
}

/**
* Checks if is sets the conversion direction.
*
* @return true, if is sets the conversion direction
*/
public boolean isSetConversionDirection(){
if(issetLayout2CD() || issetCD2Layout())
return false;

return true;
}

/**
* Checks if is 2 CD 2 layout.
*
* @return true, if is 2 CD 2 layout
*/
public boolean is2CD2Layout(){
if(issetCD2Layout())
return CD2Layout;

else
return Layout2CD;
}

/**
* Checks if is default compartment.
*
Expand All @@ -125,6 +154,18 @@ public String getInput() {
return input;
}

/**
* Checks if is sets the output.
*
* @return true, if is sets the output
*/
public boolean isSetOutput(){
if(output == null)
return false;

return true;
}

/**
* Gets the output.
*
Expand All @@ -137,4 +178,12 @@ public String getOutput() {
return output;
}

/**
* Gets the convert 2 FBC.
*
* @return the convert 2 FBC
*/
public boolean isConvert2FBC() {
return convert2FBC;
}
}
80 changes: 77 additions & 3 deletions src/org/sbml/layoutconverter/BaseLayoutConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public abstract class BaseLayoutConverter {
/** The Constant DEFAULT_SPECIES_DEPTH. */
protected static final double DEFAULT_SPECIES_DEPTH = 1.0;

/** The convert 2 FBC. */
protected boolean convert2FBC = false;

/** The convert 2 multi. */
protected boolean convert2Multi = false;

/**
* Instantiates a new base layout converter.
*
Expand Down Expand Up @@ -121,6 +127,20 @@ public BaseLayoutConverter(File file, boolean defaultCompartment, String outputF
this.convertDefaultCompartment = defaultCompartment;
}

/**
* Instantiates a new base layout converter.
*
* @param file the file
* @param options the options
* @throws XMLStreamException the XML stream exception
* @throws IOException Signals that an I/O exception has occurred.
*/
public BaseLayoutConverter(File file, ApplicationOption options) throws XMLStreamException, IOException{
this(file);
this.outputFileName = options.isSetOutput() ? options.getOutput() : SBMLUtil.createOutputFileName(file);
this.convertDefaultCompartment = options.isDefaultCompartment();
}

/**
* Gets the document.
*
Expand Down Expand Up @@ -166,9 +186,9 @@ public void setModel(Model model) {
* Save.
*/
public abstract void save();

/**
* void TODO.
* Validate.
*/
public void validate() {
document.checkConsistency();
Expand All @@ -180,7 +200,7 @@ public void validate() {
}

/**
* void TODO.
* Print
*/
public void print() {
try {
Expand All @@ -192,5 +212,59 @@ public void print() {
e.printStackTrace();
}
}

/**
* Checks if is convert default compartment.
*
* @return the convertDefaultCompartment
*/
public boolean isConvertDefaultCompartment() {
return convertDefaultCompartment;
}

/**
* Sets the convert default compartment.
*
* @param convertDefaultCompartment the convertDefaultCompartment to set
*/
public void setConvertDefaultCompartment(boolean convertDefaultCompartment) {
this.convertDefaultCompartment = convertDefaultCompartment;
}

/**
* Checks if is convert 2 FBC.
*
* @return the convert2FBC
*/
public boolean isConvert2FBC() {
return convert2FBC;
}

/**
* Sets the convert 2 FBC.
*
* @param convert2fbc the convert2FBC to set
*/
public void setConvert2FBC(boolean convert2fbc) {
convert2FBC = convert2fbc;
}

/**
* Checks if is convert 2 multi.
*
* @return the convert2Multi
*/
public boolean isConvert2Multi() {
return convert2Multi;
}

/**
* Sets the convert 2 multi.
*
* @param convert2Multi the convert2Multi to set
*/
public void setConvert2Multi(boolean convert2Multi) {
this.convert2Multi = convert2Multi;
}

}
21 changes: 15 additions & 6 deletions src/org/sbml/layoutconverter/CD2LayoutConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.sbml._2001.ns.celldesigner.Modification;
import org.sbml._2001.ns.celldesigner.ProductLink;
import org.sbml._2001.ns.celldesigner.ReactantLink;
import org.sbml.extconverter.FBCConverter;
import org.sbml.extconverter.MultiConverter;
import org.sbml.jsbml.ListOf;
import org.sbml.jsbml.Reaction;
import org.sbml.jsbml.SBMLException;
Expand Down Expand Up @@ -67,12 +69,6 @@

public class CD2LayoutConverter extends BaseLayoutConverter {

/** The convert 2 FBC. */
private boolean convert2FBC = true;

/** The convert 2 multi. */
private boolean convert2Multi = false;

/**
* Instantiates a new CD 2 layout converter.
*
Expand Down Expand Up @@ -130,6 +126,19 @@ public CD2LayoutConverter(File file, boolean defaultCompartment) throws XMLStrea
init(file);
}

/**
* @param file
* @param options
* @throws IOException
* @throws XMLStreamException
* @throws JAXBException
*/
public CD2LayoutConverter(File file, ApplicationOption options) throws XMLStreamException, IOException, JAXBException {
super(file, options);
convert2FBC = options.isConvert2FBC();
init(file);
}

/**
* Inits the.
*
Expand Down
Loading

0 comments on commit cec1bd8

Please sign in to comment.