Code Search for Developers
 
 
  

OneParameterBD.java from Oscill8 at Krugle


Show OneParameterBD.java syntax highlighted

/******************************************************************************
 * 
 *   File: $Id: OneParameterBD.java,v 1.2 2005/11/07 18:20:20 emeryconrad Exp $
 *   Author: Emery Conrad
 * 
 *   Descritption:
 *     ...
 * 
 *   Oscill8 Dynamical Systems Toolset
 *   Copyright (C) 2005, Emery Conrad
 *
 *   This library is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU Lesser General Public
 *   License as published by the Free Software Foundation; either
 *   version 2.1 of the License, or (at your option) any later version.
 *
 *   This library is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *   Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public
 *   License along with this library; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *****************************************************************************/

package com.oscill8.o8biospice;

import java.io.*;
import java.lang.*;

import org.biospice.analyzer.Analyzer;
import org.biospice.analyzer.AnalysisException;
import org.biospice.analyzer.AnalyzerFactory;
import org.biospice.analyzer.ParameterDeclaration;
import org.biospice.analyzer.ParameterDeclarationGroup;
import org.biospice.analyzer.ParameterValue;
import org.biospice.analyzer.ParameterValueGroup;
import org.biospice.datatypes.*;
import org.biospice.datatypes.impl.*;

public class OneParameterBD extends AnalyzerFactory implements Analyzer 
{
	private static final ParameterDeclarationGroup INPUTS = 
		new ParameterDeclarationGroup(new ParameterDeclaration[] {
			new ParameterDeclaration("odefile",
			                         BiodataFile.class,
			                         false,
			                         true,
			                         null,
			                         null),
			new ParameterDeclaration("workdir",
			                         String.class,
			                         false,
			                         true,
			                         null,
			                         "/tmp"),
			new ParameterDeclaration("parameter",
			                         String.class,
			                         false,
			                         true,
			                         null,
			                         null)});
				
	private static final ParameterDeclarationGroup OUTPUTS = 
		new ParameterDeclarationGroup(new ParameterDeclaration[] {
			new ParameterDeclaration("plot",
			                         String.class,
			                         false,
			                         true,
			                         null,
			                         null)});
				

	public OneParameterBD()
	{
		ICON_NAME = "/com/oscill8/o8biospice/o81p_icon.gif";
	}


	/******************************************************************
	 * 
	 *  analyze
	 *
	 *****************************************************************/
	public ParameterValueGroup analyze(ParameterValueGroup inputs) throws AnalysisException
	{
		BiodataFileImpl f = (BiodataFileImpl)inputs.getParameterValue("odefile").getValue();
		String odefile = (String)f.getPathname();
		String workdir = (String)inputs.getParameterValue("workdir").getValue();
		String parameter = (String)inputs.getParameterValue("parameter").getValue();

		// get input files to external simulator prep'd
		String o8r = 
			"<o8r>\n" +
			"  <run name=\"1p\" type=\"OneParameter\">\n" +
			"    <output format=\"o8p\">1p</output>\n" +
			"    <interest n=\"1\">\n" +
			"      <par name=\"" + parameter.toString() + "\" />\n" +
		  "    </interest>\n" +
			"  </run>\n" +
			"</o8r>\n";
		try
		{
			FileWriter fw = new FileWriter(workdir + "/1p.o8r");
			fw.write(o8r, 0, o8r.length());
			fw.close();
		}
		catch(IOException e)
		{
			throw new AnalysisException("couldn't save o8r file: " + e.getMessage());
		}
			
		// run o8core
		try
		{
			Runtime rt = Runtime.getRuntime();
			String []cmd = new String[] 
				{
					System.getenv("OSCILL8_DIR") + "/bin/o8core",
					"-m", odefile, "-r", "1p.o8r", "-l", "1p.log"
				};

			Process p = rt.exec(cmd, null, new File(workdir));
			p.waitFor();
		}
		catch(Exception e)
		{
			throw new AnalysisException("couldn't run o8r text: " + e.getMessage());
		}

		// do output
		ParameterValueGroup pvg = new ParameterValueGroup(OUTPUTS);
		pvg.setParameterValue("plot", workdir + "/1p.o8p");

		return pvg;
	}



	/******************************************************************
	 * 
	 *  factory implementation
	 *
	 *****************************************************************/


	public Analyzer getAnalyzer() 
	{
		return this;
	}
    
	public String getDisplayName() 
	{
		return "Oscill8 One Parameter BD";
	}
    
	public String getName() 
	{
		return "com.oscill8.o8biospice.OneParameterBD";
	}
    
	public String getDescription() 
	{
		return "Generates one-parameter bifrucation diagrams";
	}
    
	public ParameterDeclarationGroup getInputs() 
	{
		return INPUTS;
	}
    
	public ParameterDeclarationGroup getOutputs() 
	{
		return OUTPUTS;
	}
    
	public String getReferences() 
	{
		return "http://oscill8.sourceforge.net";
	}    
}





See more files for this project here

Oscill8

Oscill8 is a suite of tools for analyzing dynamical systems which concentrates on understanding how the dynamical behavior depends on the parameters using bifurcation theory and reaction network theory.

Project homepage: http://sourceforge.net/projects/oscill8
Programming language(s): C,C#,C++
License: other

  NonJavaAnalyzer.java
  OneParameterBD.java
  Plotter.java
  Simulator.java