Sponsored Content
Full Discussion: Reformat text table
Top Forums Shell Programming and Scripting Reformat text table Post 302486541 by yifangt on Sunday 9th of January 2011 09:17:10 AM
Old 01-09-2011
Thanks Scrutinizer!

This is amazing and too complicated to me. Is it possible for you to explain it to me, as I can only catch part of your code?

Actually my data is much bigger than the sample and I ignored the header row and some of the columns. I thought of using perl to parse it, and combined each row with the same SNP name in one row.

1) Each row start with the SNP name that can be repeated for 4 times at most (they are neighbour rows). Some only once. The output is a combined single row for all the same SNP;
2) If the 1st column is the same then the 2nd, 4th and 5th are the same (for same SNP), which means the same SNP in different rows. This is the most different part from my first post;
3) There are 96 variants for each SNP. The variant not listed for a specific SNP indicates the SNP is missing for it and should be labeled as - or NA for consistency of the output format;

Sorry for not put the raw data first as I was trying perl script by using hash and I am a geneticist fond of programming. Anyway, thank you if you can have a look at this again.
Code:
SNP-name    chromosome-polymorphic-sequence-Species-variants    Locus-(if mapped-to-locus)    Chromosomal-map-location
BKN000000001    1    C    RRS-7;RRS-10;Knox-10;Knox-18;Rmx-A02;Rmx-A180;Pna-17;Pna-10;Eden-1;Eden-2;Lov-1;Lov-5;Fab-2;Fab-4;Bil-5;Bil-7;Var2-1;Var2-6;Spr1-2;Spr1-6;Omo2-1;Omo2-3;Ull2-5;Ull2-3;Zdr-1;Zdr-6;Bor-1;Bor-4;Pu2-7;Pu2-23;Lp2-2;Lp2-6;HR5;HR-10;NFA-8;NFA-10;Sq-1;Sq-8;CIBC5;CIBC17;Tamm-2;Tamm-27;KZ9;Goettingen-7;Goettingen-22;Rennes-1;Rennes-11;Uod-1;Uod-7;Cvi-0;Lz-0;Ei-2;Gu-0;Ler-1;Nd-1;C24;CS22491;Wei-0;Ws-0;Yo-0;Col-0;An-1;Br-0;Est-1;Ag-0;Gy-0;Ra-0;Bay-0;Ga-0;Mrk-0;Mz-0;Wt-5;Kas-1;Ct-1;Mr-0;Tsu-1;Mt-0;Nok-3;Wa-1;Fei-0;Se-0;Ts-1;Ts-5;Pro-0;Ll-0;Kondara;Shahdara;Sorbo;Kin-0;Ms-0;Bur-0;Edi-0;Oy-0;Ws-2    AT1G01280    112482
BKN000000001    1    T    KZ1    AT1G01280    112482
BKN000000002    1    G    RRS-7;RRS-10;Knox-10;Knox-18;Rmx-A02;Rmx-A180;Pna-17;Pna-10;Eden-1;Eden-2;Lov-1;Lov-5;Fab-2;Fab-4;Bil-5;Bil-7;Var2-1;Var2-6;Spr1-2;Spr1-6;Omo2-1;Omo2-3;Ull2-5;Ull2-3;Zdr-1;Zdr-6;Bor-1;Bor-4;Pu2-7;Pu2-23;Lp2-2;Lp2-6;HR5;HR-10;NFA-8;NFA-10;Sq-1;Sq-8;CIBC5;CIBC17;Tamm-2;Tamm-27;KZ1;KZ9;Goettingen-7;Goettingen-22;Rennes-1;Rennes-11;Uod-1;Uod-7;Cvi-0;Lz-0;Ei-2;Gu-0;Ler-1;Nd-1;C24;CS22491;Wei-0;Ws-0;Yo-0;Col-0;An-1;Br-0;Est-1;Ag-0;Gy-0;Ra-0;Bay-0;Ga-0;Mrk-0;Mz-0;Wt-5;Kas-1;Ct-1;Mr-0;Tsu-1;Mt-0;Nok-3;Wa-1;Fei-0;Se-0;Ts-1;Ts-5;Pro-0;Ll-0;Shahdara;Kin-0;Ms-0;Bur-0;Edi-0;Oy-0;Ws-2    AT1G01280    112561
BKN000000002    1    A    Kondara;Sorbo    AT1G01280    112561
BKN000000003    1    A    RRS-7;RRS-10;Knox-10;Knox-18;Rmx-A02;Rmx-A180;Pna-10;Eden-1;Eden-2;Lov-1;Lov-5;Fab-2;Fab-4;Bil-5;Bil-7;Var2-1;Var2-6;Spr1-2;Spr1-6;Omo2-1;Omo2-3;Ull2-5;Ull2-3;Zdr-1;Zdr-6;Bor-1;Bor-4;Pu2-7;Pu2-23;Lp2-2;Lp2-6;Sq-8;CIBC5;CIBC17;Tamm-2;Tamm-27;KZ1;KZ9;Goettingen-7;Goettingen-22;Uod-1;Uod-7;Cvi-0;Ei-2;Gu-0;Ler-1;Nd-1;C24;CS22491;Wei-0;Ws-0;Yo-0;Col-0;An-1;Est-1;Gy-0;Ra-0;Bay-0;Ga-0;Mrk-0;Wt-5;Kas-1;Ct-1;Mr-0;Tsu-1;Mt-0;Nok-3;Wa-1;Se-0;Ts-1;Ts-5;Pro-0;Ll-0;Kondara;Shahdara;Sorbo;Kin-0;Ms-0;Bur-0;Edi-0;Oy-0;Ws-2    AT1G01280    112771
BKN000000003    1    G    Pna-17;HR5;HR-10;NFA-8;NFA-10;Sq-1;Rennes-1;Rennes-11;Lz-0;Br-0;Ag-0;Mz-0;Fei-0    AT1G01280    112771
.
.
.

Thanks again!

Yifangt

Last edited by yifangt; 01-09-2011 at 11:02 AM.. Reason: Code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how can I bcp out a table into a text file including the header row in the text file

Hi All, I need to BCP out a table into a text file along with the table headers. Normal BCP out command only bulk copies the data, and not the headers. I am using the following command: bcp database1..table1 out file1.dat -c -t\| -b1000 -A8192 -Uuser -Ppassword -efile.dat.err Regards,... (0 Replies)
Discussion started by: shilpa_acc
0 Replies

2. Shell Programming and Scripting

awk to reformat a text file

I am definitely not an expert with awk, and I want to reformat a text file like the following. This is probably a very easy one for an expert out there. I would like to keep the lines in the same order, but move the heading to only be listed once above the lines. This is what the text file... (7 Replies)
Discussion started by: linux4life
7 Replies

3. Shell Programming and Scripting

Help in script - Getting table name from a text file

hhhhhhhhhh (5 Replies)
Discussion started by: sams
5 Replies

4. Shell Programming and Scripting

Make a table from a text file

Hi, I have a pipe separated text file. Can some someone tell me how to convert it to a table? Text File contents. |Activities|Status1|Status2|Status3| ||NA|$io_running2|$io_running3| |Replication Status|NA|$running2|$running3| ||NA|$master2|$master3|... (1 Reply)
Discussion started by: rocky88
1 Replies

5. Shell Programming and Scripting

Normal text to table format

Hi, I am trying to show my list, from a simple list format to a table (row and column formatted table) Currently i have this format in my output (the formart it will always be like this ) >> first 3 lines must be on the same line aligned, and the next 3 shud be on 2nd line....: INT1:... (10 Replies)
Discussion started by: eboye
10 Replies

6. Shell Programming and Scripting

awk to reformat text

I have this input and want output like below, how can I achieve that through awk: Input: CAT1 FRY-01 CAT1 FRY-04 CAT1 DRY-03 CAT1 FRY-02 CAT1 DRY-04 CAT2 FRY-03 CAT2 FRY-02 CAT2 DRY-01 FAT3 DRY-12 FAT3 FRY-06 Output: category CAT1 item FRY-01 (7 Replies)
Discussion started by: aydj
7 Replies

7. UNIX for Dummies Questions & Answers

Loading text file into table

Hi, I have text file with comma seprater shown below lu8yh,n,Fri,Feb,7,2014,16:5 deer4 deer4,n,Tue,Aug,21,,2012,on r43ed r43ed,n,Tue,Nov,12,2013,12: e43sd e43sd,n,Tue,Jan,1,,2013,on, I am using below code to load the text file into table #!/bin/ksh... (16 Replies)
Discussion started by: stew
16 Replies

8. UNIX for Dummies Questions & Answers

Deleting unwanted text from a table

Hi everyone, I have a microbial diversity table in the format ;k__kingdom; p__phylum, etc, somer rows have descriptions before the :k__ (like the af028349.1 below) is there a way I can get rid of this text (which is different every time) and keep all the other columns? Thanks a bunch! ;... (1 Reply)
Discussion started by: Juan Gonzalez
1 Replies

9. Shell Programming and Scripting

awk to reformat text file

Howdy. AWK beginner here. I need to reformat a text file in the following format: TTGS08-2014001 6018.00 143563.00 ... (2 Replies)
Discussion started by: c47v3770
2 Replies
wml::std::grid(3)						     EN Tools							 wml::std::grid(3)

NAME
wml::std::grid - Layout Grid SYNOPSIS
#use wml::std::grid <grid [attributes]> <cell [attributes]>...</cell> : <cell [attributes]>...</cell> </grid> DESCRIPTION
The "<grid>" container tag provides a mixture between a HTML table and a TeX-like way of specifying its dimensions and the alignment of its cells. ATTRIBUTES
First the possible attributes for "<grid>": "summary" This attribute will be inserted into the "table" tag, see documentation of HTML 4.0 for details on why this attribute is recommended. "layout" This specifies the layout of the grid in X and Y dimension, i.e. "3x2" means 3 columns (x-dimension) and 2 rows (y-dimension). Default is "1x"NCELL where NCELL is the number of cell tags or in other words: Default is a top-down list. "align" This specifies the horizontal alignment of the cells in a row. The argument has to contain as many characters as there are cells in a row. The supported alignment characters are `"l"' (left), `"r"' (right) and `"c"' (center). Default is `"l...l"' (as much "l"'s as there are cells in a row). "valign" This specifies the vertical alignment of the cells in a column. The argument has to contain as many characters as there are cells in a column. The supported alignment characters are `"t"' (top), `"b"' (bottom) and `"m"' (middle). Default is `"t...t"' (as much "t"'s as there are cells in a column). "width" This is the corresponding attribute of the HTML "<table>" tag. Use it to set the width of the grid. Default is no specified width. "spacing" This is the corresponding attribute to "cellspacing" of the HTML "<table>" tag. Use it to set the spacing of cells in the grid, i.e. the space around the content of each cell. Default is 0 (no space). "padding" This is the corresponding attribute to "<cellpadding>" of the HTML "<table>" tag. Use it to set the padding between cells in the grid, i.e. the inter-cell space. Default is 0 (no space). "border" This is the corresponding attribute of the HTML "<table>" tag. Use it to set the border width of the grid. Default is 0 (no border). "bgcolor" This is the corresponding attribute of the HTML "<table>" tag. Use it to set the background color of the grid. Default is no specified color. "color" This sets the foreground (text) color of the grid's contents. Actually this sets the default for the same attribute of "<cell>". Default is no specified color. Second the possible attributes for "<cell>": "align" This is the corresponding attribute of the HTML "<td>" tag. Use it to set the horizontal alignment of the cell's contents. Default is taken from the same attribute of "<grid>". "valign" This is the corresponding attribute of the HTML "<td>" tag. Use it to set the vertical alignment of the cell's contents. Default is taken from the same attribute of "<grid>". "bgcolor" This is the corresponding attribute of the HTML "<td>" tag. Use it to set the background color of a particular cell. Default is no specified color. "color" This sets the foreground (text) color of the cell's contents. This is done via the HTML "<font>" tag. Default is no specified color or the color from the same attribute of "<grid>". "rowspan" This is the corresponding attribute of the HTML "<td>" tag. Use it to span a cell over more then one row of the grid. Default is 1 row. "colspan" This is the corresponding attribute of the HTML "<td>" tag. Use it to span a cell over more then one column of the grid. Default is 1 column. "width" This is the corresponding attribute of the HTML "<td>" tag. Use it to set the width of the cell. Default is no specified width. "height" This is the corresponding attribute of the HTML "<td>" tag. Use it to set the height of the cell. Default is no specified height. EXAMPLE
<grid bgcolor="#000000" color="#ffffff" layout="3x2" align="llr" valign="tm"> <cell>A</cell> <cell>B</cell> <cell>C</cell> <cell>D</cell> <cell>E</cell> <cell>F</cell> </grid> AUTHOR
Ralf S. Engelschall rse@engelschall.com www.engelschall.com REQUIRES
Internal: P1, P2, P3, P5 External: -- SEE ALSO
HTML <"table">-tag. EN Tools 2014-04-16 wml::std::grid(3)
All times are GMT -4. The time now is 10:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy