[Biojava-l] Rendering Questions
Ethan Cerami
ecerami@yahoo.com
Mon, 13 Jan 2003 04:52:14 -0800 (PST)
Hi Everyone,
I am new to BioJava, and had a few questions regarding
rendering of features. First off, I started with the
feature rendering code from BioJava in Anger (thanks
for doing this -- these cookbook recipes are
enormously helpful.)
Right now, I am just modifying the code to display
exons. The complete code is below. And, I am using
the following jar file: biojava-20020823.jar.
Here are my questions:
1. I am using the ZiggyFeatureRenderer, and I had
expected to see boxes separated by ziggy lines,
therefore indicating exons and introns. But, I don't
see any ziggy lines, just boxes. What am I doing
wrong?
2. I want to be able to render the same features
without having its actual sequence. How do I do this?
Any help would be most appreciated.
Ethan Cerami
Code follows below:
----------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.biojava.bio.*;
import org.biojava.bio.gui.sequence.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.seq.genomic.Exon;
import org.biojava.bio.symbol.*;
public class FeatureView extends JFrame {
private Sequence seq;
private JPanel jPanel = new JPanel();
private MultiLineRenderer mlr = new
MultiLineRenderer();
private ZiggyFeatureRenderer featr = new
ZiggyFeatureRenderer();
private SequenceRenderer seqR = new
SymbolSequenceRenderer();
private RulerRenderer ruler = new RulerRenderer();
private SequencePanel seqPanel = new SequencePanel();
//the proxy between featr and seqPanel
private FeatureBlockSequenceRenderer fbr = new
FeatureBlockSequenceRenderer();
public FeatureView() {
try {
seq = DNATools.createDNASequence(
"atcgcgcatgcgcgcgcgcgcgcgctttatagcgatagagatata",
"dna 1");
// create multiple exons
for (int i=10; i<=30; i+=10) {
Exon.Template exon = new Exon.Template();
exon.annotation = Annotation.EMPTY_ANNOTATION;
exon.location = new RangeLocation(i, i+5);
exon.strand = StrandedFeature.POSITIVE;
seq.createFeature(exon);
}
//setup GUI
init();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
FeatureView featureView = new FeatureView();
featureView.pack();
featureView.show();
}
/**
* initialize GUI components
*/
private void init() throws Exception {
this.setTitle("FeatureView");
this.getContentPane().add(jPanel,
BorderLayout.CENTER);
jPanel.add(seqPanel, null);
//Register the FeatureRenderer with the
FeatureBlockSequenceRenderer
fbr.setFeatureRenderer(featr);
//add Renderers to the MultiLineRenderer
mlr.addRenderer(fbr);
mlr.addRenderer(seqR);
mlr.addRenderer(ruler);
//set the MultiLineRenderer as the SequencePanels
renderer
seqPanel.setRenderer(mlr);
//set the Sequence to Render
seqPanel.setSequence(seq);
//display the whole Sequence
seqPanel.setRange(new RangeLocation(1,
seq.length()));
}
/**
* Overridden so program terminates when window
closes
*/
protected void processWindowEvent(WindowEvent we) {
if (we.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
} else {
super.processWindowEvent(we);
}
}
}
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com