Skip to content

Commit

Permalink
added util methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitoii11 committed May 28, 2016
1 parent c85e6c9 commit d2f832b
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 15 deletions.
7 changes: 7 additions & 0 deletions src/org/sbml/wrapper/CompartmentWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ public String getName(){
public void setName(String value){
annotation.getExtension().setName(value);;
}

public boolean isSetName(){
if(annotation == null || annotation.getExtension().getName() == null)
return false;

return true;
}
}
21 changes: 19 additions & 2 deletions src/org/sbml/wrapper/ModelWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,31 @@ public ModelWrapper(Model model){
this.setListOfRNAs(annotation.getExtension().getListOfRNAs());
this.setModelDisplay(annotation.getExtension().getModelDisplay());
this.setModelVersion(annotation.getExtension().getModelVersion());

this.cWrapperList = createCompartmentWrapperList(model.getListOfCompartments().getCompartment());
this.rWrapperList = createReactionWrapperList(model.getListOfReactions().getReaction());
this.sWrapperList = createSpeciesWrapperList(model.getListOfSpecies().getSpecies());
this.sAliasWrapperList = createSpeciesAliasWrapperList(annotation.getExtension().getListOfSpeciesAliases().getSpeciesAlias());

}

/**
*
* @return
* short
* TODO
*/
public short getSizeX(){
return annotation.getExtension().getModelDisplay().getSizeX();
}

/**
*
* @return
* short
* TODO
*/
public short getSizeY(){
return annotation.getExtension().getModelDisplay().getSizeY();
}

/**
*
Expand Down
52 changes: 44 additions & 8 deletions src/org/sbml/wrapper/ReactionWrapper.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.sbml.wrapper;

import java.util.ArrayList;
import java.util.List;

import org.sbml._2001.ns.celldesigner.BaseProduct;
import org.sbml._2001.ns.celldesigner.BaseProducts;
import org.sbml._2001.ns.celldesigner.BaseReactant;
import org.sbml._2001.ns.celldesigner.BaseReactants;
import org.sbml._2001.ns.celldesigner.ConnectScheme;
import org.sbml._2001.ns.celldesigner.EditPoints;
Expand All @@ -14,7 +17,9 @@
import org.sbml._2001.ns.celldesigner.Offset;
import org.sbml._2001.ns.celldesigner.ProductLink;
import org.sbml._2001.ns.celldesigner.ReactantLink;
import org.sbml.sbml.level2.version4.ModifierSpeciesReference;
import org.sbml.sbml.level2.version4.Reaction;
import org.sbml.sbml.level2.version4.SpeciesReference;

/**
* @author Kaito Ii
Expand All @@ -29,21 +34,28 @@ public class ReactionWrapper extends Reaction{

Reaction reaction;
ModelWrapper modelWrapper;

List<SpeciesReferenceWrapper> reactantWrapperList;
List<SpeciesReferenceWrapper> productWrapperList;
List<ModifierSpeciesReferenceWrapper> modifierWrapperList;

public ReactionWrapper(Reaction reaction, ModelWrapper modelWrapper){
this.reaction = reaction;
this.modelWrapper = modelWrapper;
this.annotation = reaction.getAnnotation();
this.fast = reaction.isFast();
this.id = reaction.getId();
this.kineticLaw = reaction.getKineticLaw();
// this.listOfModifiers = reaction.getListOfModifiers();
// this.listOfProducts = reaction.getListOfProducts();
// this.listOfReactants = reaction.getListOfReactants();
this.listOfModifiers = reaction.getListOfModifiers();
this.listOfProducts = reaction.getListOfProducts();
this.listOfReactants = reaction.getListOfReactants();
this.metaid = reaction.getMetaid();
this.name = reaction.getName();
this.notes = reaction.getNotes();
this.reversible = reaction.isReversible();

reactantWrapperList = createReactantWrapperList(listOfReactants.getSpeciesReference());
productWrapperList = createProductWrapperList(listOfProducts.getSpeciesReference());
//modifierWrapperList = createModifierWrapperList(listOfModifiers.getModifierSpeciesReference());
}

public String getName() {
Expand Down Expand Up @@ -80,8 +92,8 @@ public void setReaction(String value) {
* BaseReactants
* TODO
*/
public BaseReactants getBaseReactants() {
return annotation.getExtension().getBaseReactants();
public List<BaseReactant> getBaseReactants() {
return annotation.getExtension().getBaseReactants().getBaseReactant();
}

/**
Expand All @@ -100,8 +112,8 @@ public void setBaseReactants(BaseReactants value) {
* BaseProducts
* TODO
*/
public BaseProducts getBaseProducts() {
return annotation.getExtension().getBaseProducts();
public List<BaseProduct> getBaseProducts() {
return annotation.getExtension().getBaseProducts().getBaseProduct();
}

/**
Expand Down Expand Up @@ -313,4 +325,28 @@ public void addModification(Modification modification){
public void removeModification(Modification modification){
annotation.getExtension().getListOfModification().getModification().remove(modification);
}

public List<SpeciesReferenceWrapper> createReactantWrapperList(List<SpeciesReference> srList){
List<SpeciesReferenceWrapper> srwList = new ArrayList<SpeciesReferenceWrapper>(srList.size());
for(SpeciesReference sr : srList)
srwList.add(new SpeciesReferenceWrapper(sr, modelWrapper));

return srwList;
}

public List<SpeciesReferenceWrapper> createProductWrapperList(List<SpeciesReference> srList){
List<SpeciesReferenceWrapper> srwList = new ArrayList<SpeciesReferenceWrapper>(srList.size());
for(SpeciesReference sr : srList)
srwList.add(new SpeciesReferenceWrapper(sr, modelWrapper));

return srwList;
}

public List<ModifierSpeciesReferenceWrapper> createModifierWrapperList(List<ModifierSpeciesReference> msrList){
List<ModifierSpeciesReferenceWrapper> msrwList = new ArrayList<ModifierSpeciesReferenceWrapper>(msrList.size());
for(ModifierSpeciesReference msr : msrList)
msrwList.add(new ModifierSpeciesReferenceWrapper(msr, modelWrapper));

return msrwList;
}
}
2 changes: 1 addition & 1 deletion src/org/sbml/wrapper/SpeciesAliasWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SpeciesAliasWrapper(SpeciesAlias speciesAlias, ModelWrapper modelWrapper)
this.compartmentAlias = modelWrapper.getCompartmentAliasById(speciesAlias.getCompartmentAlias());
this.complexSpeciesAlias = modelWrapper.getComplexSpeciesAliasById(speciesAlias.getComplexSpeciesAlias());
this.speciesWrapper = modelWrapper.getSpeciesWrapperById(speciesAlias.getSpecies());

this.view = speciesAlias.getView();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/org/sbml/wrapper/SpeciesWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.sbml._2001.ns.celldesigner.Catalyzed;
import org.sbml._2001.ns.celldesigner.ListOfCatalyzedReactions;
import org.sbml._2001.ns.celldesigner.SpeciesIdentity;
import org.sbml.sbml.level2.version4.Compartment;
import org.sbml.sbml.level2.version4.Species;

/**
Expand All @@ -18,15 +17,14 @@ public class SpeciesWrapper extends Species{

ModelWrapper modelWrapper;
Species species;
Compartment compartment;
CompartmentWrapper compartmentWrapper;

public SpeciesWrapper(Species species, ModelWrapper modelWrapper){
this.modelWrapper = modelWrapper;
this.species = species;
this.annotation = species.getAnnotation();
this.boundaryCondition = species.isBoundaryCondition();
this.charge = species.getCharge();
//this.compartment = species.getCompartment();
this.constant = species.isConstant();
this.hasOnlySubstanceUnits = species.isHasOnlySubstanceUnits();
this.id = species.getId();
Expand All @@ -37,6 +35,8 @@ public SpeciesWrapper(Species species, ModelWrapper modelWrapper){
this.notes = species.getNotes();
this.spatialSizeUnits = species.getSpatialSizeUnits();
this.substanceUnits = species.getSubstanceUnits();

this.compartmentWrapper = modelWrapper.getCompartmentWrapperById(species.getCompartment());
}

/**
Expand Down
11 changes: 10 additions & 1 deletion src/sample/APITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import javax.xml.bind.JAXBIntrospector;
import javax.xml.bind.Unmarshaller;

import org.sbml._2001.ns.celldesigner.ConnectScheme;
import org.sbml._2001.ns.celldesigner.SpeciesAlias;
import org.sbml.sbml.level2.version4.Reaction;
import org.sbml.sbml.level2.version4.Sbml;
import org.sbml.sbml.level2.version4.Species;

Expand Down Expand Up @@ -53,7 +55,14 @@ public static void main(String[] args) {
String str = s.getAnnotation().getExtension().getPositionToCompartment();
System.out.println(s.getId() + ":" + str);
}


List<Reaction> rList = sbml.getModel().getListOfReactions().getReaction();
for(Reaction r : rList){
System.out.println(r.getId() + ":" + r.getAnnotation().getExtension().getReaction() + ", " + r.getAnnotation().getExtension().getName());
ConnectScheme cs = r.getAnnotation().getExtension().getConnectScheme();
System.out.println("connect policy " + cs.getConnectPolicy());
}

}

}

0 comments on commit d2f832b

Please sign in to comment.