Re: [BioMart Users] biomart java API problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [BioMart Users] biomart java API problem

Arek Kasprzyk
Hi Andy,
all the documentation for the Java API is available from http://www.biomart.org/other/rc6_documentation.pdf
(page 85, section 11.6). However you know this already because you are using an example from there. You must however make sure that your registry xml file is in the 0.8 format (you can pick up an example of such file from the 'registry' directory). Pleae let me know if you have problems finding it. The registry file in your email is in 0.7 version format so it is not going to work with your code.

a


On Tue, Dec 20, 2011 at 4:15 AM, 石偉良 <[hidden email]> wrote:
Thank you very much for the help for the previous questions.
I want to add the java API to my java program to access MYSQL serve for query database.
Can you refer the documentation more detail about the biomart java API?
Regards
Andy

Here is my code (Same code given at BioMart 0.8 User Manual release candidate 6 May, 2011)
import java.util.List; import org.biomart.api.Portal; import org.biomart.api.factory.MartRegistryFactory; import org.biomart.api.factory.XmlMartRegistryFactory; import org.biomart.api.lite.Attribute; import org.biomart.api.lite.Dataset; import org.biomart.api.lite.Filter; import org.biomart.api.lite.Mart; public class PortalExample { public static void main(String[] args) { MartRegistryFactory factory = new XmlMartRegistryFactory("C:/main.xml");
Portal portal = new Portal(factory); List<Mart> marts = portal.getMarts(null); System.out.println(String.format("Got %s marts", marts.size())); List<Dataset> datasets = portal.getDatasets(marts.get(0).getName()); System.out.println(String.format("Got %s datasets", datasets.size())); List<Filter> filters = portal.getFilters(datasets.get(0).getName(), marts.get(0).getConfigName(), null); System.out.println(String.format("Got %s filters", filters.size())); List<Attribute> attributes = portal.getAttributes(datasets.get(0).getName(), marts.get(0).getConfigName(), null); System.out.println(String.format("Got %s attributes", attributes.size())); System.exit(0); } }

Here is the Registry file in C:/main.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MartRegistry>
<MartRegistry>

<RegistryDBPointer
                    databaseType = "mysql"
                    host         = "ensembldb.ensembl.org" 
                    port         = "3306" 
                    database     = "central_registry" 
                    schema       = "central_registry" 
                    user         = "anonymous"
                    password     = ""
/>


</MartRegistry>


my error message:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/biomart/api/factory/XmlMartRegistryFactory : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at test.biomart.PortalExample.main(PortalExample.java:22)




_______________________________________________
Users mailing list
[hidden email]
https://lists.biomart.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [BioMart Users] biomart java API problem

Arek Kasprzyk
Hi Andy,
forgot to mention that you can of course create your own registry file to access your own database using MConfigurator tool included in the distribution

a

On Tue, Dec 20, 2011 at 7:46 AM, Arek Kasprzyk <[hidden email]> wrote:
Hi Andy,
all the documentation for the Java API is available from http://www.biomart.org/other/rc6_documentation.pdf
(page 85, section 11.6). However you know this already because you are using an example from there. You must however make sure that your registry xml file is in the 0.8 format (you can pick up an example of such file from the 'registry' directory). Pleae let me know if you have problems finding it. The registry file in your email is in 0.7 version format so it is not going to work with your code.

a



On Tue, Dec 20, 2011 at 4:15 AM, 石偉良 <[hidden email]> wrote:
Thank you very much for the help for the previous questions.
I want to add the java API to my java program to access MYSQL serve for query database.
Can you refer the documentation more detail about the biomart java API?
Regards
Andy

Here is my code (Same code given at BioMart 0.8 User Manual release candidate 6 May, 2011)
import java.util.List; import org.biomart.api.Portal; import org.biomart.api.factory.MartRegistryFactory; import org.biomart.api.factory.XmlMartRegistryFactory; import org.biomart.api.lite.Attribute; import org.biomart.api.lite.Dataset; import org.biomart.api.lite.Filter; import org.biomart.api.lite.Mart; public class PortalExample { public static void main(String[] args) { MartRegistryFactory factory = new XmlMartRegistryFactory("C:/main.xml");
Portal portal = new Portal(factory); List<Mart> marts = portal.getMarts(null); System.out.println(String.format("Got %s marts", marts.size())); List<Dataset> datasets = portal.getDatasets(marts.get(0).getName()); System.out.println(String.format("Got %s datasets", datasets.size())); List<Filter> filters = portal.getFilters(datasets.get(0).getName(), marts.get(0).getConfigName(), null); System.out.println(String.format("Got %s filters", filters.size())); List<Attribute> attributes = portal.getAttributes(datasets.get(0).getName(), marts.get(0).getConfigName(), null); System.out.println(String.format("Got %s attributes", attributes.size())); System.exit(0); } }

Here is the Registry file in C:/main.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MartRegistry>
<MartRegistry>

<RegistryDBPointer
                    databaseType = "mysql"
                    host         = "ensembldb.ensembl.org" 
                    port         = "3306" 
                    database     = "central_registry" 
                    schema       = "central_registry" 
                    user         = "anonymous"
                    password     = ""
/>


</MartRegistry>


my error message:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/biomart/api/factory/XmlMartRegistryFactory : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at test.biomart.PortalExample.main(PortalExample.java:22)





_______________________________________________
Users mailing list
[hidden email]
https://lists.biomart.org/mailman/listinfo/users