File: removeRenderInformation.java

package info (click to toggle)
libsbml 5.10.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 141,800 kB
  • ctags: 98,793
  • sloc: cpp: 804,405; xml: 206,907; ansic: 66,144; cs: 52,916; java: 25,093; python: 23,449; sh: 9,847; perl: 8,414; makefile: 7,580; ruby: 4,760; csh: 3
file content (54 lines) | stat: -rw-r--r-- 1,507 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 
// @file    removeRenderInformation.java
// @brief   removes render information from the given SBML file
// @author  Frank Bergmann
// 
// This file is part of libSBML.  Please visit http://sbml.org for more
// information about SBML, and the latest version of libSBML.
// 

import org.sbml.libsbml.SBMLDocument;
import org.sbml.libsbml.SBasePlugin;
import org.sbml.libsbml.libsbml;

public class removeRenderInformation {
	public static void main(String[] args) {

		if (args.length != 2) {
			System.err
					.println("usage: removeRenderInformation <input file> <output file>");
			System.err
					.println("       removes the render information object from the input file.");
			System.exit(1);
		}

		String inputFile = args[0];
		String outputFile = args[1];

		SBMLDocument doc = libsbml.readSBMLFromFile(inputFile);
		long numErrors = doc.getNumErrors();

		if (numErrors > 0) {
			System.err.println("Encountered errors while reading the file. ");
			System.err
					.println("Please correct the following errors and try again.");
			doc.printErrors();
			System.exit(2);
		}

		SBasePlugin plugin = doc.getPlugin("render");
		if (plugin == null) {
			System.out
					.println("Warning: the document did not use the render information in the first place. ");
		} else {
			// simply disable the package, this will cause it to no longer being
			// written out
			doc.disablePackage(plugin.getURI(), plugin.getPrefix());
		}

		libsbml.writeSBMLToFile(doc, outputFile);

		System.exit(0);
	}

}