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


Java UnitDefinition.createUnit方法代码示例

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


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

示例1: addUnits

import org.sbml.jsbml.UnitDefinition; //导入方法依赖的package包/类
/**
 * Adds the units.
 */
public void addUnits(){
	if(unit == null) 
		return; 
	UnitDefinition ud = model.createUnitDefinition();
	ud.setId("length");
	Unit u = ud.createUnit();
	u.setKind(Kind.METRE);
	u.setExponent(1d);
	u.setScale(0);
	u.setMultiplier(getUnitMultiplier(unit));

	ud = model.createUnitDefinition();
	ud.setId("area");
	u = ud.createUnit();
	u.setKind(Kind.METRE);
	u.setExponent(2d);
	u.setScale(0);
	u.setMultiplier(getUnitMultiplier(unit));
	
	ud = model.createUnitDefinition();
	ud.setId("volume");
	u = ud.createUnit();
	u.setKind(Kind.METRE);
	u.setExponent(3d);
	u.setScale(0);
	u.setMultiplier(getUnitMultiplier(unit));
}
 
开发者ID:spatialsimulator,项目名称:XitoSBML,代码行数:31,代码来源:SpatialSBMLExporter.java

示例2: createGridDegradationReaction

import org.sbml.jsbml.UnitDefinition; //导入方法依赖的package包/类
public void createGridDegradationReaction(Species species) {
	
	String speciesID = species.getId();
	Boolean speciesDegrades = false;			
	//Reaction degradation = BioModel.getDegradationReaction(speciesID, compModel);
	
	//fix the sbo term/annotation stuff if it's not correct
	//if (degradation != null)
		speciesDegrades = true;
	
	//only make grid degradation reactions if the species is degradable
	if (speciesDegrades) {
	
		//create array of grid degradation reactions
		String decayString = GlobalConstants.KECDECAY_STRING;
		double decayRate = sbml.getModel().getParameter("kecd").getValue();
			
		String decayUnitString = "u_1_second_n1";
		
		if (sbml.getModel().getUnitDefinition(decayUnitString) == null) {
			
			UnitDefinition ud = sbml.getModel().createUnitDefinition();
			Unit unit = ud.createUnit();
			unit.setExponent(-1.0);
			unit.setKind(Unit.Kind.valueOf("second".toUpperCase()));
			unit.setScale(0);
			unit.setMultiplier(1);
			ud.setId(decayUnitString);
		}
		
		Reaction r = sbml.getModel().createReaction();
		r.setId(GlobalConstants.DEGRADATION + "_" + speciesID);
		SBMLutilities.setMetaId(r, r.getId());
		r.setCompartment(sbml.getModel().getCompartment(0).getId());
		SBMLutilities.cloneDimensionAddIndex(sbml.getModel().getCompartment(r.getCompartment()),r,"compartment");
		r.setReversible(false);
		//r.setFast(false);
		r.setSBOTerm(GlobalConstants.SBO_DEGRADATION);
		
		AnnotationUtility.setGridAnnotation(r, gridTable.getNumRows(), gridTable.getNumCols());
		
		KineticLaw kl = r.createKineticLaw();
		
		if (decayRate > 0) {
			
			//this is the mathematical expression for the decay
			String decayExpression = decayString + "* get2DArrayElement(" + speciesID + ", i, j)";				
			
			SpeciesReference reactant = r.createReactant();
			reactant.setSpecies(speciesID);
			reactant.setStoichiometry(1);
			reactant.setConstant(false);
			
			LocalParameter i = kl.createLocalParameter();
			LocalParameter j = kl.createLocalParameter();
			
			AnnotationUtility.setArraySizeAnnotation(i, gridTable.getNumRows());
			AnnotationUtility.setArraySizeAnnotation(j, gridTable.getNumCols());

			i.setId("i");
			j.setId("j");
			
			//parameter: id="kecd" value=(usually 0.005) units="u_1_second_n1" (inverse seconds)
			Utility.Parameter(kl, decayString, decayRate, decayUnitString);
			
			//formula: kecd * species
			kl.setMath(SBMLutilities.myParseFormula(decayExpression));
			
			Utility.addReaction(sbml, r);
		}
	}		
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:73,代码来源:BioModel.java

示例3: getUnitString

import org.sbml.jsbml.UnitDefinition; //导入方法依赖的package包/类
public static String getUnitString(ArrayList<String> unitNames,
		ArrayList<Integer> exponents, ArrayList<Integer> multiplier,
		Model model) {

	// First build the name of the unit and see if it exists, start by
	// sorting the units to build a unique string
	for (int i = 0; i < unitNames.size(); i++) {
		for (int j = i; j > 0; j--) {
			if (unitNames.get(j - 1).compareTo(unitNames.get(i)) > 0) {
				Integer tempD = multiplier.get(j);
				Integer tempI = exponents.get(j);
				String tempS = unitNames.get(j);

				multiplier.set(j, multiplier.get(j - 1));
				unitNames.set(j, unitNames.get(j - 1));
				exponents.set(j, exponents.get(j - 1));

				multiplier.set(j - 1, tempD);
				unitNames.set(j - 1, tempS);
				exponents.set(j - 1, tempI);
			}
		}
	}
	UnitDefinition t = new UnitDefinition(GlobalConstants.SBML_LEVEL, GlobalConstants.SBML_VERSION);
	String name = "u_";
	for (int i = 0; i < unitNames.size(); i++) {
		String sign = "";
		if (exponents.get(i).intValue() < 0) {
			sign = "n";
		}
		name = name + multiplier.get(i) + "_" + unitNames.get(i) + "_"
				+ sign + Math.abs(exponents.get(i)) + "_";
		Unit u = t.createUnit();
		u.setKind(Kind.valueOf(unitNames.get(i).toUpperCase()));
		u.setExponent(exponents.get(i).intValue()*1.0);
		u.setMultiplier(multiplier.get(i).intValue());
		u.setScale(0);
	}
	name = name.substring(0, name.length() - 1);
	t.setId(name);
	if (model.getUnitDefinition(name) == null) {
		model.addUnitDefinition(t);
	}
	return name;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:46,代码来源:GeneticNetwork.java

示例4: checkUnitsInRateRule

import org.sbml.jsbml.UnitDefinition; //导入方法依赖的package包/类
public static boolean checkUnitsInRateRule(SBMLDocument document, Rule rule)
{
	UnitDefinition unitDef = rule.getDerivedUnitDefinition();
	UnitDefinition unitDefVar;
	Species species = document.getModel().getSpecies(getVariable(rule));
	Compartment compartment = document.getModel().getCompartment(getVariable(rule));
	Parameter parameter = document.getModel().getParameter(getVariable(rule));
	if (species != null)
	{
		unitDefVar = species.getDerivedUnitDefinition();
	}
	else if (compartment != null)
	{
		unitDefVar = compartment.getDerivedUnitDefinition();
	}
	else
	{
		unitDefVar = parameter.getDerivedUnitDefinition();
	}
	if (document.getModel().getUnitDefinition("time") != null)
	{
		UnitDefinition timeUnitDef = document.getModel().getUnitDefinition("time");
		for (int i = 0; i < timeUnitDef.getUnitCount(); i++)
		{
			Unit timeUnit = timeUnitDef.getUnit(i);
			Unit recTimeUnit = unitDefVar.createUnit();
			recTimeUnit.setKind(timeUnit.getKind());
			if (document.getLevel() < 3)
			{
				recTimeUnit.setExponent(timeUnit.getExponent() * (-1));
			}
			else
			{
				recTimeUnit.setExponent(timeUnit.getExponent() * (-1));
			}
			recTimeUnit.setScale(timeUnit.getScale());
			recTimeUnit.setMultiplier(timeUnit.getMultiplier());
		}
	}
	else
	{
		Unit unit = unitDefVar.createUnit();
		unit.setKind(Unit.Kind.valueOf("second".toUpperCase()));
		unit.setExponent(-1.0);
		unit.setScale(0);
		unit.setMultiplier(1.0);
	}
	if (!UnitDefinition.areEquivalent(unitDef, unitDefVar))
	{
		return true;
	}
	return false;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:54,代码来源:SBMLutilities.java


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