MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Text Wrapping

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32105] RE: [mg32099] Text Wrapping
  • From: "David Park" <djmp at earthlink.net>
  • Date: Mon, 24 Dec 2001 23:44:37 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Brian,

If you have a huge data base it will never fit of one screen so you will
need a convenient method to display selected portions of it. Here is what I
came up with. I assume that the data contains only the single sequence since
we can generate the paired sequence.

This generates the four nucleotides randomly.

randomnucl :=
  Switch[Random[],
    _?(# < 0.25 &), a,
    _?(# < 0.50 &), t,
    _?(# < 0.75 &), c,
    _, g]

This generates a sample DNA sequence.

data = Table[randomnucl, {1000}];

This generates the matching base pair. For our display short rows will be
padded with blanks.

basepair[n_] :=
  Switch[n,
    a, t,
    t, a,
    c, g,
    g, c,
    _, " "]

This routine will display a segment of the data.

DisplaySequence::usage =
    "DisplaySequence[start, rowlength, n][data] will display the DNA
sequence \
in paired format starting at position start in n rowlength rows. data must
be \
a sequence of the symbols a, t, g and c. ";

DisplaySequence[start_, rowlength_, rows_][data_] :=
  Module[{subdata, rowgrid},
    rowgrid[subdata_] :=
      GridBox[{ToBoxes /@ subdata, Table["|", {rowlength}],
            ToBoxes /@ basepair /@ subdata}, GridBaseline -> Bottom];
    subdata =
      Take[data, {start, Min[start + rows rowlength - 1, Length[data]]}];
    subdata = Partition[subdata, rowlength, rowlength, {1, 1}, " "];
    subdata = {rowgrid[#]} & /@ subdata;
    DisplayForm[FrameBox[GridBox[subdata, RowLines -> True]]]
    ]

Here is a sample display.

data // DisplaySequence[905, 25, 5]

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

> From: Brian Higgins [mailto:bghiggins at ucdavis.edu]
To: mathgroup at smc.vnet.net
>
> I am interested in using GridBoxes to generate some output  that will
> wrap in the notebook window. Here is a simple example using numbers
>
> CellPrint[Cell[BoxData[GridBox[Table[Random[], {2}, {10}]]],
> "Output"]]
>
> The output is a "table" consisting of two rows and 10 columns.
> Obviously you can scroll to see all the entries, but I would like the
> output to wrap in the browser window because in my application(see
> below) the number of columns will be  large(>1000).  Is there some
> option I can specify for GridBoxes, Cell?
>
> In my application the actual  grid structure I want to generate is a
> DNA sequence of paired bases that can be graphically represented as
> follows
>
> CellPrint[
>   Cell[RowBox[{GridBox[{Characters["atcgt"], Table["|", {5}],
>             Characters["tagca"]}, GridBaseline -> Bottom]}],
> "Output"]]
>
>
> Any thoughts how this can be done?
>
>
> Brian
>



  • Prev by Date: Re Solve for Equations
  • Next by Date: movie export
  • Previous by thread: Text Wrapping
  • Next by thread: Integration of "Which" function