moved files out of trunk/ in prep to track this proj primarily on github
[javacyc.git] / JavacycTest.java
blobae09021c2bb16313dac8f5a45e75082ae8b1b8ae
1 /**
2 A program to test Javacyc.
3 */
5 import java.util.ArrayList;
6 import java.io.*;
8 public class JavacycTest
10 public static void printLists(ArrayList list)
12 for (int i = 0; i < list.size(); i++)
14 Object obj = list.get(i);
15 if (obj instanceof String)
17 String str = (String)obj;
18 System.out.println(str);
20 else if (obj instanceof ArrayList)
22 System.out.println("*begin inner list*");
23 ArrayList aList = (ArrayList)obj;
24 printLists(aList);
25 System.out.println("*end inner list*");
27 else
29 System.out.println("WARNING THIS SHOULD NOT HAPPEN!");
34 public static void main(String[] args) throws IOException
36 Javacyc cyc = new Javacyc("ARA");
37 BufferedReader in = new BufferedReader(
38 new InputStreamReader(System.in));
40 // test a function that returns a boolean
41 System.out.println("Testing a function that returns a boolean: "
42 + "coercible-to-frame-p");
43 System.out.print("Enter a value for frame: ");
44 String thing = in.readLine();
45 boolean result1 = cyc.coercibleToFrameP(thing);
46 if (result1)
48 System.out.println("The result: true\n");
50 else
52 System.out.println("The result: false\n");
55 // test a function that returns a string
56 System.out.println("Testing a function that returns a string: "
57 + "full-enzyme-name");
58 System.out.print("Enter a value for enzyme: ");
59 String enzyme = in.readLine();
60 String result2 = cyc.fullEnzymeName(enzyme);
61 System.out.println("The result: " + result2 +"\n");
63 // test a function that returns an ArrayList
64 System.out.println("Testing a function that returns an ArrayList: "
65 + "genes-of-pathway 'PWY-581");
66 ArrayList result3 = cyc.genesOfPathway("PWY-581");
67 System.out.println("The returned values: ");
68 for (int i = 0; i < result3.size(); i++)
70 String rxn = (String)result3.get(i);
71 System.out.println(rxn);
74 // test a function that returns multiple lists
75 System.out.println("\nTesting a function that returns multiple"
76 + " lists: reaction-reactants-and-products");
77 System.out.print("Enter a value for reaction: ");
78 String rxn = in.readLine();
79 System.out.print("Enter a value for pathway: ");
80 String pwy = in.readLine();
81 ArrayList result4 = cyc.reactionReactantsAndProducts(rxn, pwy);
82 System.out.println("The returned values: ");
83 printLists(result4);