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());

}

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: