Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: sorting a file - multilevel

by runrig (Abbot)
on Jun 14, 2008 at 01:56 UTC ( [id://692041]=note: print w/replies, xml ) Need Help??


in reply to sorting a file - multilevel

I would just use sort (not sort). Except that it looks like the "10th" position in your file is just the string "UTR". How are you counting columns?

Replies are listed 'Best First'.
Re^2: sorting a file - multilevel
by ini2005 (Novice) on Jun 14, 2008 at 10:08 UTC

    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)

      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://692041]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-25 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found