0

I have multiple text files like this:

>nexus0013_Pseudomonas_59M
NNNNNNNNNNNNNNNNNNNNNNNNNNNTTGCTAGGTGCCCTGCGCTTCCCTGTGGCTGCCGCCTGGGCCGCCGAGCTCCGCCAGGAACTGCCGGGGGGCACGCAGACCTGGAGCAGCGAAGAACTGCTCAGGCATCCGCAGGCCCGCGACCTGGACATCCCGGCCGACGTCGCCTACCGCCGGAACATGCGCTACCGCGCCGTGCCACTGGCGGCCTTGTTGAAAGGCGTGCATCCCGAAGACCATTTGCAGGCCGTGGCCAGCGATGGCTTCGCCGCCGAGTTGCCGGCCGCCCCGCTGCTCGCCGAACAGGGCTCGCAAGCCTGGCTGGCGATAGAGGATCCGCAGCGCCCCTGGCCGCCGTTGGGCGCCGGCAAGCCGTCCGCCGGGCCGTTCTATCTGGTCTGGAGCAAACCCGAGGAAAAACGCATCGGTCCGGAGCAATGGCCCTTCCAGGTCGTCCGCATCCGCTATCAGCCCCCTCTGGCCGAACGCTTCCCGGCCCTGCTGCCGGCCGCCGACGCCAGCGCGGAAGTGCGCGCCGGCTTCGCCGTGTTCCAGAAGAACTGCCTGGCCTGCCACCGTCTCAACGGTGCCGGCGACGCCCAGTTCGGCCCGGACCTGAACCTGCCGTACAACCCCACCGAGTACTTCCAGCCGCAATTCCTCTCCCGCTACATCCGCGACCCGCAGGCGCTGCGGCAATGGCCACAGGCGAAAATGCCGGCGTTCCCGGAACGGGTGATCGACGACCAGGAGTTGCGCCAGTTGATCGGCTACTTGCGCCACATGGCCGGCCGCAAGGCGGGCGCGGCCGGCTGA
>nexus0013_Pseudomonas_62M
ATGCCTGTCACTCTCCCGCGCCTGGCGTTGCTAGGTGCCCTGCTCTTCCCTGTGGCTGCCGCCTGGGCCGCCGAGCTCCGCCTGGAACTGCCGGGGGGCACGCAGACCTGGAGCAGCGAAGAACTGCTCAGGCATCCGCAGGCCCGCGACCTGGACATCCCGGCCGACGTCGCCTACCGCCGGAACATGCGCTACCGCGCCGTGCCACTGGCGGCCTTGTTG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CGCAATTCCTCTCCCGCTACATCCGCGACCCGCAGGCGCTGCGGCAATGGCCACAGGCGAAAATGCCGGCGTTCCCGGAACGGGTGATCGACGACCAGGAGTTGCGCCAGTTGATCGGCTACTTGCGCCACATGGCCGGCCGCAAGGCGGGCGCGGCCGGCTGA
>nexus0013_Pseudomonas_61M
ATGCCTGTCACTCTCCCGCGCCTGGCGTTGCTAGGTGCCCTGCTCTTCCCTGTGGCTGCCGCCTGGGCCGCCGAGCTCCGCCTGGAACTGCCGGGGGGCACGCAGACCTGGAGCAGCGAAGAACTGCTCAGGCATCCGCAGGCCCGCGACCTGGACATCCCGGCCGACGTCGCCTACCGCCGGAACATGCGCTACCGCGCCGTGCCACTGGCGGCCTTGTTGAAAGGCGTGCATCCCGAAGACCATTTGCAGGCCGTGGCCAGCGATGGCTTCGCCGCCGAGTTGCCGGCCGCCCCGCTGCTCGCCGAACAGGGCTCGCAAGCCTGGCTGGCGATAGAGGATCCGCAGCGCCCCTGGCCGCCGTTGGGCGCCGGCAAGCCGTCCGCCGGGCCGTTCTATCTGGTCTGGAGCAAACCCGAGGAAAAACGCATCGGTCCGGAGCAATGGCCCTTCCAGGTCGTCCGCATCCGCTATCAGCCCCCTCTGGCCGAACGCTTCCCGGCCCTGCTGCCGGCCGCCGACGCCAGCGCGGAAGTGCGCGCCGGCTTCGCCGTGTTCCAGAAGAACTGCCTGGCCTGCCACCGTCTCAACGGTGCCGGCGACGCCCAGTTCGGCCCGGACCTGAACCTGCCGTACAACCCCACCGAGTACTTCCAGCCGCAATTCCTCTCCCGCTACATCCGCGACCCGCAGGCGCTGCGGCAATGGCCACAGGCGAAAATGCCGGCGTTCCCGGAACGGGTGATCGACGACCAGGAGTTGCGCCAGTTGATCGGCTACTTGCGCCACATGGCCGGCCGCAAGGCGGGCGCGGCCGGCTGA

I want to order both the header (everything after ">") and its corresponding sequence in the following line so that they end up being in ascending numerical order like this:

>nexus0013_Pseudomonas_53M
ATGCCTGTCACTCTCCCGCGCCTGGCG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GCCGGCGTTCCCGGAACGGGTGATCGACGACCAGGAGTTGCGCCAGTTGATCGGCTACTTGCGCCACATGGCCGGCCGCAAGGCGGGCGCGGCCGGCTGA
>nexus0013_Pseudomonas_62M
ATGCCTGTCACTCTCCCGCGCCTGGCGTTGCTAGGTGCCCTGCTCTTCCCTGTGGCTGCCGCCTGGGCCGCCGAGCTCCGCCTGGAACTGCCGGGGGGCACGCAGACCTGGAGCAGCGAAGAACTGCTCAGGCATCCGCAGGCCCGCGACCTGGACATCCCGGCCGACGTCGCCTACCGCCGGAACATGCGCTACCGCGCCGTGCCACTGGCGGCCTTGTTGAAAGGCGTGCATCCCGAAGACCATTTGCAGGCCGTGGCCAGCGATGGCTTCGCCGCCGAGTTGCCGGCCGCCCCGCTGCTCGCCGAACAGGGCTCGCAAGCCTGGCTGGCGATAGAGGATCCGCAGCGCCCCTGGCCGCCGTTGGGCGCCGGCAAGCCGTCCGCCGGGCCGTTCTATCTGGTCTGGAGCAAACCCGAGGAAAAACGCATCGGTCCGGAGCAATGGCCCTTCCAGGTCGTCCGCATCCGCTATCAGCCCCCTCTGGCCGAACGCTTCCCGGCCCTGCTGCCGGCCGCCGACGCCAGCGCGGAAGTGCGCGCCGGCTTCGCCGTGTTCCAGAAGAACTGCCTGGCCTGCCACCGTCTCAACGGTGCCGGCGACGCCCAGTTCGGCCCGGACCTGAACCTGCCGTACAACCCCACCGAGTACTTCCAGCCGCAATTCCTCTCCCGCTACATCCGCGACCCGCAGGCGCTGCGGCAATGGCCACAGGCGAAAATGCCGGCGTTCCCGGAACGGGTGATCGACGACCAGGAGTTGCGCCAGTTGATCGGCTACTTGCGCCACATGGCCGGCCGCAAGGCGGGCGCGGCCGGCTGA

*Sometimes there are missing numbers, like 56M in this case

4

Using sed:

sed -i -e 's/ /\n/' <(sort -n <(sed -e 'N;s/\n/ /' in.txt))

Explanations:

  • The sed -e 'N;s/\n/ /' in.txt parts, joining each two lines together with single space
  • The sort -n part, performing numerical sort
  • Then sed -e 's/ /\n/', we are spliting the line to two separate lines according to the single space between.
  • The -i will write the changes into the input file inplace, using -i.bak will take a backup from input file first.
  • How can I make it overwrite the result? – Manuel Aug 11 '17 at 15:18
  • 1
    @Manuel Hi please see updated answer. – αғsнιη Aug 11 '17 at 15:20
  • 1
    Very good. Worked great! – Manuel Aug 11 '17 at 15:35
3
awk '/^>/ { printf "%s ",$0; next; } { print; }' file1 | 
    sort -n |
    awk '{ print $1; print $2; }'
  • Nice. Do you know of a good awk reference manual? And/or can you explain how the '/^>/ { printf "%s ",$0; next; } { print; }' command works? Thanks. I seriously have read about half of this manual and I think I need to read it about 2 more times after I finish before it sinks in: gnu.org/software/gawk/manual/gawk.html – Jesse_b Aug 11 '17 at 3:57
  • 3
    I cannot recommend anything. I am not familiar with the available tutorials. I just read the man page (quite often) when I started using awk. I doubt that there is any tutorial which you would have to read only once... (unless it comes with tons of "homework"). The /^>... is simple: It selects every other line (you could do the same with the modulo 2 value of NR). The > lines shall become the first part of the resulting lines. Thus we may not print a newline at the end (which print does). The next reads the next line and prevents the { print; } block from being executed. – Hauke Laging Aug 11 '17 at 4:15
2

You could use the Schwartzian transform in Perl to do this:

perl -ne '
   push @A, $_.=<>}{
   print for
    # Schwartzian transform
    map  { $_->[0] }             # recover the line
    sort { $a->[1] <=> $b->[1] } # do the sorting using the key 
    map  { [$_,/_(\d+)M$/m] }    # setup: line(zeroth-indexed) + sorting key(first index)
    @A;                          # operate on elements of array @A
' yourfile

Results

>nexus0013_Pseudomonas_53M
.....................................
>nexus0013_Pseudomonas_54M
.....................................
>nexus0013_Pseudomonas_55M
.....................................
>nexus0013_Pseudomonas_57M
.....................................
>nexus0013_Pseudomonas_58M
.....................................
>nexus0013_Pseudomonas_59M
.....................................
>nexus0013_Pseudomonas_60M
.....................................
>nexus0013_Pseudomonas_61M
.....................................
>nexus0013_Pseudomonas_62M
.....................................

stuff the file in line pairs into the array @A. Then at the eof, we perform the Schwartzian maneuver, `map->sort->map'. In this we carry the whole line + the sorting data along and in the last step of the maneuver, recover the line after it's been sorted. So for this case, the sorting key is the number before the M which lies at the line boundary. (Remember we appended the next line)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.