当前位置: 首页>>代码示例>>Java>>正文


Java SBMLReader类代码示例

本文整理汇总了Java中org.sbml.jsbml.SBMLReader的典型用法代码示例。如果您正苦于以下问题:Java SBMLReader类的具体用法?Java SBMLReader怎么用?Java SBMLReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SBMLReader类属于org.sbml.jsbml包,在下文中一共展示了SBMLReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDocument

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
/**
 * Gets the document.
 *
 * @return the document
 * @throws NullPointerException the null pointer exception
 * @throws XMLStreamException the XML stream exception
 */
protected SBMLDocument getDocument() throws NullPointerException, XMLStreamException{
	JFileChooser chooser = new JFileChooser(OpenDialog.getLastDirectory());
	chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
	chooser.setMultiSelectionEnabled(false);
	chooser.setFileFilter(new FileNameExtensionFilter("SBML File(*.xml)", "xml"));
	int returnVal = chooser.showOpenDialog(null);

	if (returnVal != JFileChooser.APPROVE_OPTION)
		throw new NullPointerException();
	File f = chooser.getSelectedFile();
	return SBMLReader.read(f.getAbsolutePath());
}
 
开发者ID:spatialsimulator,项目名称:XitoSBML,代码行数:20,代码来源:MainSBaseSpatial.java

示例2: applyChanges

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
public SBMLDocument applyChanges(SEDMLDocument sedmlDoc, SBMLDocument sbmlDoc, org.jlibsedml.Model model)
		throws SBMLException, XPathExpressionException, XMLStreamException, XMLException {
	SedML sedml = sedmlDoc.getSedMLModel();
	if (sedml.getModelWithId(model.getSource()) != null) {
		sbmlDoc = applyChanges(sedmlDoc, sbmlDoc, sedml.getModelWithId(model.getSource()));
	}
	SBMLWriter Xwriter = new SBMLWriter();
	SBMLReader Xreader = new SBMLReader();
	sbmlDoc = Xreader
			.readSBMLFromString(sedmlDoc.getChangedModel(model.getId(), Xwriter.writeSBMLToString(sbmlDoc)));
	return sbmlDoc;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:13,代码来源:BioModel.java

示例3: convertToFBCVersion2

import org.sbml.jsbml.SBMLReader; //导入依赖的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;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:36,代码来源:SBMLutilities.java

示例4: isSBML

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
private static boolean isSBML(File file)
{
  try 
  {
    SBMLReader.read(file);
  } 
  catch (Exception e) 
  {
    return false;
  }
  return true;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:13,代码来源:Analysis.java

示例5: applyChanges

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
private SBMLDocument applyChanges(SEDMLDocument sedmlDoc, SBMLDocument sbmlDoc, org.jlibsedml.Model model)
    throws SBMLException, XPathExpressionException, XMLStreamException, XMLException {
  SedML sedml = sedmlDoc.getSedMLModel();
  if (sedml.getModelWithId(model.getSource()) != null) {
    sbmlDoc = applyChanges(sedmlDoc, sbmlDoc, sedml.getModelWithId(model.getSource()));
  }
  SBMLWriter Xwriter = new SBMLWriter();
  SBMLReader Xreader = new SBMLReader();
  sbmlDoc = Xreader
      .readSBMLFromString(sedmlDoc.getChangedModel(model.getId(), Xwriter.writeSBMLToString(sbmlDoc)));
  return sbmlDoc;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:13,代码来源:Analysis.java

示例6: applyChanges

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
public SBMLDocument applyChanges(SEDMLDocument sedmlDoc, SBMLDocument sbmlDoc, Model model)
		throws SBMLException, XPathExpressionException, XMLStreamException, XMLException {
	SedML sedml = sedmlDoc.getSedMLModel();
	if (sedml.getModelWithId(model.getSource()) != null) {
		sbmlDoc = applyChanges(sedmlDoc, sbmlDoc, sedml.getModelWithId(model.getSource()));
	}
	SBMLWriter Xwriter = new SBMLWriter();
	SBMLReader Xreader = new SBMLReader();
	sbmlDoc = Xreader
			.readSBMLFromString(sedmlDoc.getChangedModel(model.getId(), Xwriter.writeSBMLToString(sbmlDoc)));
	return sbmlDoc;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:13,代码来源:ModelEditor.java

示例7: performModelChanges

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
public void performModelChanges(String stem) {
	SEDMLDocument sedmlDoc;
	sedmlDoc = biosim.getSEDMLDocument();
	SedML sedml = sedmlDoc.getSedMLModel();
	String taskId = simName;
	if (stem != null && !stem.equals("")) {
		taskId = taskId + "__" + stem;
	}
	AbstractTask task = sedml.getTaskWithId(taskId);
	if (task == null)
		return;
	// Simulation simulation =
	// sedml.getSimulation(task.getSimulationReference());
	Model model = sedml.getModelWithId(task.getModelReference());
	SBMLWriter Xwriter = new SBMLWriter();
	try {
		SBMLDocument sbmlDoc = SBMLReader
				.read(new File(path + File.separator + simName + File.separator + filename));
		//createDataGenerators(sbmlDoc.getModel(), sedml, taskId);
		//SEDMLutilities.removeDataGeneratorsByTaskId(sedml, taskId);
		biosim.writeSEDMLDocument();
		if (model.getListOfChanges().size() == 0)
			return;
		Xwriter.write(applyChanges(sedmlDoc, sbmlDoc, model),
				path + File.separator + simName + File.separator + filename);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:31,代码来源:ModelEditor.java

示例8: loadSBMLFromBuffer

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
private void loadSBMLFromBuffer(StringBuffer buffer) {
	try {
		SBMLDocument doc = SBMLReader.read(buffer.toString());
		biomodel.setSBMLDocument(doc);
		biomodel.setSBMLLayout(SBMLutilities.getLayoutModelPlugin(doc.getModel()));
		biomodel.setSBMLFBC(SBMLutilities.getFBCModelPlugin(doc.getModel(), true));
		biomodel.setSBMLComp(SBMLutilities.getCompSBMLDocumentPlugin(doc));
		biomodel.setSBMLCompModel(SBMLutilities.getCompModelPlugin(doc.getModel()));
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
	biomodel.loadDefaultEnclosingCompartment();
	biomodel.loadGridSize();
   grid.createGrid(null);
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:16,代码来源:ModelEditor.java

示例9: applyChanges

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
private SBMLDocument applyChanges(SEDMLDocument sedmlDoc, SBMLDocument sbmlDoc, org.jlibsedml.Model model)
		throws SBMLException, XPathExpressionException, XMLStreamException, XMLException {
	SedML sedml = sedmlDoc.getSedMLModel();
	if (sedml.getModelWithId(model.getSource()) != null) {
		sbmlDoc = applyChanges(sedmlDoc, sbmlDoc, sedml.getModelWithId(model.getSource()));
	}
	SBMLWriter Xwriter = new SBMLWriter();
	SBMLReader Xreader = new SBMLReader();
	sbmlDoc = Xreader
			.readSBMLFromString(sedmlDoc.getChangedModel(model.getId(), Xwriter.writeSBMLToString(sbmlDoc)));
	return sbmlDoc;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:13,代码来源:Gui.java

示例10: performAnalysis

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
private void performAnalysis(String modelFileName, String analysisId) throws Exception {
	SedML sedml = sedmlDocument.getSedMLModel();
	AbstractTask task = sedml.getTaskWithId(analysisId);
	if (task == null) return;
	org.jlibsedml.Model model = sedml.getModelWithId(task.getModelReference());
	SBMLDocument sbmlDoc = SBMLReader.read(new File(root + File.separator + modelFileName));
	if (model.getListOfChanges().size() != 0) {
		try {
			sbmlDoc = applyChanges(sedmlDocument, sbmlDoc, model);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} 
	SBMLWriter Xwriter = new SBMLWriter();
	Xwriter.write(sbmlDoc, root + File.separator + "_" + modelFileName);
	AnalysisProperties properties;
	properties = new AnalysisProperties(analysisId, modelFileName, root, false);
	properties.addObserver(this);
    BioModel biomodel =  BioModel.createBioModel(root + File.separator, this);
    biomodel.load(root + File.separator + "_" + modelFileName);
    SBMLDocument flatten = biomodel.flattenModel(true);
    String newFilename = root + File.separator + analysisId + File.separator + modelFileName;
    SBMLWriter.write(flatten, newFilename, ' ', (short) 2);
    File tempFile = new File(root + File.separator + "_" + modelFileName);
    tempFile.delete();
    properties.setId(analysisId);
    AnalysisPropertiesLoader.loadSEDML(sedmlDocument, "", properties);
    AnalysisPropertiesWriter.createProperties(properties);
	Run run = new Run(properties);
    run.addObserver(this);
    run.execute();
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:34,代码来源:Gui.java

示例11: initializeDocument

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
private void initializeDocument(InputStream inputStream) {
    SBMLReader reader = new SBMLReader();
    logger.info("Parsing SBML...");
    try {
        document = reader.readSBMLFromStream(inputStream);
    } catch (XMLStreamException e) {
        logger.error("Could not read SBML File.");
        e.printStackTrace();
    }
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:11,代码来源:SBMLParser.java

示例12: writeSMT2ToString

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
public static String writeSMT2ToString(ModelSettings settings) throws XMLStreamException,
		IOException {
	List<String> params = new ArrayList<String>();
	for (String param : settings.getParams()) {
		params.add(param);
	}
	return writeSMT2ToString(SBMLReader.read(new File(settings.getSBMLFile())), params,
			TraceParser.parseCopasiOutput(new File(settings.getTimeSeriesFile())), null);
}
 
开发者ID:dreal,项目名称:biology,代码行数:10,代码来源:Utility.java

示例13: flattenModelWithLibSBML

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
public SBMLDocument flattenModelWithLibSBML(boolean removeComp) throws Exception {
		if (Executables.libsbmlFound) {
			String tempFile = filename.replace(".gcm", "").replace(".xml", "") + "_temp.xml";
			save(tempFile);
			
			org.sbml.libsbml.SBMLReader reader = new org.sbml.libsbml.SBMLReader();
			org.sbml.libsbml.SBMLDocument document = reader.readSBML(tempFile);
			new File(tempFile).delete();
			
			document.enablePackage(org.sbml.libsbml.LayoutExtension.getXmlnsL3V1V1(), "layout", false);
			// TODO: Hack to allow flatten to work as it crashes with arrays namespace
			//document.enablePackage(org.sbml.libsbml.ArraysExtension.getXmlnsL3V1V1(), "arrays", false);
			document.enablePackage(org.sbml.libsbml.CompExtension.getXmlnsL3V1V1(), "comp", true);
			document.setPackageRequired("comp", true); 
			// following line causes unsatisfied link error via libsbml when attempting to save hierarchical models on windows machine
//			((org.sbml.libsbml.CompSBMLDocumentPlugin)document.getPlugin("comp")).setRequired(true);
			org.sbml.libsbml.CompModelPlugin sbmlCompModel = (org.sbml.libsbml.CompModelPlugin) document.getModel().getPlugin("comp");
			
			long numSubModels = sbmlCompModel.getNumSubmodels();
			if (numSubModels > 0 && isGridEnabled()) {
				expandListOfSubmodels(sbmlCompModel, document);
			}
			if (document.getErrorLog().getNumFailsWithSeverity(libsbmlConstants.LIBSBML_SEV_ERROR) > 0) {
				document.printErrors();
				return null;
			}
			else if (numSubModels > 0) {
				/* create a new conversion properties structure */
				org.sbml.libsbml.ConversionProperties props = new org.sbml.libsbml.ConversionProperties();

				/* add an option that we want to flatten */
				props.addOption("flatten comp", true, "flatten comp");

				/* add an option to leave ports if the user has requested this */
				props.addOption("leavePorts", !removeComp, "unused ports should be listed in the flattened model");
				
				//props.addOption("abortIfUnflattenable", "none");
				
				props.addOption("performValidation", "false");
				
				props.addOption("basePath", path);

				//org.sbml.libsbml.SBMLWriter writer = new org.sbml.libsbml.SBMLWriter();
				//writer.writeSBMLToFile(document, tempFile);

				/* perform the conversion */
				if (document.convert(props) != libsbmlConstants.LIBSBML_OPERATION_SUCCESS) {
					return null;
				}
			}
			document.enablePackage(org.sbml.libsbml.CompExtension.getXmlnsL3V1V1(), "comp", !removeComp);
			org.sbml.libsbml.SBMLWriter writer = new org.sbml.libsbml.SBMLWriter();
			writer.writeSBMLToFile(document, tempFile);
			BioModel bioModel = BioModel.createBioModel(path, this);
			bioModel.load(tempFile);
			new File(tempFile).delete();
			SBMLDocument doc = bioModel.getSBMLDocument();
			return doc;
		}
		throw new Exception("libsbml not found.  Unable to flatten model.");
	}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:62,代码来源:BioModel.java

示例14: readSBML

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
public static SBMLDocument readSBML(String filename, BioObservable observable, BioObserver observer) throws XMLStreamException, IOException, BioSimException
	{
		SBMLDocument document = null;
		document = SBMLReader.read(new File(filename));
		if (document.getModel().isSetId())
		{
			document.getModel().setId(document.getModel().getId().replace(".", "_"));
		}

		if (document.getLevel() < GlobalConstants.SBML_LEVEL || document.getVersion() < GlobalConstants.SBML_VERSION)
		{
			if (!Executables.libsbmlFound)
			{
				ArrayList<SBase> sbmlElements = getListOfAllElements(document);
				for (SBase sbase : sbmlElements) {
					if (sbase instanceof Reaction) {
						Reaction r = (Reaction) sbase;
						if (r.isSetFast()) {
							r.unsetFast();
						}
					}
				}
				document.setLevelAndVersion(GlobalConstants.SBML_LEVEL, GlobalConstants.SBML_VERSION, false);
//				SBMLWriter Xwriter = new SBMLWriter();
//				Xwriter.writeSBMLToFile(document, filename);
				return document;
				
			}
			long numErrors = 0;
			org.sbml.libsbml.SBMLReader reader = new org.sbml.libsbml.SBMLReader();
			org.sbml.libsbml.SBMLDocument doc = reader.readSBML(filename);
			numErrors = doc.checkL3v2Compatibility();
			if (numErrors > 0)
			{
				String msg = "Conversion to SBML level " + GlobalConstants.SBML_LEVEL + " version " + GlobalConstants.SBML_VERSION
						+ " produced the errors listed below.";
				msg += "It is recommended that you fix them before using these models or you may get unexpected results.\n\n";
				msg += "--------------------------------------------------------------------------------------\n";
				msg += filename;
				msg += "\n--------------------------------------------------------------------------------------\n\n";
				for (int i = 0; i < numErrors; i++)
				{
					String error = doc.getError(i).getMessage();
					msg += i + ":" + error + "\n";
				}
				
				Message message = new Message();
				message.setScrollableErrorDialog("SBML Conversion Errors and Warnings", msg);
				
				if(observable != null)
				{
				  observable.notifyObservers(message);
				}
				if(observer != null)
				{
				  observer.update(message);
				}
			}
			convertToL3(doc);
			doc.setLevelAndVersion(GlobalConstants.SBML_LEVEL, GlobalConstants.SBML_VERSION, false);
			/*
			 * for (int i = 0; i < doc.getNumErrors(); i++) {
			 * System.out.println(doc.getError(i).getMessage()); }
			 */
			org.sbml.libsbml.SBMLWriter writer = new org.sbml.libsbml.SBMLWriter();
			writer.writeSBMLToFile(doc, filename);
			document = SBMLReader.read(new File(filename));
		}
		document = convertToFBCVersion2(filename,document);
		return document;
	}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:72,代码来源:SBMLutilities.java

示例15: estimate

import org.sbml.jsbml.SBMLReader; //导入依赖的package包/类
/**
 * This function is used to execute parameter estimation from a given SBML file. The input model serves
 * as a template and the existing parameters in the model will set the bounds to which parameter estimation will use.
 * <p>
 * In addition, the SBML file is used for simulation when estimating the values of the parameters. 
 * 
 * @param SBMLFileName: the input SBML file
 * @param root: the directory where the experimental data is located
 * @param parameterList: the list of parameters that needs to have the value estimated.
 * @param experiments: data object that holds the experimental data.
 * @param speciesCollection: data object that holds the species in the model.
 * @return A new SBMLDocument containing the new parameter values.
 * @throws IOException - when a file cannot be read or written.
 * @throws XMLStreamException - when an SBML file cannot be parsed.
 * @throws BioSimException - when simulation encounters a problem.
 */
public static SBMLDocument estimate(String SBMLFileName, String root, List<String> parameterList, Experiments experiments, SpeciesCollection speciesCollection) throws IOException, XMLStreamException, BioSimException
{

	int numberofparameters = parameterList.size();
	int sp = 0;
	int n = experiments.getExperiments().get(0).size() - 1;
	double ep = experiments.getExperiments().get(0).get(n).get(0);
	double[] lowerbounds = new double[numberofparameters];
	double[] upperbounds = new double[numberofparameters];
	HierarchicalSimulation sim = new HierarchicalODERKSimulator(SBMLFileName, root, 0);
	sim.initialize(randomSeed, 0);

	for (int i = 0; i < numberofparameters; i++)
	{
		lowerbounds[i] = sim.getTopLevelValue(parameterList.get(i)) / 100;
		upperbounds[i] = sim.getTopLevelValue(parameterList.get(i)) * 100;
	}
	Modelsettings M1 = new Modelsettings(experiments.getExperiments().get(0).get(0), speciesCollection.size(), sp, (int) ep, lowerbounds, upperbounds, false);
	// Objective objective1 = new ObjectiveSqureError(M1,0.1);

	EvolutionMethodSetting EMS = new EvolutionMethodSetting();
	ObjectiveSqureError TP = new ObjectiveSqureError(sim, experiments, parameterList, speciesCollection, M1, 0.1);

	SRES sres = new SRES(TP, EMS);
	SRES.Solution solution = sres.run(200).getBestSolution();

	// TODO: report results: take average of error
	// TODO: weight mean square error. Add small value
	SBMLDocument doc = SBMLReader.read(new File(SBMLFileName));
	Model model = doc.getModel();
	
	for(int i = 0; i < parameterList.size(); i++)
	{
	  Parameter parameter = model.getParameter(parameterList.get(i));
	  
	  if(parameter != null)
	  {
	    parameter.setValue(solution.getFeatures()[i]);
	  }
	}
	System.out.println(solution.toString());
	return doc;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:60,代码来源:ParameterEstimator.java


注:本文中的org.sbml.jsbml.SBMLReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。