// TestCreateGCP_LocusCollection.java // // Created: January 2006 // // This file is a component of the BioMoby project. // Copyright Martin Senger (martin.senger@gmail.com). // package org.jmoby.tutorial.client; import org.biomoby.shared.parser.MobyCollection; import org.biomoby.shared.parser.MobySimple; import org.biomoby.shared.datatypes.GCP_Locus; import org.jdom.Document; import org.jdom.output.XMLOutputter; import org.jdom.output.Format; /** * A example how to create a BioMoby input data using Moses * pre-generated data types.

* * @author Martin Senger * @version $Id: TestCreateGCP_LocusCollection.java.txt,v 1.1 2007/05/21 00:56:15 senger Exp $ */ public class TestCreateGCP_LocusCollection { public static void main (String [] args) { try { // create a collection MobyCollection collection = new MobyCollection(); collection.setName ("loci"); // and fill it with simple elements String[] idsOfElements = new String[] { "a", "b" }; for (int i = 0; i < idsOfElements.length; i++) { GCP_Locus locus = new GCP_Locus(); locus.setId (idsOfElements[i]); locus.setNamespace ("Tropgene_Banana"); // here you can add some GCP_Alleles and/or // GCP_LinkageGroup to the just created locus by // calling methods locus.set_allele(...) and // locus.set_linkage_group(...) MobySimple simple = new MobySimple(); simple.setData (locus); collection.addData (simple); } // and print it as a text... System.out.println (collection); // and print it as an XML Document doc = new Document (collection.toXML()); XMLOutputter xo = new XMLOutputter(); xo.setFormat (Format.getPrettyFormat()); System.out.println (xo.outputString (doc)); } catch (Exception e) { System.err.println ("===ERROR==="); e.printStackTrace(); System.err.println ("==========="); } } }