Sponsored Content
Top Forums Shell Programming and Scripting extract the max value category Post 302621633 by Diya123 on Tuesday 10th of April 2012 07:43:49 PM
Old 04-10-2012
Moderator's Comments:
Mod Comment This is the sample input

Code:
[dvaka@cabiopeds ~]$ head -10  table1_predominent
me      5'UTR   3'UTR   exon    intron
ADARB1  781     55      14      239
C6orf176        477     0       0       0
BASP1   465     14      1       0
SMAD2   94      128     11      225
TEAD1   89      59      4       48
CUL4A   70      21      17      177
CREBZF  69      0       0       0
SFRS1   65      0       4       9
LIFR    63      21      10      16

Moderator's Comments:
Mod Comment This section is code which does not work

Code:
[dvaka@cabiopeds ~]$ awk '{ HI=$1; for(N=2; N<=NF; N++) if($N > HI) HI=$N; $(NF+1)=HI } 1' table1_predominent >output_table1_predominent
[dvaka@cabiopeds ~]$ head -10 output_table1_predominent

me 5'UTR 3'UTR exon intron me
ADARB1 781 55 14 239 ADARB1
C6orf176 477 0 0 0 C6orf176
BASP1 465 14 1 0 BASP1
SMAD2 94 128 11 225 SMAD2
TEAD1 89 59 4 48 TEAD1
CUL4A 70 21 17 177 CUL4A
CREBZF 69 0 0 0 CREBZF
SFRS1 65 0 4 9 SFRS1
LIFR 63 21 10 16 LIFR

Moderator's Comments:
Mod Comment There is no detailed specification of the rule

Moderator's Comments:
Mod Comment This is the desired output

The output I desire is the category
Code:
me 5'UTR 3'UTR exon intron me
ADARB1 781 55 14 239 5'UTR
C6orf176 477 0 0 0 5'UTR
BASP1 465 14 1 0 5'UTR
SMAD2 94 128 11 225 intron
TEAD1 89 59 4 48 5'UTR
CUL4A 70 21 17 177 intron
CREBZF 69 0 0 0 5'UTR
SFRS1 65 0 4 9 5'UTR
LIFR 63 21 10 16 5'UTR

The max number category should be listed in column 6

Thanks,

Diya

Last edited by methyl; 04-10-2012 at 09:14 PM.. Reason: please use code tags. Also attempt at layout of the post logically
 

9 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

How to change the category?

Hi, I submitted my blog on UNIX in the links section. On submitting, i chose the category as Unix/Linux standards, which i now feel is incorrect. I would like to change the category of my link, but i don't find any option to change the category. Please help me in doing the needful. Thanks... (7 Replies)
Discussion started by: guruprasadpr
7 Replies

2. Shell Programming and Scripting

Parsing out the first (top) data lines of each category

Hi All, I need some help in parsing out the first (top) data lines of each category (categories are based on the first column a, b, c, d, e.( see example file below) from a big file a dfg 3 6 8 9 a fgh 5 7 0 9 a gkl 5 2 4 7 a glo 7 0 1 5 b ghj 9 0 4 2 b mkl 7 8 0 5 b jkl 9 0 4 5 c jkl 2... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

3. Shell Programming and Scripting

Getting category when given the variable from external file to shell script

Hi, I have a script that interacts with a config file in the format: file1.txt file2.txt file3.txt file4.txt file5.txt file6.txt I would like to return the Category, when given the file name. (11 Replies)
Discussion started by: MoreCowbell
11 Replies

4. Shell Programming and Scripting

Split file into given category and others using awk

Hi All, Would it be possible using awk to split a given file into two files based on a certain condition such that one output file will contain all lines that fit the condition while the other output file will contain lines that did not fit the condition? Here is a sample input file ... (6 Replies)
Discussion started by: cympaulife
6 Replies

5. Shell Programming and Scripting

Total count in each category for given file list

I have list of file names in filename.txt below is file format >>File1 _________________________ 01~12345~Y~YES~aaaaa~can 02~23456~N~NO~bbbbb~can . . . 99~23__________________________ Need to find total count from each file depending on specific string and add them to have total count... (17 Replies)
Discussion started by: santoshdrkr
17 Replies

6. Shell Programming and Scripting

Data filtering and category assigning

Please consider the following file, I have many groups which can be of 3 types, T1 (Serial_Number 1) T2 (Serial_Number 2) and T1*T2 (all other Serial_Number). I want to only consider groups that have both T1 and T2 present and their values are different from each other. In the example file,... (8 Replies)
Discussion started by: jianp83
8 Replies

7. Shell Programming and Scripting

Inserting column data based on category assignment

please help with the following. I have 4 col data .. instrument , category, variable and value. the instruments belong to particular categories and they all measure some variables (var1 and var2 in this example), the last column is the value an instrument outputs for a variable. I have used... (0 Replies)
Discussion started by: ritakadm
0 Replies

8. Shell Programming and Scripting

Category and count with awk

I want to categorize and count the as below: Input file: A1 G1 C1 F1 A2 G1 C1 F1 A3 G1 C1 F2 A4 G1 C2 F2 A7 G1 C2 F2 A8 G1 C2 F3 A11 G1 C2 F3 A23 G1 C2 F3 B4 G1 C2 F3 AC4 G2 C3 F4 B6 G2 C4 F4 BB5 G2 C4 F4 A25 G2 C5 F4 B13 G2 C5 F5 D12 G2 C5 F5 D2 G2 C5 F5 (3 Replies)
Discussion started by: aydj
3 Replies

9. What is on Your Mind?

Which category do you belong to?

Hello All, I was thinking to start this POLL, sometime back but couldn't get time so starting it today. So we all work either as an Admin or as a Developer or as a QA etc. So let's have a thread(POLL) where we could share our experiences(if it doesn't come anyone's privacy category) so that we... (17 Replies)
Discussion started by: RavinderSingh13
17 Replies
All times are GMT -4. The time now is 04:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy