How to create a genotype database for use as a DAS source

Assuming your data is of the following format seperated by tabs (genotype id, chromosome, position, genotype bases):

rs7763	16	544555	TT
rs763158	16	546105	GG
rs7190878	16	549131	AG
rs4984890	16	552699	CT
rs710925	16	573355	AG

if you have access to a mysql database and admin priveleges you can use the following commands to set up a database called genotype1 with a table called genotype.

First you have to make sure you have a user set up for creating and reading from the database:

if it’s not a production database you can usually log in as root using:

-mysql -u uroot

Then run the following commands:

create database genotype1;

grant all privileges on genotype1.* to genotype@localhost;

then type exit and then login as the genotype user.

mysql -u genotype -p

use genotype;

CREATE TABLE `genotype` (

`rs_id` varchar (100) NOT NULL,

`chromosome` mediumint(8) unsigned NOT NULL,

`position` bigint(8) unsigned NOT NULL,

`bases` varchar(5) default NULL,

PRIMARY KEY  (`rs_id`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

you now have a database called genotype1 set up with a user genotype and password genotype (which obviously you would set to something different).

To load your data file using the unix command line and not when logged into mysql:

mysqlimport -u genotype -pgenotype –local genotype1 genotype.txt

loads the genotype.txt file into the genotype table (note file names need to be same as table name) into the genotype1 database.

Or from the mysql command line: LOAD DATA INFILE ‘/Users/jw12/genotype.txt’ into table genotype;
example configuration for MyDAS:

<datasource uri="person1"

title="genotype db person1"

description="genotype db person1"

doc_href="http://mydas.googlecode.com"

mapmaster="http://mapmaster.esemblTest">

<maintainer email="dasregistry@sanger.ac.uk" />

<version uri="person1" created="2010-04-01">

<class>uk.ac.ebi.mydas.examples.GenotyeMangaerDataSource</class>

<coordinates uri="http://www.dasregistry.org/dasregistry/coordsys/CS_DS94"

source="Gene_ID"

authority="Ensembl"

taxid="9606"

test_range="ENSG00000160916">Ensembl,Gene_ID,Homo sapiens</coordinates>

<capability type="das1:sources" query_uri="http://localhost:8080/das/ensemblTest" />

<capability type="das1:types" query_uri="http://localhost:8080/das/ensemblTest/types" />

<capability type="das1:features" query_uri="http://localhost:8080/das/ensemblTest/features" />

<capability type="das1:feature-by-id" query_uri="http://localhost:8080/das/ensemblTest/features" />

<capability type="das1:stylesheet" query_uri="http://localhost:8080/das/ensemblTest/stylesheet" />

<capability type="das1:unknown-feature" />

<capability     type="das1:maxbins"     />

<capability     type="das1:entry_points"        />

</version>

<dna-command-enabled>true</dna-command-enabled>

<use-feature-id-for-feature-label>true</use-feature-id-for-feature-label>

<include-types-with-zero-count>true</include-types-with-zero-count>

</datasource>

Setting up a MyDAS data source from svn using eclipse

select new -> project from svn.

make sure mydas repository is added in your svn repository list.

navigate to the svn repository mydas->mydastemplate.

select open project with wizard.

open the project as a “dynammic web project”

right click on the “pom.xml” file and select “package”. wait for maven to package the project

right click on the project and select “enable maven dependencies” – project icon will then have “M” on it and may take a minute to build.

right click on the project and select run on server. select a tomcat server and the server should then run.

put this url into your browser: http://localhost:8080/MyDasTemplate/das/referencegff/features?segment=L47615.1

if the page responds with a blank try right clicking on the page and select “view source”. This should then have an xml response containing this data:

<DASGFF>
<SEGMENT id=”L47615.1″ start=”1″ stop=”3221″ total=”2″ version=”FromFile” label=”L47615.1″>
<FEATURE id=”GFF_feature_1″ label=”GFF_feature_1″>
<TYPE id=”TSS”/>
<METHOD id=”hand_built”>hand_built</METHOD>
<START>2097</START>
<END>2097</END>
<ORIENTATION>+</ORIENTATION>
<PHASE>0</PHASE>
</FEATURE>
<FEATURE id=”GFF_feature_2″ label=”GFF_feature_2″>
<TYPE id=”TSS”/>
<METHOD id=”hand_built”>hand_built</METHOD>
<START>2108</START>
<END>2108</END>
<ORIENTATION>+</ORIENTATION>
<PHASE>0</PHASE>
</FEATURE>
</SEGMENT>
</GFF>
</DASGFF>
if this is not the case and you get a class not found error. right click on your project and then “Deployment Assembly” then “add”, add maven library dependencies (select the whole library not individual ones).
when developing a new adapter:
I changed the mydas log to be to the console by changing the rootCategory line in the log4j.properties file:

log4j.rootCategory=DEBUG, console

Generating Features response programmatically with JDAS

I’ve just added a CreateFeatures class in the package org.biodas.jdas.creators this makes making constructing the DAS features object model from the JAXB2 generated classes much easier.

METHOD method=featuresC.createMethod(“Path Problem; Status Under Review”, “Path Problem; Status Under Review”, “ECO:1500”);

TYPE type=featuresC.createType(“Path Problem:Haplotypic clone overlap”, “Path Problem:Haplotypic clone overlap”,”PathProblem”, “SO:1500”);

List<String> partFeatureIds=new ArrayList<String>();

partFeatureIds.add(“ZG-36”);

List <String> parentFeatureIds=new ArrayList<String>();

parentFeatureIds.add(“ZG-3819”);

FEATURE feature=featuresC.createFeature(“ZG-3699”, “5101786”, “5276672”, “+”, “1”, “86”, method, type);

FEATURE feature1=featuresC.createFeatureWithParts(“ZG-3819”, “5101286”, “5276672”, “+”, “1”, “100”, method, type, partFeatureIds );

FEATURE feature2=featuresC.createFeatureWithParents(“ZG-36”, “5101786”, “5276672”, “+”, “1”, “86”, method, type, parentFeatureIds);

List<FEATURE> features=new ArrayList<FEATURE>();

features.add(feature);

features.add(feature1);

features.add(feature2);

SEGMENT segment=featuresC.createSegment(“18″,”1.1″,”4679530”, “5944401”, features);

//DASGFF dgff = this.createDASGFF(segment);

//or if multiple segments

List<SEGMENT> segments=new ArrayList<SEGMENT>();

segments.add(segment);

segments.add(segment);

DASGFF dgff2 = featuresC.createDASGFF(segments);

//test the created objects

DasGFFAdapter dasGffAdapter=new DasGFFAdapter(dgff2);

assertTrue(dasGffAdapter.getGFF().getSegment().size()==2);

List<FEATURE> featuresR = dasGffAdapter.getGFF().getSegment().get(0).getFEATURE();

for(FEATURE featureTemp:featuresR){

System.out.println(featureTemp.getId()+” start=”+featureTemp.getSTART()+” stop=”+featureTemp.getEND());

assertTrue(featureTemp.getId()!=null);

}

——————————————————————————-

replaces code that looks like this:

DASGFF dgff = factory.createDASGFF();

SEGMENT segment = factory.createSEGMENT();

segment.setId(“18”);

segment.setVersion(“1.0”);

segment.setStart(“4679530”);

segment.setStop(“5944401”);

FEATURE feature = factory.createFEATURE();

feature.setId(“TestId1”);

feature.setSTART(new BigInteger(“5101286”));

feature.setEND(new BigInteger(“5276672”));

METHOD method = factory.createMETHOD();

method.setContent(“Path Problem; Status Under Review”);

method.setId(“Path Problem; Status Under Review”);

feature.setMETHOD(method);

feature.setORIENTATION(“+”);

feature.setPHASE(“1”);

feature.setSCORE(“100”);

TYPE type = factory.createTYPE();

type.setContent(“Path Problem:Haplotypic clone overlap”);

type.setId(“Path Problem:Haplotypic clone overlap”);

type.setCategory(“PathProblem”);

type.setCvId(“SO:1500″);

feature.setTYPE(type);

segment.getFEATURE().add(feature);

GFF gff = factory.createGFF();

gff.getSEGMENTOrERRORSEGMENTOrUNKNOWNSEGMENT().add(segment);

dgff.setGFF(gff);

return dgff;

//you can then test the objects created using code like this:

DasGFFAdapter dasGffAdapter=new DasGFFAdapter(dgff2);

List<FEATURE> featuresR = dasGffAdapter.getGFF().getSegment().get(0).getFEATURE();

for(FEATURE featureTemp:featuresR){

System.out.println(featureTemp.getId()+” start=”+featureTemp.getSTART()+” stop=”+featureTemp.getEND());

}

DAS writeback

The current version of the DAS writeback server that uses MyDAS is here: http://code.google.com/p/writeback/ There is an older version that is at a different google location – make sure you don’t use that one. The writeback implementation was written by Gustavo.

The code can be downloaded from svn and used in eclipse much the same as I’ve described in a previous post about JDAS. Once you have the war file running on a server you can access the basic writeback client at http://localhost:8080/writeback-datasource/ not the url stated in the tutorial here http://code.google.com/p/writeback/wiki/Tutorial which probably works if you download the .war file instead of using svn.

The root of the DAS source created is here http://localhost:8080/writeback-datasource/das/

after going through the tutorial example if I make a request to get the features I’ve just created It appears to be that I don’t get a response, however when you look at the source of the web page the xml is there. This I think is a stylesheet issue.

request=

http://localhost:8080/writeback-datasource/das/writeback/features?segment=P05067

to create a mysql database for use:

for das writeback on laptop mysql instance:

mysql -u root

create database daswriteback;

grant all privileges on daswriteback.* to dasregistry@localhost;

Then we edit the hibernate.cfg.xml file to use the mysql database rather than derby:

<!– MYSQL CONFIGURATION –>

<property name=”hibernate.connection.driver_class”>com.mysql.jdbc.Driver</property>

<property name=”hibernate.connection.password”>dasregistry</property>

<property name=”hibernate.connection.url”>jdbc:mysql://localhost/daswriteback</property>

<property name=”hibernate.connection.username”>dasregistry</property>

<property name=”hibernate.dialect”>org.hibernate.dialect.MySQLDialect</property>

<!–         <property name=”hbm2ddl.auto”>update</property> –>

<property name=”hbm2ddl.auto”>create</property>

<property name=”show_sql”>true</property>

<mapping resource=”uk/ac/ebi/mydas/writeback/datasource/model/Type.hbm.xml”/>

<mapping resource=”uk/ac/ebi/mydas/writeback/datasource/model/Method.hbm.xml”/>

<mapping resource=”uk/ac/ebi/mydas/writeback/datasource/model/Target.hbm.xml”/>

<mapping resource=”uk/ac/ebi/mydas/writeback/datasource/model/Users.hbm.xml”/>

<mapping resource=”uk/ac/ebi/mydas/writeback/datasource/model/Feature.hbm.xml”/>

<mapping resource=”uk/ac/ebi/mydas/writeback/datasource/model/Segment.hbm.xml”/>

A new page about setting up the advanced search index for MyDAS is now here: http://code.google.com/p/mydas/wiki/AdvanceSearch?ts=1318324380&updated=AdvanceSearch

New Registry Version 4.1.6

There has been a registry update highlights below:

 

* json responses for web service if accept header = application/json. The exact format of the json response is currently subject to change.

* multiple parameters for the same type are now accepted for e.g. capabilities=features;capabilities=types; returning sources with either features or types

* select active or inactive or both sources using the active=true, active=false or active=any, default is active only

* lists and links to rng files at http://www.dasregistry.org/validation1.6/ http://www.dasregistry.org/validation/

 

Code:

The registry web service code is now self contained and is it’s own project hosted here: http://code.google.com/p/das-registry-web-service/source/browse/ it uses the Spring REST mvc framework, JAXB2 and the Jackson JSON library. Also maven.

 

The new registry rest service uses the JDAS project which is here: http://code.google.com/p/jdas/ . This project has object models generated from the relaxng schema files and thus has an easy to use model that follows the structure of the documents. These objects also have JAXB2 annotations that enables the immediate use of more standard Java libraries like spring REST and the Jackson library.

 

To make a json request you can for example make a request to http://www.dasregistry.org/das/sources after setting the “accept” header in the request to “application/json”. A simple REST client can be downloaded for free from here:

http://rest-client.googlecode.com/

 

 

Configuration for REST spring mvc with Jackson json mapper omitting null properties

Putting this configuration into my spring res-mvc-config.xml changed the json responses so that null properties are not written. To make this changes have an effect you have to get rid of any mvc:annotation-driven element as this stops the overriding having an effect. no errors will be thrown, so it’s not easy to see what is going on or not going on 😉

<<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”http://www.springframework.org/schema/beans&#8221;
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
xmlns:context=”http://www.springframework.org/schema/context&#8221;
xmlns:jdbc=”http://www.springframework.org/schema/jdbc&#8221;
xmlns:mvc=”http://www.springframework.org/schema/mvc&#8221;
xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd”&gt;

<context:component-scan base-package=”uk.ac.sanger.das.dasregistry.springrest.sources”></context:component-scan>

<context:component-scan base-package=”uk.ac.sanger.das.dasregistry.springrest.coordinates”></context:component-scan>
<!– <mvc:annotation-driven/> –>

<bean
>
<property name=”messageConverters”>
<list>
<bean> </bean>
<bean>
<property name=”objectMapper” ref=”jacksonObjectMapper” />
</bean>
</list>
</property>
</bean>

<!– jackson configuration : http://stackoverflow.com/questions/3661769 –>
<bean id=”jacksonObjectMapper” />
<bean id=”jacksonSerializationConfig”
factory-bean=”jacksonObjectMapper” factory-method=”getSerializationConfig” />
<bean
>
<property name=”targetMethod” value=”setSerializationInclusion” />
<property name=”targetObject” ref=”jacksonSerializationConfig” />
<property name=”arguments”>
<list>
<value type=”org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion”>NON_NULL</value>
</list>
</property>
</bean>

</beans>

Mapping urls to a jsp

I have a directory with some schema files in that I wanted to list for people to see. The old tomcat would list them if you went to the directory e.g. http://www.dasregistry.org/validation1.6/ there were a few forums where various answers to how to do this came up top in google, but they weren’t very simple. The simplest being to create a servlet to redirect to the jsp from your desired urls, simple but not very quick. I knew there had to be a quicker way as jsps are compiled into servlets anyway!

I found an article here http://www.xyzws.com/JSPfaq/how-to-config-a-jsp-file-in-webxml/2 which is what I wanted and it’s pretty easy.

<servlet>
<servlet-name>myjsp</servlet-name>
<jsp-file>/myjsp.jsp</jsp-file>
<init-param>
<param-name>hello</param-name>
<param-value>test</param-value>
</init-param>
</servlet>
 
<servlet-mapping>
<servlet-name>myjsp</servlet-name>
<url-pattern>/myjsp</url-pattern>
</servlet-mapping>

so for my directory listing url I used these mappings to allow access through the directory with and without the last slash:

<servlet>

<servlet-name>relaxng1.6</servlet-name>

<jsp-file>/validation1.6/relaxng.jsp</jsp-file>

</servlet>

 

<servlet-mapping>

<servlet-name>relaxng1.6</servlet-name>

<url-pattern>/validation1.6</url-pattern>

</servlet-mapping>

<servlet-mapping>

<servlet-name>relaxng1.6</servlet-name>

<url-pattern>/validation1.6/</url-pattern>

</servlet-mapping>