package src; import java.io.ByteArrayInputStream; import java.util.Iterator; import org.biomoby.client.*; import org.biomoby.shared.*; import org.biomoby.shared.data.*; import org.biomoby.shared.datatypes.MobyObject; import org.biomoby.shared.parser.MobyJob; import org.biomoby.shared.parser.MobyPackage; public class TestGetAffyprobesetIdsForAGILocuscode { public static void main(String[] args) throws Exception{ if (args.length != 2) { System.err.println ("Usage: java TestGetAffyprobesetIdsForAGILocuscode [ []]\n"); System.exit (1); } String agiLocusCode = "AT2G44490"; String serviceEndPoint = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; Central worker = new CentralImpl(); // Make template for finding services MobyService service = new MobyService(); service.setURL(serviceEndPoint); service.setName("getAffyProbesetIdsForAgiLocusCode"); service.setAuthority("ssg.uab.edu"); MobyDataObject input = new MobyDataObject("Object", agiLocusCode); input.setId(agiLocusCode); input.setPrimaryNamespace(new MobyNamespace("AGI_LocusCode")); System.out.println("Finding services matching template: "+service.getName()); MobyService[] validServices = worker.findService(service); // Make sure we have a service to run for this input if(validServices == null || validServices.length == 0){ System.err.println("Could not find any valid services"); } else{ System.out.println("Found some services"); } MobyRequest request = new MobyRequest(worker); request.setDebugMode(true); request.setService(validServices[0]); request.setInput(input); MobyContentInstance responses = request.invokeService(); //System.out.println(responses.toXML()); // Process responses // The service invocation may have had many requests, there is a response // object for each request Iterator i = responses.keySet().iterator(); while(i.hasNext()){ MobyDataJob responseObjects = responses.get(i.next()); // The response for a request may have many objects Iterator i2 = responseObjects.values().iterator(); while(i2.hasNext()){ MobyDataInstance responseObject = (MobyDataInstance)i2.next(); //The response objects may either be simple data, or data sets if(responseObject instanceof MobyDataObject){ System.out.println("Plain simple instance is "+((MobyDataInstance)responseObject).toXML()); } else if(responseObject instanceof MobyDataObjectSet){ System.out.println("Found a collection:"); MobyDataObject[] simples = ((MobyDataObjectSet) responseObject).getElementInstances(); for(int j = 0; j < simples.length; j++){ // Print results probe set ids System.out.println("Object type:" + simples[j].getName()); System.out.println("Probeset Id:" + simples[j].getId()); //Print XML formatted result set XML System.out.println(" Member instance is \n"+simples[j].toXML()); } } else{ System.out.println("Found funky data!" + responseObject); } } } } }