Archive for October, 2011

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