[Biojava-l] Rendering Questions
Thomas Down
td2@sanger.ac.uk
Mon, 13 Jan 2003 13:29:33 +0000
On Mon, Jan 13, 2003 at 04:52:14AM -0800, Ethan Cerami wrote:
>
> 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.
If you're using that snapshot, you might want to update
to the latest and greatest code from http://cvs.open-bio.org/
> 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?
ZiggyFeatureRenderer can't magically work out how to
group your exons together. What it actually does it
render features with non-contiguous locations in the
`tented exons' style.
Try:
StrandedFeature.Template temp = new StrandedFeature.Template();
temp.type = "transcript";
temp.source = "just_testing";
temp.location = LocationTools.union(
new RangeLocation(10, 20),
new RangeLocation(50, 60)
);
temp.annotation = Annotation.EMPTY_ANNOTATION;
temp.strand = StrandedFeature.POSITIVE
> 2. I want to be able to render the same features
> without having its actual sequence. How do I do this?
Do you just want to remove the sequence line from the
display? In this case, just remove the line:
mlr.addRenderer(seqR);
If you want to draw some boxes on the screen without
knowing the sequence *at all*, I've found some code like
this works well:
SymbolList dummySL = new DummySymbolList(
DNATools.getDNA(),
1000
);
Sequence dummySeq = new SimpleSequence(
dummySL,
"foo",
"bar",
Annotation.EMPTY_ANNOTATION
);
// construct features on dummySeq
Hope this helps,
Thomas.
> 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
> _______________________________________________
> Biojava-l mailing list - Biojava-l@biojava.org
> http://biojava.org/mailman/listinfo/biojava-l