Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: sorting a file - multilevel

by ini2005 (Novice)
on Jun 14, 2008 at 10:08 UTC ( [id://692067]=note: print w/replies, xml ) Need Help??


in reply to Re: sorting a file - multilevel
in thread sorting a file - multilevel

Yes, the 10th col is UTR but it varies, ti can be GENE, CDS, RNA..

another problem is that I need GENE to always be first (not regular lexicographic sort)

Replies are listed 'Best First'.
Re^3: sorting a file - multilevel
by runrig (Abbot) on Jun 25, 2008 at 20:34 UTC
    another problem is that I need GENE to always be first (not regular lexicographic sort)
    That's doable...here's a sample (the sed and awk can easily be replaced by perl...left as an exercise):
    #!/bin/ksh awk 'BEGIN { SORTCD["GENE"] = 1 SORTCD["CDS"] = 2 SORTCD["RNA"] = 3 } { print SORTCD[$3], $0 }' <<EOT | 1 1 RNA 1 1 GENE 1 2 CDS EOT sort -n -k2,3 -k1,1 | sed -e 's/^[0-9]* //'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://692067]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-24 18:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found