本文整理汇总了Java中org.sbml.jsbml.ext.fbc.FBCConstants类的典型用法代码示例。如果您正苦于以下问题:Java FBCConstants类的具体用法?Java FBCConstants怎么用?Java FBCConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FBCConstants类属于org.sbml.jsbml.ext.fbc包,在下文中一共展示了FBCConstants类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertSpecies
import org.sbml.jsbml.ext.fbc.FBCConstants; //导入依赖的package包/类
/**
* Convert species.
*/
public void convertSpecies() {
List<SpeciesWrapper> swList = mWrapper.getListOfSpeciesWrapper();
for (SpeciesWrapper sw : swList) {
if (sw.getCharge() != null) {
Species s = model.getSpecies(sw.getId());
FBCSpeciesPlugin speciesPlugin = (FBCSpeciesPlugin) s.getPlugin(FBCConstants.shortLabel);
speciesPlugin.setCharge(sw.getCharge().intValue());
}
}
}
示例2: convertReactions
import org.sbml.jsbml.ext.fbc.FBCConstants; //导入依赖的package包/类
/**
* Convert reactions.
*/
public void convertReactions() {
List<ReactionWrapper> rwList = mWrapper.getListOfReactionWrapper();
for (ReactionWrapper rw : rwList) {
List<Modification> mList = rw.getListOfModification();
if (mList == null)
continue;
for (Modification modification : mList) {
if (modification.getType().contains("BOOLEAN_LOGIC_GATE")) {
Reaction reaction = model.getReaction(rw.getId());
FBCReactionPlugin reactionPlugin = (FBCReactionPlugin) reaction.getPlugin(FBCConstants.shortLabel);
GeneProductAssociation gpa;
if (reactionPlugin.isSetGeneProductAssociation())
gpa = reactionPlugin.getGeneProductAssociation();
else
gpa = reactionPlugin.createGeneProductAssociation("ga_"
+ rw.getId());
String modifiers = modification.getModifiers();
String[] modifierList = modifiers.split(",");
for (String m : modifierList) {
if (fbcPlugin.getListOfGeneProducts().get("gene_" + m) == null) {
GeneProduct geneProduct = fbcPlugin.createGeneProduct("gene_" + m);
geneProduct.setLabel(m);
geneProduct.setAssociatedSpecies(m);
}
}
LogicalOperator lo;
if (modification.getType().contains("AND")) {
lo = setAllProductRef(new And(), modifierList, rw.getId());
} else {
lo = setAllProductRef(new Or(), modifierList, rw.getId());
}
gpa.setAssociation(lo);
}
}
}
}
示例3: addExtensionPackageFBC
import org.sbml.jsbml.ext.fbc.FBCConstants; //导入依赖的package包/类
/**
* Adds the extension package fbc.
*
* @param document the document
* @return the SBML document
*/
public static SBMLDocument addExtensionPackageFBC(SBMLDocument document) {
document.enablePackage(FBCConstants.getNamespaceURI(SBMLUtil.DEFAULT_SBML_LEVEL, SBMLUtil.DEFAULT_SBML_VERSION), true);
document.setPackageRequired(FBCConstants.getNamespaceURI(SBMLUtil.DEFAULT_SBML_LEVEL, SBMLUtil.DEFAULT_SBML_VERSION), false);
return document;
}
示例4: getFBCReactionPlugin
import org.sbml.jsbml.ext.fbc.FBCConstants; //导入依赖的package包/类
public static FBCReactionPlugin getFBCReactionPlugin(Reaction r)
{
if (r.getExtension(FBCConstants.namespaceURI) != null)
{
return (FBCReactionPlugin) r.getExtension(FBCConstants.namespaceURI);
}
FBCReactionPlugin reac = new FBCReactionPlugin(r);
r.addExtension(FBCConstants.namespaceURI, reac);
return reac;
}
示例5: convertToFBCVersion2
import org.sbml.jsbml.ext.fbc.FBCConstants; //导入依赖的package包/类
private static SBMLDocument convertToFBCVersion2(String filename,SBMLDocument document) throws XMLStreamException, IOException, BioSimException
{
if (document.getDeclaredNamespaces().get("xmlns:"+FBCConstants.shortLabel)!=null &&
document.getDeclaredNamespaces().get("xmlns:"+FBCConstants.shortLabel).endsWith("1"))
{
if (!Executables.libsbmlFound)
{
throw new BioSimException("Unable convert FBC model from Version 1 to Version 2.", "Error Opening File");
}
//long numErrors = 0;
org.sbml.libsbml.SBMLReader reader = new org.sbml.libsbml.SBMLReader();
org.sbml.libsbml.SBMLDocument doc = reader.readSBML(filename);
/* create a new conversion properties structure */
ConversionProperties props = new ConversionProperties(new SBMLNamespaces(3, 1));
/* add an option that we want to strip a given package */
boolean strict = false;
props.addOption("convert fbc v1 to fbc v2", true, "convert fbc v1 to fbc v2");
props.addOption("strict", strict, "should the model be a strict one (i.e.: all non-specified bounds will be filled)");
/* perform the conversion */
if (doc.convert(props) != libsbml.LIBSBML_OPERATION_SUCCESS)
{
System.err.println("Conversion failed!");
doc.printErrors();
// System.exit(2);
}
org.sbml.libsbml.SBMLWriter writer = new org.sbml.libsbml.SBMLWriter();
writer.writeSBMLToFile(doc, filename);
document = SBMLReader.read(new File(filename));
} else {
SBMLutilities.getFBCModelPlugin(document.getModel(),true);
}
return document;
}
示例6: convertModel
import org.sbml.jsbml.ext.fbc.FBCConstants; //导入依赖的package包/类
/**
* Convert model.
*/
public void convertModel() {
fbcPlugin = (FBCModelPlugin) model.getPlugin(FBCConstants.shortLabel);
fbcPlugin.setStrict(false);
}
示例7: createFBCPlugin
import org.sbml.jsbml.ext.fbc.FBCConstants; //导入依赖的package包/类
public void createFBCPlugin() {
sbml.enablePackage(FBCConstants.namespaceURI);
sbmlFBC = SBMLutilities.getFBCModelPlugin(sbml.getModel(),true);
}
示例8: createSingleDocument
import org.sbml.jsbml.ext.fbc.FBCConstants; //导入依赖的package包/类
public SBMLDocument createSingleDocument() throws XMLStreamException, IOException, BioSimException {
ArrayList<String> comps = new ArrayList<String>();
SBMLDocument document = new SBMLDocument(GlobalConstants.SBML_LEVEL, GlobalConstants.SBML_VERSION);
Model model = new Model(sbml.getModel());
document.setModel(model);
document.enablePackage(LayoutConstants.namespaceURI);
SBMLutilities.getLayoutModelPlugin(document.getModel());
if (sbmlCompModel.getListOfPorts().size() > 0 || sbmlCompModel.getListOfSubmodels().size() > 0) {
document.enablePackage(CompConstants.namespaceURI);
}
if (sbmlFBC.getListOfObjectives().size() > 0) {
document.enablePackage(FBCConstants.namespaceURI);
} else {
for (int i = 0; i < document.getModel().getNumReactions(); i++) {
Reaction r = document.getModel().getReaction(i);
FBCReactionPlugin rBounds = SBMLutilities.getFBCReactionPlugin(r);
if (rBounds != null) {
if (rBounds.isSetLowerFluxBound()) {
document.enablePackage(FBCConstants.namespaceURI);
break;
}
if (rBounds.isSetUpperFluxBound()) {
document.enablePackage(FBCConstants.namespaceURI);
break;
}
}
}
}
document.enablePackage(ArraysConstants.namespaceURI);
if (sbmlCompModel.getListOfSubmodels().size()>0) {
CompSBMLDocumentPlugin documentComp = SBMLutilities.getCompSBMLDocumentPlugin(document);
for (int i = 0; i < sbmlCompModel.getListOfSubmodels().size(); i++) {
String subModelId = sbmlCompModel.getListOfSubmodels().get(i).getId();
String extModel = sbmlComp.getListOfExternalModelDefinitions().get(sbmlCompModel.getListOfSubmodels().get(subModelId)
.getModelRef()).getSource().replace("file://","").replace("file:","").replace(".gcm",".xml");
if (!comps.contains(extModel)) {
comps.add(extModel);
SBMLDocument subDocument = SBMLutilities.readSBML(path + File.separator + extModel, this, null);
CompModelPlugin subDocumentCompModel = SBMLutilities.getCompModelPlugin(subDocument.getModel());
String id = subDocument.getModel().getId();
// TODO: hack to avoid jsbml scope bug
LayoutModelPlugin subDocumentLayoutModel = SBMLutilities.getLayoutModelPlugin(subDocument.getModel());
Layout layout = subDocumentLayoutModel.getListOfLayouts().get("iBioSim");
layout.setId(id+"__iBioSim");
ModelDefinition md = new ModelDefinition(subDocument.getModel());
ArrayList<SBase> elements = SBMLutilities.getListOfAllElements(md);
for (int j = 0; j < elements.size(); j++) {
SBase sbase = elements.get(j);
if (sbase.isSetMetaId()) {
for (int k = 0; k < subDocumentCompModel.getListOfPorts().size(); k++) {
Port port = subDocumentCompModel.getListOfPorts().get(k);
if (port.isSetMetaIdRef() && port.getMetaIdRef().equals(sbase.getMetaId())) {
port.setMetaIdRef(id+"__"+sbase.getMetaId());
}
}
String newMetaId = id+"__"+sbase.getMetaId();
while (SBMLutilities.getElementByMetaId(document, newMetaId)!=null) {
newMetaId += "_";
}
while (SBMLutilities.getElementByMetaId(subDocument, newMetaId)!=null) {
newMetaId += "_";
}
while (SBMLutilities.getElementByMetaId(documentComp, newMetaId)!=null) {
newMetaId += "_";
}
sbase.unsetMetaId();
SBMLutilities.setMetaId(sbase, newMetaId);
}
}
documentComp.addModelDefinition(md);
recurseExportSingleFile(comps,SBMLutilities.getCompModelPlugin(subDocument.getModel()),
SBMLutilities.getCompSBMLDocumentPlugin(subDocument),documentComp);
}
}
}
return document;
}
示例9: removeUnusedNamespaces
import org.sbml.jsbml.ext.fbc.FBCConstants; //导入依赖的package包/类
/**
*
* @param doc
*/
public static void removeUnusedNamespaces(SBMLDocument doc)
{
boolean isCompSet = false;
boolean isArraysSet = false;
boolean isFbcSet = false;
LinkedList<SBase> queue = new LinkedList<SBase>();
queue.add(doc);
while(!queue.isEmpty())
{
SBase sbase = queue.pop();
if(!isArraysSet)
{
isArraysSet = isArraysUsed(sbase);
}
if(!isCompSet)
{
isCompSet = isCompUsed(sbase);;
}
if(!isFbcSet)
{
isFbcSet = isFbcUsed(sbase);
}
for (int i = sbase.getChildCount() - 1; i >= 0; i--)
{
TreeNode node = sbase.getChildAt(i);
if(node instanceof SBase)
{
queue.push((SBase) node);
}
}
}
if(!isArraysSet)
{
doc.disablePackage(ArraysConstants.shortLabel);
}
if(!isCompSet)
{
doc.disablePackage(CompConstants.shortLabel);
}
if(!isFbcSet)
{
doc.disablePackage(FBCConstants.shortLabel);
}
}