Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:14:27+00:00 2026-06-12T12:14:27+00:00

I have data in this format (tab separated columns)… Name_00001 Annotation_1 gene 329412 330509

  • 0

I have data in this format (tab separated columns)…

Name_00001  Annotation_1    gene    329412  330509  .   -   .   ID=TAXON_00029;Name=TAXON_00029
Name_00001  Annotation_1    mRNA    329412  330509  .   -   .   ID=TAXON_00029T0;Parent=TAXON_00029
Name_00001  Annotation_1    exon    193957  194252  .   +   .   ID=exon:TAXON_00022T0:1;Parent=TAXON_00022T0
Name_00001  Annotation_1    exon    195500  197118  .   +   .   ID=exon:TAXON_00022T0:2;Parent=TAXON_00022T0

…and I would like to sort by the first 5 numbers in column 9 in ascending order. I.e. so the file looks like this:

Name_00001  Annotation_1    exon    193957  194252  .   +   .   ID=exon:TAXON_00022T0:1;Parent=TAXON_00022T0
Name_00001  Annotation_1    exon    195500  197118  .   +   .   ID=exon:TAXON_00022T0:2;Parent=TAXON_00022T0    
Name_00001  Annotation_1    gene    329412  330509  .   -   .   ID=TAXON_00029;Name=TAXON_00029
Name_00001  Annotation_1    mRNA    329412  330509  .   -   .   ID=TAXON_00029T0;Parent=TAXON_00029

I have tried to use Unix or Perl, but my skills are very limited…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:14:28+00:00Added an answer on June 12, 2026 at 12:14 pm

    If you really want to sort by the first 5 digits in column 9,
    that is something you cannot literally explain to sort, but as you suggested, perl is more flexible:

    perl -e 'sub key { 0+((split(/\s+/,$_[0]))[8] =~ /(\d{5})/)[0] }; print sort { key($a) <=> key($b) } <>' < unsorted > sorted
    

    This assumes the five digits always exist and are always consecutive but you can take it from there.
    It’s better to put the code into a file, add use warnings; use strict; and increase legibility:

    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    
    sub key {
        my $line = $_[0];
        my @fields = split(/\s+/,$line);
        my ($keystring) = $fields[8] =~ /(\d{5})/;
        my $key = 0 + $keystring;
        $key
    }
    
    print sort { key($a) <=> key($b) } <>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a lagre data frame which looks similar to this format: line1 line2<tab>value1
I have data in this format coming from a database... BUS 101S Business and
I currently have my data stored in this format : Word1 - Word2 -
I have some data in the database, in this format: Description~Level||Description~Level|| I want to
I have a table which stores the data related to posts in this format
I have data of this format: 2011-06-22 22:33:19 23 15 2011-06-23 09:46:13 12 79
I have data stored in this format in amazon simpledb source code success fa.php
I have JSON Data in this format : var jsonData = [{date:'August 19, 2004',open:100.01,high:104.06},{date:'August
I have 2 columns of data with numerical values as follows which is tab
I have data like this: Team | goal a | 5 b | 8

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.